1616 CARGO_REGISTRIES_CRATES_IO_PROTOCOL : sparse
1717
1818jobs :
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+
1933 # Check Code style quickly by running `rustfmt` over all code
2034 rustfmt :
2135 runs-on : ubuntu-latest
6377 - run : rustup update stable && rustup default stable
6478 - run : ci/validate-version-bump.sh
6579
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+
66112 test :
67113 runs-on : ${{ matrix.os }}
114+ needs :
115+ - matrix
68116 env :
69117 CARGO_PROFILE_DEV_DEBUG : 1
70118 CARGO_PROFILE_TEST_DEBUG : 1
@@ -73,36 +121,7 @@ jobs:
73121 # Deny warnings on CI to avoid warnings getting into the codebase.
74122 RUSTFLAGS : -D warnings
75123 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) }}
106125 name : Tests ${{ matrix.name }}
107126 steps :
108127 - uses : actions/checkout@v3
@@ -184,6 +203,9 @@ jobs:
184203
185204 build_std :
186205 runs-on : ubuntu-latest
206+ needs :
207+ - channel
208+ if : needs.channel.outputs.CHANNEL == 'nightly'
187209 steps :
188210 - uses : actions/checkout@v3
189211 - run : rustup update nightly && rustup default nightly
@@ -194,6 +216,8 @@ jobs:
194216 CARGO_RUN_BUILD_STD_TESTS : 1
195217 docs :
196218 runs-on : ubuntu-latest
219+ needs :
220+ - channel
197221 steps :
198222 - uses : actions/checkout@v3
199223 - run : rustup update nightly && rustup default nightly
@@ -215,22 +239,30 @@ jobs:
215239 - run : cd src/doc && mdbook build --dest-dir ../../target/doc
216240 - name : Run linkchecker.sh
217241 run : |
242+ BRANCH=${{ needs.channel.outputs.CHANNEL }}
218243 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"
220245 sh linkcheck.sh --all --path ../src/doc cargo
221246
247+ # Jobs here must be skipped if they aren't going to merge into master (nightly).
248+ z-nightly-jobs :
249+ needs :
250+ - build_std
251+ if : " (jobs.channel.outputs.CHANNEL != 'master' && contains(needs.*.result, 'skipped')) || success()"
252+ runs-on : ubuntu-latest
253+
222254 success :
223255 permissions :
224256 contents : none
225257 name : bors build finished
226258 needs :
227- - build_std
228259 - docs
229260 - lockfile
230261 - resolver
231262 - rustfmt
232263 - test
233264 - test_gitoxide
265+ - z-nightly-jobs
234266 runs-on : ubuntu-latest
235267 if : " success() && github.event_name == 'push' && github.ref == 'refs/heads/auto-cargo'"
236268 steps :
@@ -240,13 +272,13 @@ jobs:
240272 contents : none
241273 name : bors build finished
242274 needs :
243- - build_std
244275 - docs
245276 - lockfile
246277 - resolver
247278 - rustfmt
248279 - test
249280 - test_gitoxide
281+ - z-nightly-jobs
250282 runs-on : ubuntu-latest
251283 if : " !success() && github.event_name == 'push' && github.ref == 'refs/heads/auto-cargo'"
252284 steps :
0 commit comments