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