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 == 'master'
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,36 @@ 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 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+
222260 success :
223261 permissions :
224262 contents : none
225263 name : bors build finished
226264 needs :
227- - build_std
228265 - docs
229266 - lockfile
230267 - resolver
231268 - rustfmt
232269 - test
233270 - test_gitoxide
271+ - z-nightly-jobs
234272 runs-on : ubuntu-latest
235273 if : " success() && github.event_name == 'push' && github.ref == 'refs/heads/auto-cargo'"
236274 steps :
@@ -240,13 +278,13 @@ jobs:
240278 contents : none
241279 name : bors build finished
242280 needs :
243- - build_std
244281 - docs
245282 - lockfile
246283 - resolver
247284 - rustfmt
248285 - test
249286 - test_gitoxide
287+ - z-nightly-jobs
250288 runs-on : ubuntu-latest
251289 if : " !success() && github.event_name == 'push' && github.ref == 'refs/heads/auto-cargo'"
252290 steps :
0 commit comments