Skip to content

Commit c4e3ff8

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.
1 parent 3faaf4d commit c4e3ff8

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:
@@ -24,71 +24,25 @@ jobs:
2424
- name: Check style
2525
run: ./ci/style.sh
2626

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

9347
macos:
9448
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
@@ -198,40 +207,30 @@ i386-apple-ios \
198207
"
199208

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

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

232231
for target in $targets; do
233232
if echo "$target" | grep -q "$filter"; then
234-
if [ "${OS}" = "windows" ]; then
233+
if [ "$os" = "windows" ]; then
235234
TARGET="$target" ./ci/install-rust.sh
236235
test_target "$target"
237236
else
@@ -242,9 +241,9 @@ for target in $targets; do
242241
fi
243242
done
244243

245-
for target in $no_dist_targets; do
244+
for target in ${no_dist_targets:-}; do
246245
if echo "$target" | grep -q "$filter"; then
247-
if [ "${OS}" = "windows" ]; then
246+
if [ "$os" = "windows" ]; then
248247
TARGET="$target" ./ci/install-rust.sh
249248
test_target "$target" 1
250249
else

0 commit comments

Comments
 (0)