75
75
- name : Run unit tests
76
76
run : cargo test --locked --all-targets --workspace --all-features
77
77
timeout-minutes : 10
78
+
78
79
check :
79
80
runs-on : ubuntu-latest
80
81
outputs :
84
85
- uses : ./.github/actions/setup-rust
85
86
- run : cargo xtask ci-job check
86
87
id : check
88
+
87
89
generate-matrix :
88
90
runs-on : ubuntu-latest
89
91
outputs :
@@ -99,10 +101,109 @@ jobs:
99
101
COMMIT_MESSAGE : ${{ github.event.head_commit.message }}
100
102
COMMIT_AUTHOR : ${{ github.event.head_commit.author.username }}
101
103
104
+ build-base :
105
+ name : ${{ matrix.image }} (${{ matrix.sub }})
106
+ runs-on : ubuntu-latest
107
+ needs : [shellcheck, test, check]
108
+ if : github.event_name == 'push'
109
+ strategy :
110
+ fail-fast : false
111
+ matrix :
112
+ image :
113
+ - base
114
+ sub :
115
+ - ubuntu
116
+ - centos
117
+ - emscripten
118
+ outputs :
119
+ coverage-artifact : ${{ steps.cov.outputs.artifact-name }}
120
+ steps :
121
+ - uses : actions/checkout@v3
122
+ - uses : ./.github/actions/setup-rust
123
+
124
+ - name : Set up Docker Buildx
125
+ if : runner.os == 'Linux'
126
+ uses : docker/setup-buildx-action@v1
127
+
128
+ - name : Build xtask
129
+ run : cargo build -p xtask
130
+
131
+ - name : Prepare Meta
132
+ id : prepare-meta
133
+ timeout-minutes : 60
134
+ run : cargo xtask ci-job prepare-meta "${IMAGE}.${SUB}"
135
+ env :
136
+ IMAGE : ${{ matrix.image }}
137
+ SUB : ${{ matrix.sub }}
138
+ shell : bash
139
+
140
+ - name : LLVM instrument coverage
141
+ uses : ./.github/actions/cargo-llvm-cov
142
+ with :
143
+ name : cross-${{matrix.image}}-${{matrix.sub}}
144
+
145
+ - name : Install cross
146
+ if : matrix.deploy
147
+ run : cargo install --path . --force --debug
148
+
149
+ - name : Docker Meta
150
+ id : docker-meta
151
+ uses : docker/metadata-action@v4
152
+ with :
153
+ images : |
154
+ name=${{ steps.prepare-meta.outputs.image }}
155
+ labels : |
156
+ ${{ fromJSON(steps.prepare-meta.outputs.labels) }}
157
+
158
+ # always use the main branch, since we need it for the base image
159
+ - name : Build Docker image
160
+ id : build-docker-image
161
+ timeout-minutes : 60
162
+ run : cargo xtask build-docker-image -v --tag main "${IMAGE}.${SUB}"
163
+ env :
164
+ IMAGE : ${{ matrix.image }}
165
+ SUB : ${{ matrix.sub }}
166
+ LABELS : ${{ steps.docker-meta.outputs.labels }}
167
+ LATEST : ${{ needs.check.outputs.is-latest || 'false' }}
168
+ shell : bash
169
+
170
+ - name : Save Docker Image
171
+ id : save-docker-image
172
+ run : docker save "ghcr.io/cross-rs/${IMAGE}:main-${SUB}" -o "${IMAGE}-main-${SUB}.tar"
173
+ env :
174
+ IMAGE : ${{ matrix.image }}
175
+ SUB : ${{ matrix.sub }}
176
+
177
+ - uses : actions/upload-artifact@v2
178
+ with :
179
+ name : ${{ matrix.image }}-${{ matrix.sub }}-image-tarball
180
+ path : ${{ matrix.image }}-main-${{ matrix.sub }}.tar
181
+
182
+ - name : Login to GitHub Container Registry
183
+ uses : docker/login-action@v1
184
+ with :
185
+ registry : ghcr.io
186
+ username : ${{ github.actor }}
187
+ password : ${{ secrets.GITHUB_TOKEN }}
188
+
189
+ - name : Push image to GitHub Container Registry
190
+ if : >
191
+ (
192
+ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) ||
193
+ startsWith(github.ref, 'refs/tags/v')
194
+ )
195
+ run : cargo xtask build-docker-image -v "${IMAGE}.${SUB}"
196
+ env :
197
+ IMAGE : ${{ matrix.image }}
198
+ SUB : ${{ matrix.sub }}
199
+ LABELS : ${{ steps.docker-meta.outputs.labels }}
200
+ LATEST : ${{ needs.check.outputs.is-latest || 'false' }}
201
+ shell : bash
202
+
102
203
build :
103
204
name : target (${{ matrix.pretty }},${{ matrix.os }})
104
205
runs-on : ${{ matrix.os }}
105
- needs : [shellcheck, test, generate-matrix, check]
206
+ needs : [shellcheck, test, generate-matrix, check, build-base ]
106
207
if : github.event_name == 'push' && needs.generate-matrix.outputs.matrix != '{}' && needs.generate-matrix.outputs.matrix != '[]' && needs.generate-matrix.outputs.matrix != ''
107
208
strategy :
108
209
fail-fast : false
@@ -114,7 +215,6 @@ jobs:
114
215
coverage-artifact : ${{ steps.cov.outputs.artifact-name }}
115
216
steps :
116
217
- uses : actions/checkout@v3
117
-
118
218
- uses : ./.github/actions/setup-rust
119
219
120
220
- name : Set up Docker Buildx
@@ -153,6 +253,33 @@ jobs:
153
253
name=${{ steps.prepare-meta.outputs.image }}
154
254
labels : |
155
255
${{ fromJSON(steps.prepare-meta.outputs.labels) }}
256
+
257
+ - name : Set env Base Image
258
+ if : steps.prepare-meta.outputs.has-image
259
+ run : |
260
+ if [[ "${SUB}" == "centos" ]]; then
261
+ echo "BASE=centos" >> "${GITHUB_ENV}"
262
+ elif [[ "${TARGET}" == *emscripten ]]; then
263
+ echo "BASE=emscripten" >> "${GITHUB_ENV}"
264
+ else
265
+ echo "BASE=ubuntu" >> "${GITHUB_ENV}"
266
+ fi
267
+ env :
268
+ TARGET : ${{ matrix.target }}
269
+ SUB : ${{ matrix.sub }}
270
+
271
+ - uses : actions/download-artifact@v3
272
+ if : steps.prepare-meta.outputs.has-image
273
+ with :
274
+ name : base-${{ env.BASE }}-image-tarball
275
+
276
+ - name : Load Base Image
277
+ id : load-docker-image
278
+ if : steps.prepare-meta.outputs.has-image
279
+ run : docker load --input "base-main-${BASE}.tar"
280
+ env :
281
+ SUB : ${{ matrix.sub }}
282
+
156
283
- name : Build Docker image
157
284
id : build-docker-image
158
285
if : steps.prepare-meta.outputs.has-image
@@ -163,7 +290,9 @@ jobs:
163
290
SUB : ${{ matrix.sub }}
164
291
LABELS : ${{ steps.docker-meta.outputs.labels }}
165
292
LATEST : ${{ needs.check.outputs.is-latest || 'false' }}
293
+ CROSS_CONTAINER_ENGINE_NO_PULL : true
166
294
shell : bash
295
+
167
296
- name : Set Docker image for test
168
297
if : steps.prepare-meta.outputs.has-image
169
298
run : |
@@ -173,6 +302,7 @@ jobs:
173
302
TARGET : ${{ matrix.target }}
174
303
IMAGE : ${{ steps.build-docker-image.outputs.image }}
175
304
shell : bash
305
+
176
306
- name : Test Image
177
307
if : steps.prepare-meta.outputs.has-image && steps.prepare-meta.outputs.test-variant == 'default'
178
308
run : ./ci/test.sh
@@ -185,6 +315,7 @@ jobs:
185
315
RUN : ${{ matrix.run }}
186
316
RUNNERS : ${{ matrix.runners }}
187
317
shell : bash
318
+
188
319
- uses : ./.github/actions/cargo-install-upload-artifacts
189
320
if : matrix.deploy
190
321
with :
@@ -210,6 +341,7 @@ jobs:
210
341
registry : ghcr.io
211
342
username : ${{ github.actor }}
212
343
password : ${{ secrets.GITHUB_TOKEN }}
344
+
213
345
- name : Push image to GitHub Container Registry
214
346
if : >
215
347
steps.prepare-meta.outputs.has-image && (
@@ -275,15 +407,18 @@ jobs:
275
407
uses : ./.github/actions/cargo-llvm-cov
276
408
with :
277
409
name : integration-bisect
410
+
278
411
- name : Set up QEMU
279
412
uses : docker/setup-qemu-action@v2
280
413
with :
281
414
platforms : arm64
415
+
282
416
- name : Set up docker buildx
283
417
uses : docker/setup-buildx-action@v2
284
418
id : buildx
285
419
with :
286
420
install : true
421
+
287
422
- name : Run Foreign toolchain test
288
423
run : ./ci/test-foreign-toolchain.sh
289
424
shell : bash
@@ -321,7 +456,6 @@ jobs:
321
456
coverage-artifact : ${{ steps.cov.outputs.artifact-name }}
322
457
steps :
323
458
- uses : actions/checkout@v3
324
-
325
459
- uses : ./.github/actions/setup-rust
326
460
327
461
- name : Install Podman
@@ -348,7 +482,7 @@ jobs:
348
482
shell : bash
349
483
350
484
publish :
351
- needs : [build, check, fmt, clippy, cargo-deny]
485
+ needs : [build-base, build , check, fmt, clippy, cargo-deny]
352
486
runs-on : ubuntu-latest
353
487
steps :
354
488
- uses : actions/checkout@v3
@@ -359,7 +493,7 @@ jobs:
359
493
github-token : ${{ secrets.GITHUB_TOKEN }}
360
494
361
495
conclusion :
362
- needs : [shellcheck, fmt, clippy, test, generate-matrix, build, publish, check, remote, bisect, docker-in-docker, foreign, podman]
496
+ needs : [shellcheck, fmt, clippy, test, generate-matrix, build-base, build , publish, check, remote, bisect, docker-in-docker, foreign, podman]
363
497
if : always()
364
498
runs-on : ubuntu-latest
365
499
steps :
0 commit comments