@@ -35,22 +35,25 @@ jobs:
35
35
- arm-linux
36
36
- aarch64-linux
37
37
- jruby
38
- docker-platform :
39
- - linux/ amd64
40
- - linux/ arm64
38
+ docker-platform-cpu :
39
+ - amd64
40
+ - arm64
41
41
42
42
runs-on : ubuntu-latest
43
43
env :
44
44
PLATFORM : ${{ matrix.platform }}
45
+ DOCKER_BUILD_PLATFORM : linux/${{ matrix.docker-platform-cpu }}
45
46
steps :
46
47
- uses : actions/checkout@v2
47
48
48
49
- name : Cache Docker layers
49
- uses : actions/cache@v2
50
+ uses : actions/cache@v3
50
51
with :
51
52
path : tmp/build-cache
52
- key : ${{ runner.os }}-${{ matrix.platform }}-buildx-${{ github.sha }}
53
+ key : ${{ runner.os }}-${{ matrix.platform }}-${{ matrix.docker-platform-cpu }}-buildx-${{ github.sha }}
54
+ # TODO: remove last key
53
55
restore-keys : |
56
+ ${{ runner.os }}-${{ matrix.platform }}-${{ matrix.docker-platform-cpu }}-buildx
54
57
${{ runner.os }}-${{ matrix.platform }}-buildx
55
58
56
59
- uses : ruby/setup-ruby@v1
62
65
uses : docker/setup-qemu-action@v2
63
66
64
67
- name : Build docker image
68
+ id : buildx
65
69
run : |
66
70
docker buildx create --driver docker-container --use
67
- bundle exec rake build:${PLATFORM} DOCKER_BUILD_PLATFORM="${{ matrix.docker-platform }}" RCD_DOCKER_BUILD="docker buildx build --platform=${{ matrix.docker-platform }} --cache-from=type=local,src=tmp/build-cache --cache-to=type=local,dest=tmp/build-cache-new --load"
71
+ extra_tag="rcd-${PLATFORM}-${DOCKER_BUILD_PLATFORM}-${{ github.sha }}"
72
+ docker_build="docker buildx build --platform=$DOCKER_BUILD_PLATFORM --cache-from=type=local,src=tmp/build-cache --cache-to=type=local,dest=tmp/build-cache-new --load -t $extra_tag"
73
+ bundle exec rake build:${PLATFORM} RCD_DOCKER_BUILD="$docker_build"
74
+
75
+ # Save the image if the commit message contains the docker platform name (e.g. "[linux/arm64] ...")
76
+ if [[ "${{ github.event.head_commit.message }}" == *"[$DOCKER_BUILD_PLATFORM]"* ]]; then
77
+ echo "::info::Saving docker image $extra_tag"
78
+ docker save -o "tmp/${extra_tag}.tar" $extra_tag
79
+ echo "image-tarball: tmp/${extra_tag}.tar" >> $GITHUB_OUTPUT
80
+ fi
81
+
82
+ - name : Upload Docker image tarball
83
+ if : ${{ steps.buildx.outputs.image-tarball != '' }}
84
+ uses : actions/upload-artifact@v3
85
+ with :
86
+ path : ${{ steps.buildx.outputs.image-tarball }}
87
+ retention-days : 1
68
88
69
89
- name : Move build cache and remove outdated layers
70
90
run : |
83
103
- name : Upload binary gem
84
104
uses : actions/upload-artifact@v2
85
105
with :
86
- name : gem-${{ matrix.platform }}
106
+ name : gem-${{ matrix.platform }}-${{ matrix.docker-platform-cpu }}
87
107
path : test/rcd_test/pkg/*-*-*.gem
88
108
89
109
- if : matrix.platform == 'jruby'
@@ -109,11 +129,11 @@ jobs:
109
129
name : Upload static binary gem
110
130
uses : actions/upload-artifact@v2
111
131
with :
112
- name : gem-${{ matrix.platform }}-static
132
+ name : gem-${{ matrix.platform }}-${{ matrix.docker-platform-cpu }}- static
113
133
path : test/rcd_test/pkg/*-*-*.gem
114
134
115
135
job_test_native :
116
- name : Test (${{matrix.ruby}}, ${{matrix.platform}})
136
+ name : Test (${{matrix.ruby}}, ${{matrix.platform}}, ${{ matrix.docker-platform-cpu }} )
117
137
needs : docker_build
118
138
strategy :
119
139
fail-fast : false
@@ -155,11 +175,11 @@ jobs:
155
175
with :
156
176
ruby-version : ${{ matrix.ruby }}
157
177
- run : ruby --version
158
- - name : Download gem-${{matrix.platform}}
178
+ - name : Download gem-${{ matrix.platform }}-${{ matrix.docker-platform-cpu }}
159
179
uses : actions/download-artifact@v2
160
180
with :
161
- name : gem-${{ matrix.platform }}
162
- - name : Install gem-${{matrix.platform}}
181
+ name : gem-${{ matrix.platform }}-${{ matrix.docker-platform-cpu }}
182
+ - name : Install gem-${{ matrix.platform }}-${{ matrix.docker-platform-cpu }}
163
183
run : gem install --local *.gem --verbose
164
184
- name : Run tests
165
185
run : |
@@ -199,11 +219,11 @@ jobs:
199
219
with :
200
220
ruby-version : ${{ matrix.ruby }}
201
221
- run : ruby --version
202
- - name : Download gem-${{matrix.platform}}-static
222
+ - name : Download gem-${{ matrix.platform }}-${{ matrix.docker-platform-cpu }}-static
203
223
uses : actions/download-artifact@v2
204
224
with :
205
- name : gem-${{ matrix.platform }}-static
206
- - name : Install gem-${{matrix.platform}}-static
225
+ name : gem-${{ matrix.platform }}-${{ matrix.docker-platform-cpu }}- static
226
+ - name : Install gem-${{ matrix.platform }}-${{ matrix.docker-platform-cpu }}-static
207
227
run : gem install --local *.gem --verbose
208
228
- name : Run tests
209
229
run : |
@@ -237,12 +257,13 @@ jobs:
237
257
runs-on : ubuntu-latest
238
258
steps :
239
259
- uses : actions/checkout@v2
240
- - name : Download gem-${{matrix.platform}}
260
+ - name : Download gem-${{ matrix.platform }}-${{ matrix.docker-platform-cpu }}
241
261
uses : actions/download-artifact@v2
242
262
with :
243
- name : gem-${{ matrix.platform }}
263
+ name : gem-${{ matrix.platform }}-${{ matrix.docker-platform-cpu }}
244
264
- name : Build image and Run tests
245
265
run : |
266
+ docker buildx create --driver docker-container --use
246
267
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
247
- docker build --rm --build-arg from_image=${{matrix.from_image}} -t ruby-test -f test/env/Dockerfile.${{matrix.dockerfile}} .
248
- docker run --rm -t --network=host -v `pwd`:/build ruby-test
268
+ docker buildx build --platform=$DOCKER_BUILD_PLATFORM --rm --build-arg from_image=${{matrix.from_image}} -t ruby-test -f test/env/Dockerfile.${{matrix.dockerfile}} .
269
+ docker run --platform=$DOCKER_BUILD_PLATFORM -- rm -t --network=host -v `pwd`:/build ruby-test
0 commit comments