Skip to content

Commit

Permalink
ci: Switch to a single matrix for build channels (verify_build)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
tgross35 committed Nov 20, 2024
1 parent 70e98b6 commit df51f2b
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 94 deletions.
73 changes: 13 additions & 60 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: full CI
name: CI

on:
merge_group:
Expand All @@ -9,6 +9,10 @@ env:
CARGO_TERM_VERBOSE: true
LIBC_CI: 1

defaults:
run:
shell: bash

jobs:
style_check:
name: Style check
Expand All @@ -20,71 +24,22 @@ jobs:
- name: Check style
run: ./ci/style.sh

build_channels_linux:
name: Build Channels Linux
runs-on: ubuntu-22.04
# This runs `cargo build --target ...` for all T1 and T2 targets`
verify_build:
name: Verify build
strategy:
fail-fast: true
max-parallel: 5
matrix:
toolchain:
- stable
- beta
- nightly
- 1.63.0
env:
OS: linux
TOOLCHAIN: ${{ matrix.toolchain }}
steps:
- uses: actions/checkout@v4
- name: Setup Rust toolchain
run: ./ci/install-rust.sh
- name: Execute build.sh
run: ./ci/build.sh

build_channels_macos:
name: Build Channels macOS
needs: macos
strategy:
fail-fast: true
max-parallel: 4
matrix:
target:
- { toolchain: stable, os: macos-14 }
- { toolchain: beta, os: macos-14 }
- { toolchain: nightly, os: macos-14 }
- { toolchain: 1.63.0, os: macos-14 }
runs-on: ${{ matrix.target.os }}
toolchain: [stable, nightly, 1.63.0, beta]
os: [ubuntu-22.04, macos-14, windows-2022]
runs-on: ${{ matrix.os }}
env:
OS: macos
TOOLCHAIN: ${{ matrix.toolchain }}
steps:
- uses: actions/checkout@v4
- name: Setup Rust toolchain
run: ./ci/install-rust.sh
- name: Execute build.sh
run: ./ci/build.sh

build_channels_windows:
name: Build Channels Windows
runs-on: windows-2022
strategy:
fail-fast: true
matrix:
toolchain:
- 1.63.0
- stable
env:
OS: windows
TOOLCHAIN: ${{ matrix.toolchain }}
steps:
- uses: actions/checkout@v4
- name: Self-update rustup
run: rustup self update
shell: bash
- name: Execute build.sh
run: ./ci/build.sh
shell: bash
run: ./ci/verify-build.sh

macos:
name: macOS
Expand Down Expand Up @@ -250,9 +205,7 @@ jobs:
- windows
- solaris
- style_check
- build_channels_linux
- build_channels_macos
- build_channels_windows
- verify_build
# Github branch protection is exceedingly silly and treats "jobs skipped because a dependency
# failed" as success. So we have to do some contortions to ensure the job fails if any of its
# dependencies fails.
Expand Down
67 changes: 33 additions & 34 deletions ci/build.sh → ci/verify-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,21 @@
set -eux

: "${TOOLCHAIN?The TOOLCHAIN environment variable must be set.}"
: "${OS?The OS environment variable must be set.}"

rust="$TOOLCHAIN"
filter="${FILTER:-}"

echo "Testing Rust $rust on $OS"
case "$(uname -s)" in
Linux*) os=linux ;;
Darwin*) os=macos ;;
MINGW*) os=windows ;;
*)
echo "Unknown system $(uname -s)"
exit 1
;;
esac

echo "Testing Rust $rust on $os"

if [ "$TOOLCHAIN" = "nightly" ] ; then
rustup component add rust-src
Expand Down Expand Up @@ -198,40 +207,30 @@ i386-apple-ios \
"

# The targets are listed here alphabetically
targets=""
no_dist_targets=""

case "${OS}" in
linux*)
targets="$rust_linux_targets"

if [ "$rust" = "nightly" ]; then
targets="$targets $rust_nightly_linux_targets"
no_dist_targets="$rust_linux_no_dist_targets"
fi

;;
macos*)
targets="$rust_apple_targets"

if [ "$rust" = "nightly" ]; then
targets="$targets $rust_nightly_apple_targets"
no_dist_targets="$rust_apple_no_dist_targets"
fi
if [ "$os" = "linux" ]; then
targets="$rust_linux_targets"
nightly_targets="$rust_nightly_linux_targets"
no_dist_targets="$rust_linux_no_dist_targets"
elif [ "$os" = "macos" ]; then
targets="$rust_apple_targets"
nightly_targets="$rust_nightly_apple_targets"
no_dist_targets="$rust_apple_no_dist_targets"
elif [ "$os" = "windows" ]; then
targets=${rust_nightly_windows_targets}
else
exit 1
fi

;;
windows*)
targets=${rust_nightly_windows_targets}
;;
*)
echo "Unrecognized OS $OS"
exit 1
;;
esac
if [ "$rust" = "nightly" ]; then
targets="$targets $nightly_targets"
else
# build-std requires nightly
no_dist_targets=""
fi

for target in $targets; do
if echo "$target" | grep -q "$filter"; then
if [ "${OS}" = "windows" ]; then
if [ "$os" = "windows" ]; then
TARGET="$target" ./ci/install-rust.sh
test_target "$target"
else
Expand All @@ -242,9 +241,9 @@ for target in $targets; do
fi
done

for target in $no_dist_targets; do
for target in ${no_dist_targets:-}; do
if echo "$target" | grep -q "$filter"; then
if [ "${OS}" = "windows" ]; then
if [ "$os" = "windows" ]; then
TARGET="$target" ./ci/install-rust.sh
test_target "$target" 1
else
Expand Down

0 comments on commit df51f2b

Please sign in to comment.