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,17 +253,48 @@ 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
159
286
timeout-minutes : 120
160
- run : cargo xtask build-docker-image -v "${TARGET}${SUB:+.$SUB}"
287
+ # TODO(ahuszagh) Remove this multiline and docker images
288
+ run : |
289
+ docker images
290
+ cargo xtask build-docker-image -v "${TARGET}${SUB:+.$SUB}"
161
291
env :
162
292
TARGET : ${{ matrix.target }}
163
293
SUB : ${{ matrix.sub }}
164
294
LABELS : ${{ steps.docker-meta.outputs.labels }}
165
295
LATEST : ${{ needs.check.outputs.is-latest || 'false' }}
166
296
shell : bash
297
+
167
298
- name : Set Docker image for test
168
299
if : steps.prepare-meta.outputs.has-image
169
300
run : |
@@ -173,6 +304,7 @@ jobs:
173
304
TARGET : ${{ matrix.target }}
174
305
IMAGE : ${{ steps.build-docker-image.outputs.image }}
175
306
shell : bash
307
+
176
308
- name : Test Image
177
309
if : steps.prepare-meta.outputs.has-image && steps.prepare-meta.outputs.test-variant == 'default'
178
310
run : ./ci/test.sh
@@ -185,6 +317,7 @@ jobs:
185
317
RUN : ${{ matrix.run }}
186
318
RUNNERS : ${{ matrix.runners }}
187
319
shell : bash
320
+
188
321
- uses : ./.github/actions/cargo-install-upload-artifacts
189
322
if : matrix.deploy
190
323
with :
@@ -210,6 +343,7 @@ jobs:
210
343
registry : ghcr.io
211
344
username : ${{ github.actor }}
212
345
password : ${{ secrets.GITHUB_TOKEN }}
346
+
213
347
- name : Push image to GitHub Container Registry
214
348
if : >
215
349
steps.prepare-meta.outputs.has-image && (
@@ -275,15 +409,18 @@ jobs:
275
409
uses : ./.github/actions/cargo-llvm-cov
276
410
with :
277
411
name : integration-bisect
412
+
278
413
- name : Set up QEMU
279
414
uses : docker/setup-qemu-action@v2
280
415
with :
281
416
platforms : arm64
417
+
282
418
- name : Set up docker buildx
283
419
uses : docker/setup-buildx-action@v2
284
420
id : buildx
285
421
with :
286
422
install : true
423
+
287
424
- name : Run Foreign toolchain test
288
425
run : ./ci/test-foreign-toolchain.sh
289
426
shell : bash
@@ -321,7 +458,6 @@ jobs:
321
458
coverage-artifact : ${{ steps.cov.outputs.artifact-name }}
322
459
steps :
323
460
- uses : actions/checkout@v3
324
-
325
461
- uses : ./.github/actions/setup-rust
326
462
327
463
- name : Install Podman
@@ -348,7 +484,7 @@ jobs:
348
484
shell : bash
349
485
350
486
publish :
351
- needs : [build, check, fmt, clippy, cargo-deny]
487
+ needs : [build-base, build , check, fmt, clippy, cargo-deny]
352
488
runs-on : ubuntu-latest
353
489
steps :
354
490
- uses : actions/checkout@v3
@@ -359,7 +495,7 @@ jobs:
359
495
github-token : ${{ secrets.GITHUB_TOKEN }}
360
496
361
497
conclusion :
362
- needs : [shellcheck, fmt, clippy, test, generate-matrix, build, publish, check, remote, bisect, docker-in-docker, foreign, podman]
498
+ needs : [shellcheck, fmt, clippy, test, generate-matrix, build-base, build , publish, check, remote, bisect, docker-in-docker, foreign, podman]
363
499
if : always()
364
500
runs-on : ubuntu-latest
365
501
steps :
0 commit comments