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
@@ -180,6 +199,9 @@ jobs:
180
199
181
200
build_std :
182
201
runs-on : ubuntu-latest
202
+ needs :
203
+ - channel
204
+ if : needs.channel.outputs.CHANNEL == 'master'
183
205
steps :
184
206
- uses : actions/checkout@v3
185
207
- run : rustup update nightly && rustup default nightly
@@ -190,6 +212,8 @@ jobs:
190
212
CARGO_RUN_BUILD_STD_TESTS : 1
191
213
docs :
192
214
runs-on : ubuntu-latest
215
+ needs :
216
+ - channel
193
217
steps :
194
218
- uses : actions/checkout@v3
195
219
- run : rustup update nightly && rustup default nightly
@@ -211,22 +235,36 @@ jobs:
211
235
- run : cd src/doc && mdbook build --dest-dir ../../target/doc
212
236
- name : Run linkchecker.sh
213
237
run : |
238
+ BRANCH=${{ needs.channel.outputs.CHANNEL }}
214
239
cd target
215
- curl -sSLO https://raw.githubusercontent.com/rust-lang/rust/master /src/tools/linkchecker/linkcheck.sh
240
+ curl -sSLO " https://raw.githubusercontent.com/rust-lang/rust/$BRANCH /src/tools/linkchecker/linkcheck.sh"
216
241
sh linkcheck.sh --all --path ../src/doc cargo
217
242
243
+ # Jobs that may be skipped if they aren't going to merge into master (nightly).
244
+ #
245
+ # This is needed because GitHub Actions treats success() as false if a job is
246
+ # skipped, and the bors success/failure jobs below need to ignore skipped jobs.
247
+ z-nightly-jobs :
248
+ needs :
249
+ - channel
250
+ - build_std
251
+ if : " (needs.channel.outputs.CHANNEL != 'master' && !failure()) || success()"
252
+ runs-on : ubuntu-latest
253
+ steps :
254
+ - run : exit 0
255
+
218
256
success :
219
257
permissions :
220
258
contents : none
221
259
name : bors build finished
222
260
needs :
223
- - build_std
224
261
- docs
225
262
- lockfile
226
263
- resolver
227
264
- rustfmt
228
265
- test
229
266
- test_gitoxide
267
+ - z-nightly-jobs
230
268
runs-on : ubuntu-latest
231
269
if : " success() && github.event_name == 'push' && github.ref == 'refs/heads/auto-cargo'"
232
270
steps :
@@ -236,13 +274,13 @@ jobs:
236
274
contents : none
237
275
name : bors build finished
238
276
needs :
239
- - build_std
240
277
- docs
241
278
- lockfile
242
279
- resolver
243
280
- rustfmt
244
281
- test
245
282
- test_gitoxide
283
+ - z-nightly-jobs
246
284
runs-on : ubuntu-latest
247
285
if : " !success() && github.event_name == 'push' && github.ref == 'refs/heads/auto-cargo'"
248
286
steps :
0 commit comments