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 : ${{ matrix.image }} (${{ matrix.sub }})
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
+ # always use the main branch, since we need it for the base image
158
+ - name : Build Docker image
159
+ id : build-docker-image
160
+ timeout-minutes : 60
161
+ run : cargo xtask build-docker-image -v --tag main "${IMAGE}.${SUB}"
162
+ env :
163
+ IMAGE : ${{ matrix.image }}
164
+ SUB : ${{ matrix.sub }}
165
+ LABELS : ${{ steps.docker-meta.outputs.labels }}
166
+ LATEST : ${{ needs.check.outputs.is-latest || 'false' }}
167
+ shell : bash
168
+
169
+ - name : Save Docker Image
170
+ id : save-docker-image
171
+ run : docker save "ghcr.io/cross-rs/${IMAGE}:main-${SUB}" -o "${IMAGE}-main-${SUB}.tar"
172
+ env :
173
+ IMAGE : ${{ matrix.image }}
174
+ SUB : ${{ matrix.sub }}
175
+
176
+ - uses : actions/upload-artifact@v2
177
+ with :
178
+ name : ${{ matrix.image }}-${{ matrix.sub }}-image-tarball
179
+ path : ${{ matrix.image }}-main-${{ matrix.sub }}.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,33 @@ 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
+
275
+ - name : Load Base Image
276
+ id : load-docker-image
277
+ if : steps.prepare-meta.outputs.has-image
278
+ run : docker load --input "base-main-${BASE}.tar"
279
+ env :
280
+ SUB : ${{ matrix.sub }}
281
+
155
282
- name : Build Docker image
156
283
id : build-docker-image
157
284
if : steps.prepare-meta.outputs.has-image
@@ -163,6 +290,7 @@ jobs:
163
290
LABELS : ${{ steps.docker-meta.outputs.labels }}
164
291
LATEST : ${{ needs.check.outputs.is-latest || 'false' }}
165
292
shell : bash
293
+
166
294
- name : Set Docker image for test
167
295
if : steps.prepare-meta.outputs.has-image
168
296
run : |
@@ -172,6 +300,7 @@ jobs:
172
300
TARGET : ${{ matrix.target }}
173
301
IMAGE : ${{ steps.build-docker-image.outputs.image }}
174
302
shell : bash
303
+
175
304
- name : Test Image
176
305
if : steps.prepare-meta.outputs.has-image && steps.prepare-meta.outputs.test-variant == 'default'
177
306
run : ./ci/test.sh
@@ -184,6 +313,7 @@ jobs:
184
313
RUN : ${{ matrix.run }}
185
314
RUNNERS : ${{ matrix.runners }}
186
315
shell : bash
316
+
187
317
- uses : ./.github/actions/cargo-install-upload-artifacts
188
318
if : matrix.deploy
189
319
with :
@@ -209,6 +339,7 @@ jobs:
209
339
registry : ghcr.io
210
340
username : ${{ github.actor }}
211
341
password : ${{ secrets.GITHUB_TOKEN }}
342
+
212
343
- name : Push image to GitHub Container Registry
213
344
if : >
214
345
steps.prepare-meta.outputs.has-image && (
@@ -274,15 +405,18 @@ jobs:
274
405
uses : ./.github/actions/cargo-llvm-cov
275
406
with :
276
407
name : integration-bisect
408
+
277
409
- name : Set up QEMU
278
410
uses : docker/setup-qemu-action@v2
279
411
with :
280
412
platforms : arm64
413
+
281
414
- name : Set up docker buildx
282
415
uses : docker/setup-buildx-action@v2
283
416
id : buildx
284
417
with :
285
418
install : true
419
+
286
420
- name : Run Foreign toolchain test
287
421
run : ./ci/test-foreign-toolchain.sh
288
422
shell : bash
@@ -320,7 +454,6 @@ jobs:
320
454
coverage-artifact : ${{ steps.cov.outputs.artifact-name }}
321
455
steps :
322
456
- uses : actions/checkout@v3
323
-
324
457
- uses : ./.github/actions/setup-rust
325
458
326
459
- name : Install Podman
@@ -347,7 +480,7 @@ jobs:
347
480
shell : bash
348
481
349
482
publish :
350
- needs : [build, check, fmt, clippy, cargo-deny]
483
+ needs : [build-base, build , check, fmt, clippy, cargo-deny]
351
484
runs-on : ubuntu-latest
352
485
steps :
353
486
- uses : actions/checkout@v3
@@ -358,7 +491,7 @@ jobs:
358
491
github-token : ${{ secrets.GITHUB_TOKEN }}
359
492
360
493
conclusion :
361
- needs : [shellcheck, fmt, clippy, test, generate-matrix, build, publish, check, remote, bisect, docker-in-docker, foreign, podman]
494
+ needs : [shellcheck, fmt, clippy, test, generate-matrix, build-base, build , publish, check, remote, bisect, docker-in-docker, foreign, podman]
362
495
if : always()
363
496
runs-on : ubuntu-latest
364
497
steps :
0 commit comments