From fb3f2d545f0fef310e83bc4c50b6552fb020cdf2 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Fri, 4 Dec 2026 23:58:57 -0800 Subject: [PATCH] CI: the build job runs each shard's doctests in a command of its own `cargo xtask ci doctests` ran the doctests of every workspace member in one `cargo test --doc`, which resolves features over all of them and rebuilt the libraries the per-shard builds had built: the step took 24 minutes in the build job of pull request run 47488581650. It now runs one `cargo test --doc` per shard with the crates `ci shard` runs them for. On the build host, after `ci archive`, the step took 34 seconds. --- xtask/src/main.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/xtask/src/main.rs b/xtask/src/main.rs index 73a47429ba..2ec7e394b5 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -56,7 +56,7 @@ commands: ci archive build every shard's tests once and write shard k's nextest archive to $NEXTEST_ARCHIVE_DIR//$NEXTEST_ARCHIVE_NAME for k from 1 to $GATE_SHARDS; with CRAFT_CACHE_UNITS set, appends Cargo's JSON messages for the build to that file - ci doctests the workspace doctests + ci doctests the doctests of each shard's crates, one cargo command per shard ci checks the ci steps other than the tests, the doctests and the i18n report shards list the crates each shard tests; fails when a member is in no shard or in two, or builds with other features in its shard than in the whole workspace @@ -99,7 +99,7 @@ fn main() -> ExitCode { Some("test") => cmd_test().and_then(|()| cmd_doctests()), Some("ci") if rest.first() == Some(&"shard") => cmd_ci_shard(), Some("ci") if rest.first() == Some(&"archive") => cmd_ci_archive(), - Some("ci") if rest.first() == Some(&"doctests") => cmd_doctests(), + Some("ci") if rest.first() == Some(&"doctests") => cmd_ci_doctests(), Some("ci") if rest.first() == Some(&"checks") => cmd_ci_checks(), Some("ci") => cmd_ci(), Some("shards") => shards::run().map(drop), @@ -540,6 +540,17 @@ fn test_build(r: &shards::Run, units: bool) -> (Command, String) { (c, format!("cargo test {} --no-run ({})", targets.shown(), shards::names(&r.crates))) } +/// `cargo xtask ci doctests`: the doctests of each shard's crates, one cargo command per shard +/// with the crates `ci shard` runs them for, after `ci archive` (the shared gate's +/// `after-archive-command`). Every command runs before the first error is returned. +fn cmd_ci_doctests() -> Result<(), String> { + let mut result = Ok(()); + for s in shards::assigned()?.iter().filter(|s| s.part.is_none_or(|p| p.is_first())) { + result = result.and(doctest_packages(&shards::unit_crates(&s.runs))); + } + result +} + /// `cargo xtask ci checks`: every `ci` step other than [`TEST_STEPS`], for the shared gate's /// `lint` leg. fn cmd_ci_checks() -> Result<(), String> {