Skip to content

Commit b2425ee

Browse files
committed
ci: Switch to a single matrix for build channels (verify_build)
The Mac, Windows, and Linux jobs for build channels are pretty redundant. Turn this into a single `verify_build` job that has both OS and version in its matrix. For consistency, rename the script to `verify-build`. To simplify variables, allow the build and toolchain scripts to detect the OS rather than passing it from CI. (backport <#4124>) (cherry picked from commit c4e3ff8)
1 parent 8f6d1fe commit b2425ee

File tree

3 files changed

+61
-105
lines changed

3 files changed

+61
-105
lines changed

.github/workflows/ci.yaml

Lines changed: 12 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: full CI
1+
name: CI
22

33
on:
44
merge_group:
@@ -25,71 +25,25 @@ jobs:
2525
- name: Check style
2626
run: ./ci/style.sh
2727

28-
build_channels_linux:
29-
name: Build Channels Linux
30-
runs-on: ubuntu-22.04
28+
# This runs `cargo build --target ...` for all T1 and T2 targets`
29+
verify_build:
30+
name: Verify build
3131
strategy:
32-
fail-fast: true
33-
max-parallel: 5
3432
matrix:
35-
toolchain:
36-
- stable
37-
- beta
38-
- nightly
39-
- 1.63.0
40-
env:
41-
OS: linux
42-
TOOLCHAIN: ${{ matrix.toolchain }}
43-
steps:
44-
- uses: actions/checkout@v4
45-
- name: Setup Rust toolchain
46-
run: ./ci/install-rust.sh
47-
- name: Execute build.sh
48-
run: ./ci/build.sh
49-
50-
build_channels_macos:
51-
name: Build Channels macOS
52-
needs: macos
53-
strategy:
54-
fail-fast: true
55-
max-parallel: 4
56-
matrix:
57-
target:
58-
- { toolchain: stable, os: macos-14 }
59-
- { toolchain: beta, os: macos-14 }
60-
- { toolchain: nightly, os: macos-14 }
61-
- { toolchain: 1.63.0, os: macos-14 }
62-
runs-on: ${{ matrix.target.os }}
33+
toolchain: [stable, nightly, 1.63.0]
34+
os: [ubuntu-22.04, macos-14, windows-2022]
35+
include:
36+
- toolchain: beta
37+
os: ubuntu-22.04
38+
runs-on: ${{ matrix.os }}
6339
env:
64-
OS: macos
6540
TOOLCHAIN: ${{ matrix.toolchain }}
6641
steps:
6742
- uses: actions/checkout@v4
6843
- name: Setup Rust toolchain
6944
run: ./ci/install-rust.sh
7045
- name: Execute build.sh
71-
run: ./ci/build.sh
72-
73-
build_channels_windows:
74-
name: Build Channels Windows
75-
runs-on: windows-2022
76-
strategy:
77-
fail-fast: true
78-
matrix:
79-
toolchain:
80-
- 1.63.0
81-
- stable
82-
env:
83-
OS: windows
84-
TOOLCHAIN: ${{ matrix.toolchain }}
85-
steps:
86-
- uses: actions/checkout@v4
87-
- name: Self-update rustup
88-
run: rustup self update
89-
shell: bash
90-
- name: Execute build.sh
91-
run: ./ci/build.sh
92-
shell: bash
46+
run: ./ci/verify-build.sh
9347

9448
macos:
9549
name: macOS
@@ -254,9 +208,7 @@ jobs:
254208
- windows
255209
- solaris
256210
- style_check
257-
- build_channels_linux
258-
- build_channels_macos
259-
- build_channels_windows
211+
- verify_build
260212
# Github branch protection is exceedingly silly and treats "jobs skipped because a dependency
261213
# failed" as success. So we have to do some contortions to ensure the job fails if any of its
262214
# dependencies fails.

ci/install-rust.sh

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,25 @@ echo "Setup toolchain"
88
toolchain="${TOOLCHAIN:-nightly}"
99
os="${OS:-}"
1010

11-
if [ "$os" = "windows" ]; then
12-
: "${TARGET?The TARGET environment variable must be set.}"
13-
rustup set profile minimal
14-
rustup update --force "$toolchain-$TARGET"
15-
rustup default "$toolchain-$TARGET"
16-
else
11+
case "$(uname -s)" in
12+
Linux*) os=linux ;;
13+
Darwin*) os=macos ;;
14+
MINGW*) os=windows ;;
15+
*)
16+
echo "Unknown system $(uname -s)"
17+
exit 1
18+
;;
19+
esac
20+
21+
if [ "$os" = "windows" ] && [ -n "${TARGET:-}" ]; then
22+
toolchain="$toolchain-$TARGET"
1723
rustup set profile minimal
18-
rustup update --force "$toolchain"
19-
rustup default "$toolchain"
2024
fi
2125

26+
rustup set profile minimal
27+
rustup update --force "$toolchain"
28+
rustup default "$toolchain"
29+
2230
if [ -n "${TARGET:-}" ]; then
2331
echo "Install target"
2432
rustup target add "$TARGET"
@@ -50,9 +58,6 @@ if [ "$os" = "windows" ]; then
5058
fi
5159

5260
echo "Query rust and cargo versions"
53-
command -v rustc
54-
command -v cargo
55-
command -v rustup
5661
rustc -Vv
5762
cargo -V
5863
rustup -Vv

ci/build.sh renamed to ci/verify-build.sh

Lines changed: 33 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,21 @@
88
set -eux
99

1010
: "${TOOLCHAIN?The TOOLCHAIN environment variable must be set.}"
11-
: "${OS?The OS environment variable must be set.}"
1211

1312
rust="$TOOLCHAIN"
1413
filter="${FILTER:-}"
1514

16-
echo "Testing Rust $rust on $OS"
15+
case "$(uname -s)" in
16+
Linux*) os=linux ;;
17+
Darwin*) os=macos ;;
18+
MINGW*) os=windows ;;
19+
*)
20+
echo "Unknown system $(uname -s)"
21+
exit 1
22+
;;
23+
esac
24+
25+
echo "Testing Rust $rust on $os"
1726

1827
if [ "$TOOLCHAIN" = "nightly" ] ; then
1928
rustup component add rust-src
@@ -201,40 +210,30 @@ i386-apple-ios \
201210
"
202211

203212
# The targets are listed here alphabetically
204-
targets=""
205-
no_dist_targets=""
206-
207-
case "${OS}" in
208-
linux*)
209-
targets="$rust_linux_targets"
210-
211-
if [ "$rust" = "nightly" ]; then
212-
targets="$targets $rust_nightly_linux_targets"
213-
no_dist_targets="$rust_linux_no_dist_targets"
214-
fi
215-
216-
;;
217-
macos*)
218-
targets="$rust_apple_targets"
219-
220-
if [ "$rust" = "nightly" ]; then
221-
targets="$targets $rust_nightly_apple_targets"
222-
no_dist_targets="$rust_apple_no_dist_targets"
223-
fi
213+
if [ "$os" = "linux" ]; then
214+
targets="$rust_linux_targets"
215+
nightly_targets="$rust_nightly_linux_targets"
216+
no_dist_targets="$rust_linux_no_dist_targets"
217+
elif [ "$os" = "macos" ]; then
218+
targets="$rust_apple_targets"
219+
nightly_targets="$rust_nightly_apple_targets"
220+
no_dist_targets="$rust_apple_no_dist_targets"
221+
elif [ "$os" = "windows" ]; then
222+
targets=${rust_nightly_windows_targets}
223+
else
224+
exit 1
225+
fi
224226

225-
;;
226-
windows*)
227-
targets=${rust_nightly_windows_targets}
228-
;;
229-
*)
230-
echo "Unrecognized OS $OS"
231-
exit 1
232-
;;
233-
esac
227+
if [ "$rust" = "nightly" ]; then
228+
targets="$targets ${nightly_targets:-}"
229+
else
230+
# build-std requires nightly
231+
no_dist_targets=""
232+
fi
234233

235234
for target in $targets; do
236235
if echo "$target" | grep -q "$filter"; then
237-
if [ "${OS}" = "windows" ]; then
236+
if [ "$os" = "windows" ]; then
238237
TARGET="$target" ./ci/install-rust.sh
239238
test_target "$target"
240239
else
@@ -245,9 +244,9 @@ for target in $targets; do
245244
fi
246245
done
247246

248-
for target in $no_dist_targets; do
247+
for target in ${no_dist_targets:-}; do
249248
if echo "$target" | grep -q "$filter"; then
250-
if [ "${OS}" = "windows" ]; then
249+
if [ "$os" = "windows" ]; then
251250
TARGET="$target" ./ci/install-rust.sh
252251
test_target "$target" 1
253252
else

0 commit comments

Comments
 (0)