16
16
CARGO_REGISTRIES_CRATES_IO_PROTOCOL : sparse
17
17
18
18
jobs :
19
+ # Determine which channel will be merged into.
20
+ channel :
21
+ runs-on : ubuntu-latest
22
+ outputs :
23
+ CHANNEL : ${{ steps.channel.outputs.CHANNEL }}
24
+ env :
25
+ BASE_SHA : ${{ github.event.pull_request.base.sha }}
26
+ steps :
27
+ - uses : actions/checkout@v3
28
+ with :
29
+ fetch-depth : 0 # fetch all branches
30
+ - id : channel
31
+ run : ci/which-channel.sh
32
+
19
33
# Check Code style quickly by running `rustfmt` over all code
20
34
rustfmt :
21
35
runs-on : ubuntu-latest
63
77
- run : rustup update stable && rustup default stable
64
78
- run : ci/validate-version-bump.sh
65
79
80
+ # Generate strategy matrix for different platforms and channels
81
+ # (see ci/matrix.json)
82
+ matrix :
83
+ runs-on : ubuntu-latest
84
+ needs :
85
+ - channel
86
+ outputs :
87
+ matrix : ${{ steps.matrix.outputs.matrix }}
88
+ steps :
89
+ - uses : actions/checkout@v3
90
+ - name : Generate strategy matrix
91
+ id : matrix
92
+ run : |
93
+ CHANNEL=${{ needs.channel.outputs.CHANNEL }}
94
+
95
+ # This reads ci/matrix.json and then filters the environment we want to
96
+ # build on, based on the channel this PR want to merge into.
97
+ #
98
+ # * For stable, we build only on stable toolchain.
99
+ # * For beta, we build on stable and beta.
100
+ # * For nightly, we build on stable, beta, and nightly.
101
+ MATRIX=$(
102
+ jq --arg C "$CHANNEL" 'map (. |
103
+ if ($C == "beta") then select(.rust | startswith("nightly") | not)
104
+ elif ($C == "stable") then select(.rust | startswith("stable"))
105
+ else . end)' ci/matrix.json
106
+ )
107
+ echo "$MATRIX"
108
+
109
+ # Outputs as Job's outputs for other jobs to reuse.
110
+ echo "MATRIX={\"include\":$(echo $MATRIX)}" >> "$GITHUB_OUTPUT"
111
+
66
112
test :
67
113
runs-on : ${{ matrix.os }}
114
+ needs :
115
+ - matrix
68
116
env :
69
117
CARGO_PROFILE_DEV_DEBUG : 1
70
118
CARGO_PROFILE_TEST_DEBUG : 1
@@ -73,36 +121,7 @@ jobs:
73
121
# Deny warnings on CI to avoid warnings getting into the codebase.
74
122
RUSTFLAGS : -D warnings
75
123
strategy :
76
- matrix :
77
- include :
78
- - name : Linux x86_64 stable
79
- os : ubuntu-latest
80
- rust : stable
81
- other : i686-unknown-linux-gnu
82
- - name : Linux x86_64 beta
83
- os : ubuntu-latest
84
- rust : beta
85
- other : i686-unknown-linux-gnu
86
- - name : Linux x86_64 nightly
87
- os : ubuntu-latest
88
- rust : nightly
89
- other : i686-unknown-linux-gnu
90
- - name : macOS x86_64 stable
91
- os : macos-latest
92
- rust : stable
93
- other : x86_64-apple-ios
94
- - name : macOS x86_64 nightly
95
- os : macos-latest
96
- rust : nightly
97
- other : x86_64-apple-ios
98
- - name : Windows x86_64 MSVC stable
99
- os : windows-latest
100
- rust : stable-msvc
101
- other : i686-pc-windows-msvc
102
- - name : Windows x86_64 gnu nightly # runs out of space while trying to link the test suite
103
- os : windows-latest
104
- rust : nightly-gnu
105
- other : i686-pc-windows-gnu
124
+ matrix : ${{ fromJSON(needs.matrix.outputs.MATRIX) }}
106
125
name : Tests ${{ matrix.name }}
107
126
steps :
108
127
- uses : actions/checkout@v3
@@ -184,6 +203,9 @@ jobs:
184
203
185
204
build_std :
186
205
runs-on : ubuntu-latest
206
+ needs :
207
+ - channel
208
+ if : needs.channel.outputs.CHANNEL == 'master'
187
209
steps :
188
210
- uses : actions/checkout@v3
189
211
- run : rustup update nightly && rustup default nightly
@@ -194,6 +216,8 @@ jobs:
194
216
CARGO_RUN_BUILD_STD_TESTS : 1
195
217
docs :
196
218
runs-on : ubuntu-latest
219
+ needs :
220
+ - channel
197
221
steps :
198
222
- uses : actions/checkout@v3
199
223
- run : rustup update nightly && rustup default nightly
@@ -215,22 +239,36 @@ jobs:
215
239
- run : cd src/doc && mdbook build --dest-dir ../../target/doc
216
240
- name : Run linkchecker.sh
217
241
run : |
242
+ BRANCH=${{ needs.channel.outputs.CHANNEL }}
218
243
cd target
219
- curl -sSLO https://raw.githubusercontent.com/rust-lang/rust/master /src/tools/linkchecker/linkcheck.sh
244
+ curl -sSLO " https://raw.githubusercontent.com/rust-lang/rust/$BRANCH /src/tools/linkchecker/linkcheck.sh"
220
245
sh linkcheck.sh --all --path ../src/doc cargo
221
246
247
+ # Jobs that may be skipped if they aren't going to merge into master (nightly).
248
+ #
249
+ # This is needed because GitHub Actions treats success() as false if a job is
250
+ # skipped, and the bors success/failure jobs below need to ignore skipped jobs.
251
+ z-nightly-jobs :
252
+ needs :
253
+ - channel
254
+ - build_std
255
+ if : " (needs.channel.outputs.CHANNEL != 'master' && !failure()) || success()"
256
+ runs-on : ubuntu-latest
257
+ steps :
258
+ - run : exit 0
259
+
222
260
success :
223
261
permissions :
224
262
contents : none
225
263
name : bors build finished
226
264
needs :
227
- - build_std
228
265
- docs
229
266
- lockfile
230
267
- resolver
231
268
- rustfmt
232
269
- test
233
270
- test_gitoxide
271
+ - z-nightly-jobs
234
272
runs-on : ubuntu-latest
235
273
if : " success() && github.event_name == 'push' && github.ref == 'refs/heads/auto-cargo'"
236
274
steps :
@@ -240,13 +278,13 @@ jobs:
240
278
contents : none
241
279
name : bors build finished
242
280
needs :
243
- - build_std
244
281
- docs
245
282
- lockfile
246
283
- resolver
247
284
- rustfmt
248
285
- test
249
286
- test_gitoxide
287
+ - z-nightly-jobs
250
288
runs-on : ubuntu-latest
251
289
if : " !success() && github.event_name == 'push' && github.ref == 'refs/heads/auto-cargo'"
252
290
steps :
0 commit comments