diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 144e3cf..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,214 +0,0 @@ -version: 2.1 - -orbs: - docker: circleci/docker@1.0.1 - -commands: - docker-build: - description: | - Build a Docker image - parameters: - dockerfile: - default: Dockerfile - description: | - Name of dockerfile to use, defaults to Dockerfile - type: string - extra_build_args: - default: '' - description: > - Extra flags to pass to docker build. For examples, see - https://docs.docker.com/engine/reference/commandline/build - type: string - registry: - default: docker.io - description: | - Comma separated list of registry to use, defaults to docker.io - type: string - image: - default: cdalvaro/saltstack-master - description: | - Name of image to build - type: string - tag: - default: ${CIRCLE_SHA1} - description: | - Image tag, defaults to the value of $CIRCLE_SHA1 - type: string - path: - default: . - description: | - Path to the directory containing your Dockerfile and build context, - defaults to . (working directory) - type: string - cache_from: - default: '' - description: | - Comma-separated list of images. Images will first be pulled, then passed - as the --cache-from build argument - https://docs.docker.com/engine/reference/commandline/build/ - type: string - no_output_timeout: - default: 10m - description: | - No output timeout for build step - type: string - steps: - - when: - condition: <> - steps: - - run: - name: Build image for <> - no_output_timeout: <> - command: > - echo "<>" | sed -n 1'p' | tr ',' '\n' | - while read image; do - echo "Pulling ${image} ..."; - docker pull "${image}" || true - done - - docker_tag_args="" - - IFS="," read -ra DOCKER_REGISTRIES \<<< "<>" - - for registry in "${DOCKER_REGISTRIES[@]}"; do - IFS="," read -ra DOCKER_TAGS \<<< "<>" - - for tag in "${DOCKER_TAGS[@]}"; do - docker_tag_args="${docker_tag_args} -t ${registry}/<>:${tag}" - done - done - - docker build - <<#parameters.extra_build_args>><><> - \ - --cache-from <> \ - -f <>/<> \ - ${docker_tag_args} \ - <> - - unless: - condition: <> - steps: - - run: - name: Building image for <> - no_output_timeout: <> - command: > - docker_tag_args="" - - IFS="," read -ra DOCKER_REGISTRIES \<<< "<>" - - for registry in "${DOCKER_REGISTRIES[@]}"; do - IFS="," read -ra DOCKER_TAGS \<<< "<>" - - for tag in "${DOCKER_TAGS[@]}"; do - docker_tag_args="${docker_tag_args} -t ${registry}/<>:${tag}" - done - done - - docker build - <<#parameters.extra_build_args>><><> - \ - -f <>/<> \ - ${docker_tag_args} \ - <> - - docker-save: - description: | - Save one or more images to a tar archive - parameters: - registry: - default: docker.io - description: | - Comma separated list of registry to use, defaults to docker.io - type: string - image: - description: | - Name of image to save - type: string - tag: - default: ${CIRCLE_SHA1} - description: | - Image tag, defaults to the value of $CIRCLE_SHA1 - type: string - steps: - - run: - name: Save image to tar archive - command: > - docker_images="" - - IFS="," read -ra DOCKER_REGISTRIES \<<< "<>" - - for registry in "${DOCKER_REGISTRIES[@]}"; do - IFS="," read -ra DOCKER_TAGS \<<< "<>" - - for tag in "${DOCKER_TAGS[@]}"; do - docker_images="${docker_images} ${registry}/<>:${tag}" - done - done - - mkdir -p ~/docker/ - - docker save -o ~/docker/docker-images.tar ${docker_images} - - persist_to_workspace: - root: ~/ - paths: - - docker - - docker-load: - description: | - Load tar archive - steps: - - attach_workspace: - at: ~/ - - run: - name: Load images from tar archive - command: > - docker load -i ~/docker/docker-images.tar - -jobs: - build: - executor: docker/machine - steps: - - checkout - - docker-build: - registry: docker.io,quay.io - image: cdalvaro/saltstack-master - tag: ${CIRCLE_TAG:-latest} - cache_from: docker.io/cdalvaro/saltstack-master:latest - extra_build_args: '--build-arg VCS_REF=${CIRCLE_TAG:-${CIRCLE_SHA1}} --build-arg BUILD_DATE="$(date +"%Y-%m-%d %H:%M:%S%:z")"' - no_output_timeout: 45m - - docker-save: - registry: docker.io,quay.io - image: cdalvaro/saltstack-master - tag: ${CIRCLE_TAG:-latest} - - test: - executor: docker/machine - steps: - - checkout - - docker-load - - run: - name: Launch docker container - command: docker run -it --rm -d --name salt_master cdalvaro/saltstack-master:${CIRCLE_TAG:-latest} - - run: - name: Container info - command: docker container ls - - run: - name: Wait for salt-master bootup - command: sleep 60 - - run: - name: Test image bootup - command: docker exec -it salt_master /usr/local/sbin/healthcheck - -workflows: - build-and-test: - jobs: - - build: - filters: - tags: - only: /^[0-9._]+$/ - - test: - requires: - - build - filters: - tags: - only: /^[0-9._]+$/ diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..e91bf40 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1 @@ +github: cdalvaro \ No newline at end of file diff --git a/.github/stale.yml b/.github/stale.yml new file mode 100644 index 0000000..480589d --- /dev/null +++ b/.github/stale.yml @@ -0,0 +1,18 @@ +# Number of days of inactivity before an issue becomes stale +daysUntilStale: 60 +# Number of days of inactivity before a stale issue is closed +daysUntilClose: 7 +# Issues with these labels will never be considered stale +exemptLabels: + - pinned + - security + - keep-alive +# Label to use when marking an issue as stale +staleLabel: stale +# Comment to post when marking an issue as stale. Set to `false` to disable +markComment: > + This issue has been automatically marked as stale because it has not had + recent activity. It will be closed if no further activity occurs. Thank you + for your contributions. +# Comment to post when closing a stale issue. Set to `false` to disable +closeComment: false diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml new file mode 100644 index 0000000..2d8496c --- /dev/null +++ b/.github/workflows/build-and-test.yml @@ -0,0 +1,79 @@ +name: Build and test + +on: + pull_request: + branches: + - master + +env: + REGISTRY: docker.io + IMAGE_NAME: cdalvaro/saltstack-master + IMAGE_TAG: ci + GITHUB_REF_NAME: ${{ github.event.release.tag_name }} + +jobs: + build: + name: Build Docker image + runs-on: ubuntu-latest + timeout-minutes: 45 + steps: + - name: Set env variables + run: | + echo ::set-env name=CACHE_FROM::"${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest" + echo ::set-env name=DOCKER_IMAGE::"${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}" + + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Cache lastest image + run: docker pull ${CACHE_FROM} + + - name: Build Docker image + run: | + docker build \ + --build-arg VCS_REF=${GITHUB_REF_NAME:-${GITHUB_SHA}} \ + --build-arg BUILD_DATE="$(date +"%Y-%m-%d %H:%M:%S%:z")" \ + --cache-from ${CACHE_FROM} \ + --tag ${DOCKER_IMAGE} . + + - name: Save docker image + run: | + mkdir -p docker/ + docker save -o docker/docker-image.tar ${DOCKER_IMAGE} + + - name: Upload image for test job + uses: actions/upload-artifact@v2 + with: + name: docker-image + path: docker/docker-image.tar + + test: + name: Test Docker image + needs: build + runs-on: ubuntu-latest + env: + CONTAINER_NAME: salt_master_ci + steps: + - name: Download docker image from build job + uses: actions/download-artifact@v2 + with: + name: docker-image + path: docker/ + + - name: Load docker image from build job + run: docker load -i docker/docker-image.tar + + - name: Launch docker container + run: docker run --rm -d --name "${CONTAINER_NAME}" "${IMAGE_NAME}:${IMAGE_TAG}" + + - name: Show container info + run: docker container ls + + - name: Wait for salt-master bootup + run: sleep 60 + + - name: Show salt versions + run: docker exec "${CONTAINER_NAME}" salt --versions + + - name: Test image calling healthcheck + run: docker exec "${CONTAINER_NAME}" /usr/local/sbin/healthcheck