Skip to content

Commit c068f61

Browse files
committed
ci: Always run verify-build on Linux
Most of the targets are cross compiled anyway, and there isn't any advantage to running on native platforms. Start running everything on Linux which is the fastest and cheapest runner. As part of this, introduce a way to run only half of the target list from a single invocation. This is used to split the nightly job in two, each now only taking about as long as the stable job. (backport <#4780>) (cherry picked from commit 56b916d)
1 parent 0f4f2a9 commit c068f61

File tree

2 files changed

+29
-28
lines changed

2 files changed

+29
-28
lines changed

.github/workflows/ci.yaml

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,18 @@ jobs:
5151
name: Verify build
5252
strategy:
5353
matrix:
54-
toolchain: [stable, nightly, 1.63.0]
55-
os: [ubuntu-24.04, macos-15, windows-2025]
54+
toolchain: [stable, 1.63.0]
5655
include:
56+
# Nightly has a lot of targets, so split it in half
57+
- toolchain: nightly
58+
half: 1
59+
- toolchain: nightly
60+
half: 2
5761
- toolchain: beta
58-
os: ubuntu-24.04
59-
runs-on: ${{ matrix.os }}
62+
only: '(aarch64|x86_64)' # just a spot check for beta
63+
- toolchain: stable
64+
- toolchain: 1.63.0 # msrv
65+
runs-on: ubuntu-24.04
6066
timeout-minutes: 25
6167
env:
6268
TOOLCHAIN: ${{ matrix.toolchain }}
@@ -83,7 +89,10 @@ jobs:
8389
set -eux
8490
# Remove `-Dwarnings` at the MSRV since lints may be different
8591
[ "${{ matrix.toolchain }}" = "1.63.0" ] && export RUSTFLAGS=""
86-
python3 ci/verify-build.py --toolchain "$TOOLCHAIN"
92+
python3 ci/verify-build.py \
93+
--toolchain "$TOOLCHAIN" \
94+
${{ matrix.only && format('--only "{0}"', matrix.only) }} \
95+
${{ matrix.half && format('--half "{0}"', matrix.half) }}
8796
- name: Target size after job completion
8897
run: du -sh target | sort -k 2
8998

ci/verify-build.py

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,6 @@ def __post_init__(self):
6464
# We will need to use build-std
6565
self.min_toolchain = Toolchain.NIGHTLY
6666

67-
def run_on(self) -> Os:
68-
"""MacOS CI runs all apple targets, Windows CI runs all Windows targets,
69-
Linux CI handles everything else."""
70-
71-
if "apple" in self.name:
72-
return Os.DARWIN
73-
elif "windows" in self.name:
74-
return Os.WINDOWS
75-
return Os.LINUX
76-
7767

7868
FREEBSD_VERSIONS = [11, 12, 13, 14, 15]
7969

@@ -324,6 +314,12 @@ def main():
324314
p.add_argument("--toolchain", required=True, help="Rust toolchain")
325315
p.add_argument("--only", help="only targets matching this regex")
326316
p.add_argument("--skip", help="skip targets matching this regex")
317+
p.add_argument(
318+
"--half",
319+
type=int,
320+
choices=[1, 2],
321+
help="specify 1 or 2 to run half of the targets",
322+
)
327323
args = p.parse_args()
328324

329325
cfg = Cfg(toolchain_name=args.toolchain)
@@ -346,30 +342,26 @@ def main():
346342
targets = [t for t in targets if cfg.toolchain >= t.min_toolchain]
347343
eprint(f"Targets checkable with this toolchain: {len(targets)}")
348344

349-
# Targets get split among the diferent CI runners
350-
targets = [t for t in targets if t.run_on() == cfg.os_]
351-
eprint(f"Targets checked on this OS: {len(targets)}")
352-
353345
# Apply filtering
354346
if args.only:
355347
targets = [t for t in targets if re.match(args.only, t.name)]
356348
if args.skip:
357349
targets = [t for t in targets if not re.match(args.skip, t.name)]
358350

351+
# Allow splitting the targets in half for time improvements
352+
if args.half == 1:
353+
targets = targets[0::2]
354+
elif args.half == 2:
355+
targets = targets[1::2]
356+
359357
total = len(targets)
360358
eprint(f"Targets to run: {total}")
361359
assert total > 0, "some tests should be run"
362360

363361
for i, target in enumerate(targets):
364-
# HACK: We need to install the toolchain by name for most Windows toolchains,
365-
# but not when cross compiling.
366-
if cfg.os_ == Os.WINDOWS and "aarch64" not in target.name:
367-
run(
368-
["sh", "./ci/install-rust.sh"], env=os.environ | {"TARGET": target.name}
369-
)
370-
371-
eprint(f"::group::Target: {target.name} ({i}/{total})")
372-
eprint(f"{ESC_CYAN}Checking target {target} ({i}/{total}){ESC_END}")
362+
at = i + 1
363+
eprint(f"::group::Target: {target.name} ({at}/{total})")
364+
eprint(f"{ESC_CYAN}Checking target {target} ({at}/{total}){ESC_END}")
373365
test_target(cfg, target)
374366
eprint("::endgroup::")
375367

0 commit comments

Comments
 (0)