Skip to content

Commit df51f2b

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 script to detect the OS rather than passing it from CI.
1 parent 70e98b6 commit df51f2b

File tree

2 files changed

+46
-94
lines changed

2 files changed

+46
-94
lines changed

.github/workflows/ci.yaml

Lines changed: 13 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:
@@ -9,6 +9,10 @@ env:
99
CARGO_TERM_VERBOSE: true
1010
LIBC_CI: 1
1111

12+
defaults:
13+
run:
14+
shell: bash
15+
1216
jobs:
1317
style_check:
1418
name: Style check
@@ -20,71 +24,22 @@ jobs:
2024
- name: Check style
2125
run: ./ci/style.sh
2226

23-
build_channels_linux:
24-
name: Build Channels Linux
25-
runs-on: ubuntu-22.04
27+
# This runs `cargo build --target ...` for all T1 and T2 targets`
28+
verify_build:
29+
name: Verify build
2630
strategy:
27-
fail-fast: true
28-
max-parallel: 5
2931
matrix:
30-
toolchain:
31-
- stable
32-
- beta
33-
- nightly
34-
- 1.63.0
35-
env:
36-
OS: linux
37-
TOOLCHAIN: ${{ matrix.toolchain }}
38-
steps:
39-
- uses: actions/checkout@v4
40-
- name: Setup Rust toolchain
41-
run: ./ci/install-rust.sh
42-
- name: Execute build.sh
43-
run: ./ci/build.sh
44-
45-
build_channels_macos:
46-
name: Build Channels macOS
47-
needs: macos
48-
strategy:
49-
fail-fast: true
50-
max-parallel: 4
51-
matrix:
52-
target:
53-
- { toolchain: stable, os: macos-14 }
54-
- { toolchain: beta, os: macos-14 }
55-
- { toolchain: nightly, os: macos-14 }
56-
- { toolchain: 1.63.0, os: macos-14 }
57-
runs-on: ${{ matrix.target.os }}
32+
toolchain: [stable, nightly, 1.63.0, beta]
33+
os: [ubuntu-22.04, macos-14, windows-2022]
34+
runs-on: ${{ matrix.os }}
5835
env:
59-
OS: macos
6036
TOOLCHAIN: ${{ matrix.toolchain }}
6137
steps:
6238
- uses: actions/checkout@v4
6339
- name: Setup Rust toolchain
6440
run: ./ci/install-rust.sh
6541
- name: Execute build.sh
66-
run: ./ci/build.sh
67-
68-
build_channels_windows:
69-
name: Build Channels Windows
70-
runs-on: windows-2022
71-
strategy:
72-
fail-fast: true
73-
matrix:
74-
toolchain:
75-
- 1.63.0
76-
- stable
77-
env:
78-
OS: windows
79-
TOOLCHAIN: ${{ matrix.toolchain }}
80-
steps:
81-
- uses: actions/checkout@v4
82-
- name: Self-update rustup
83-
run: rustup self update
84-
shell: bash
85-
- name: Execute build.sh
86-
run: ./ci/build.sh
87-
shell: bash
42+
run: ./ci/verify-build.sh
8843

8944
macos:
9045
name: macOS
@@ -250,9 +205,7 @@ jobs:
250205
- windows
251206
- solaris
252207
- style_check
253-
- build_channels_linux
254-
- build_channels_macos
255-
- build_channels_windows
208+
- verify_build
256209
# Github branch protection is exceedingly silly and treats "jobs skipped because a dependency
257210
# failed" as success. So we have to do some contortions to ensure the job fails if any of its
258211
# dependencies fails.

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)