@@ -2,6 +2,10 @@ name: checks
2
2
on : [pull_request, workflow_dispatch]
3
3
4
4
env :
5
+ ACT_OWNER : ${{ github.repository_owner }}
6
+ ACT_REPOSITORY : ${{ github.repository }}
7
+ CACHED_DOCKER_IMAGES : ' "node:12-buster" "node:12-buster-slim" "ubuntu:18.04" "ubuntu:latest" "alpine:3.10" "tonistiigi/binfmt:latest"'
8
+ CACHED_DOCKER_IMAGES_KEY : docker-images-0
5
9
GO_VERSION : 1.17
6
10
7
11
jobs :
@@ -61,14 +65,49 @@ jobs:
61
65
files : coverage.txt
62
66
fail_ci_if_error : true # optional (default = false)
63
67
68
+ dump_images :
69
+ runs-on : ubuntu-latest
70
+ continue-on-error : true
71
+ steps :
72
+ - uses : actions/cache@v2
73
+ id : image_cache
74
+ with :
75
+ key : ${{ env.CACHED_DOCKER_IMAGES_KEY }}
76
+ path : |
77
+ registry
78
+ docker-registry
79
+ - name : Pull and export images
80
+ if : steps.image_cache.outputs.cache-hit != 'true'
81
+ run : |
82
+ docker pull registry:2
83
+ docker image save -o registry registry:2
84
+ mkdir -p docker-registry
85
+ docker run -d -p 5000:5000 --name registry -v $PWD/docker-registry:/var/lib/registry registry:2
86
+ npx wait-on tcp:5000
87
+ for image in ${{ env.CACHED_DOCKER_IMAGES }}
88
+ do
89
+ bash -c 'docker pull "'"$image"'" && docker tag "'"$image"'" "localhost:5000/'"$image"'" && docker push "localhost:5000/'"$image"'"'&
90
+ done
91
+ wait
92
+
64
93
test-macos :
94
+ needs : dump_images
65
95
name : test-macos
66
96
runs-on : macos-latest
67
97
continue-on-error : true # Don't let macos test fail whole workflow
68
98
env :
69
99
ISO_PATH : ~/.docker/machine/cache/boot2docker.iso
70
100
steps :
71
101
- uses : actions/checkout@v2
102
+ - name : Restore Docker Image Cache
103
+ uses : actions/cache@v2
104
+ id : image_cache
105
+ continue-on-error : true
106
+ with :
107
+ key : ${{ env.CACHED_DOCKER_IMAGES_KEY }}
108
+ path : |
109
+ registry
110
+ docker-registry
72
111
- uses : actions/setup-go@v1
73
112
with :
74
113
go-version : ${{ env.GO_VERSION }}
@@ -100,9 +139,23 @@ jobs:
100
139
echo "DOCKER_HOST=$DOCKER_HOST" | tee -a $GITHUB_ENV
101
140
echo "DOCKER_CERT_PATH=$DOCKER_CERT_PATH" | tee -a $GITHUB_ENV
102
141
echo "DOCKER_MACHINE_NAME=$DOCKER_MACHINE_NAME" | tee -a $GITHUB_ENV
103
- printf " 🛠️ Install Qemu for running containers with different architecture 🛠️ \n\n"
104
- docker run --rm --privileged tonistiigi/binfmt --install all
105
142
printf " 🛠️ Finished installing Docker 🛠️ \n\n"
143
+ - name : Import images
144
+ if : steps.image_cache.outputs.cache-hit == 'true'
145
+ continue-on-error : true
146
+ run : |
147
+ echo load registry
148
+ docker image load -i registry
149
+ echo Setup local registry
150
+ docker run -d -p 5000:5000 --name registry -v $PWD/docker-registry:/var/lib/registry registry:2
151
+ echo pulling images from cache
152
+ for image in ${{ env.CACHED_DOCKER_IMAGES }}
153
+ do
154
+ 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"'"'&
155
+ done
156
+ wait
157
+ - name : 🛠️ Install Qemu for running containers with different architecture 🛠️
158
+ run : docker run --rm --privileged tonistiigi/binfmt:latest --install all
106
159
- run : go test -v -timeout 30m -cover ./...
107
160
env :
108
161
CGO_ENABLED : 0
0 commit comments