diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index cbd5c63..53425f8 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -2,6 +2,10 @@ name: checks on: [pull_request, workflow_dispatch] env: + ACT_OWNER: ${{ github.repository_owner }} + ACT_REPOSITORY: ${{ github.repository }} + CACHED_DOCKER_IMAGES: '"node:12-buster" "node:12-buster-slim" "ubuntu:18.04" "ubuntu:latest" "alpine:3.10" "tonistiigi/binfmt:latest"' + CACHED_DOCKER_IMAGES_KEY: docker-images-0 GO_VERSION: 1.17 jobs: @@ -61,7 +65,33 @@ jobs: files: coverage.txt fail_ci_if_error: true # optional (default = false) + dump_images: + runs-on: ubuntu-latest + continue-on-error: true + steps: + - uses: actions/cache@v2 + id: image_cache + with: + key: ${{ env.CACHED_DOCKER_IMAGES_KEY }} + path: | + registry + docker-registry + - name: Pull and export images + if: steps.image_cache.outputs.cache-hit != 'true' + run: | + docker pull registry:2 + docker image save -o registry registry:2 + mkdir -p docker-registry + docker run -d -p 5000:5000 --name registry -v $PWD/docker-registry:/var/lib/registry registry:2 + npx wait-on tcp:5000 + for image in ${{ env.CACHED_DOCKER_IMAGES }} + do + bash -c 'docker pull "'"$image"'" && docker tag "'"$image"'" "localhost:5000/'"$image"'" && docker push "localhost:5000/'"$image"'"'& + done + wait + test-macos: + needs: dump_images name: test-macos runs-on: macos-latest continue-on-error: true # Don't let macos test fail whole workflow @@ -69,6 +99,15 @@ jobs: ISO_PATH: ~/.docker/machine/cache/boot2docker.iso steps: - uses: actions/checkout@v2 + - name: Restore Docker Image Cache + uses: actions/cache@v2 + id: image_cache + continue-on-error: true + with: + key: ${{ env.CACHED_DOCKER_IMAGES_KEY }} + path: | + registry + docker-registry - uses: actions/setup-go@v1 with: go-version: ${{ env.GO_VERSION }} @@ -100,9 +139,23 @@ jobs: echo "DOCKER_HOST=$DOCKER_HOST" | tee -a $GITHUB_ENV echo "DOCKER_CERT_PATH=$DOCKER_CERT_PATH" | tee -a $GITHUB_ENV echo "DOCKER_MACHINE_NAME=$DOCKER_MACHINE_NAME" | tee -a $GITHUB_ENV - printf " 🛠️ Install Qemu for running containers with different architecture 🛠️ \n\n" - docker run --rm --privileged tonistiigi/binfmt --install all printf " 🛠️ Finished installing Docker 🛠️ \n\n" + - name: Import images + if: steps.image_cache.outputs.cache-hit == 'true' + continue-on-error: true + run: | + echo load registry + docker image load -i registry + echo Setup local registry + docker run -d -p 5000:5000 --name registry -v $PWD/docker-registry:/var/lib/registry registry:2 + echo pulling images from cache + for image in ${{ env.CACHED_DOCKER_IMAGES }} + do + bash -c '(sleep 1 && docker pull "localhost:5000/'"$image"'" || sleep 2 && docker pull "localhost:5000/'"$image"'" || sleep 10 && docker pull "localhost:5000/'"$image"'") && docker tag "localhost:5000/'"$image"'" "'"$image"'"'& + done + wait + - name: 🛠️ Install Qemu for running containers with different architecture 🛠️ + run: docker run --rm --privileged tonistiigi/binfmt:latest --install all - run: go test -v -timeout 30m -cover ./... env: CGO_ENABLED: 0