Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache dockerhub images from linux for macOS #768

Merged
merged 5 commits into from
Aug 31, 2021
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 57 additions & 2 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
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

jobs:
lint:
name: lint
Expand Down Expand Up @@ -58,14 +64,49 @@ 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
env:
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: 1.16
Expand Down Expand Up @@ -97,9 +138,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
Expand Down