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.
This commit is contained in:
dotCooCoo committed 2026-12-04 23:58:57 -08:00
1 parent 4f0f123108
commit fb3f2d545f
1 file changed
+13 -2
+13 -2
View File
@@ -56,7 +56,7 @@ commands:
ci archive build every shard's tests once and write shard k's nextest archive to
$NEXTEST_ARCHIVE_DIR/<k>/$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> {