diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 53a9be4e4a..94e08ef762 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -67,7 +67,8 @@ jobs: # The warm build runs as one `cache warm /6` leg per shard, in parallel (each builds what # its shard builds), and `cache warm` puts their files into the one entry it saves. warm-split: true - # The dependency cache also keeps the compiled workspace crates and test executables, so a + # The dependency cache also keeps the compiled workspace crates and their library and binary + # test executables (not the integration tests' executables), so a # pull request's shards rebuild only the crates its changes reach. Each main run's `cache # warm` leg saves a rolling entry of its own, every leg restores the newest one, and # cache-prune.yml deletes the one it replaced after each attempt. The nightly run restores diff --git a/xtask/src/main.rs b/xtask/src/main.rs index a09949f548..d0b95be14e 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -420,11 +420,13 @@ fn cmd_ci_shard() -> Result<(), String> { run_steps(&steps) } -/// `cargo xtask ci warm`: for each run of each test shard, builds the test targets it runs without -/// running them, then builds what the checks shard builds, so one dependency-cache entry holds the -/// dependencies of every shard with the features that shard builds them with (cargo resolves -/// features over the packages each command selects). The test builds select the same crates and -/// targets as the test shards' runs, so the cache also holds the test executables the shards run. +/// `cargo xtask ci warm`: for each test shard, builds the library and binary tests of the crates +/// it tests without running them, then builds what the checks shard builds, so one +/// dependency-cache entry holds the dependencies of every shard with the features that shard builds +/// them with (cargo resolves features over the packages each command selects). It does not build +/// the integration tests ([`warm_runs`], [`warm_tests`]), which take the same dependencies and +/// dev-dependencies as the library tests. Cargo warns `unused dependency vectorcraft-testkit` for +/// vectorcraft-cli, whose integration tests are the only ones that use it. /// /// With `GATE_SHARD` and `GATE_SHARDS` set (the gate's split warm legs), it builds only what that /// shard builds: a test shard's tests, or the checks shard's builds. A split's later parts build @@ -446,7 +448,7 @@ fn cmd_ci_warm() -> Result<(), String> { let mut steps: Vec = Vec::new(); for i in tests { if let shards::Shard::Tests(runs, _) = checked[i].clone() { - for r in runs { + for r in warm_runs(runs) { steps.push(( "build tests", Box::new(move || { @@ -490,11 +492,19 @@ fn push_warm_checks(steps: &mut Vec) { steps.push(("wasm", Box::new(cmd_wasm))); } -/// The command `ci warm` builds the tests of one run of a test shard with, and its description. +/// The runs of a test shard that `ci warm` builds: every run except an integration-test run, whose +/// crate has its library tests in a run on another shard. +fn warm_runs(runs: Vec) -> impl Iterator { + runs.into_iter().filter(|r| r.targets != shards::Targets::Integration) +} + +/// The command `ci warm` builds the library and binary tests of one run of a test shard with, and +/// its description. fn warm_tests(r: &shards::Run) -> (Command, String) { + let units = shards::Targets::Units; let mut c = cargo(); - c.arg("test").args(shards::select(&r.crates)).args(r.targets.args()).arg("--no-run"); - (c, format!("cargo test {} --no-run ({})", r.targets.shown(), shards::names(&r.crates))) + c.arg("test").args(shards::select(&r.crates)).args(units.args()).arg("--no-run"); + (c, format!("cargo test {} --no-run ({})", units.shown(), shards::names(&r.crates))) } /// Runs `steps` in turn, stopping at the first that fails; the summary names the steps that passed @@ -646,15 +656,17 @@ mod tests { use super::*; #[test] - fn warm_builds_the_test_targets_the_shards_run() { - let a = shards::Member { name: "a".into(), id: "path+file:///w/a#0.1.0".into(), version: "0.1.0".into(), doctests: true }; + fn warm_builds_library_and_binary_tests_without_integration_tests() { + let m = + |name: &str| shards::Member { name: name.into(), id: format!("path+file:///w/{name}#0.1.0"), version: "0.1.0".into(), doctests: true }; let args = |r: &shards::Run| warm_tests(r).0.get_args().map(|a| a.to_string_lossy().into_owned()).collect::>(); - let all = shards::Run::all(vec![a.clone()]); - assert_eq!(args(&all), ["test", "-p", "path+file:///w/a#0.1.0", "--lib", "--bins", "--tests", "--no-run"]); - assert_eq!(warm_tests(&all).1, "cargo test --lib --bins --tests --no-run (a)"); - let units = shards::Run { targets: shards::Targets::Units, crates: vec![a.clone()] }; - assert_eq!(args(&units), ["test", "-p", "path+file:///w/a#0.1.0", "--lib", "--bins", "--no-run"]); - let integration = shards::Run { targets: shards::Targets::Integration, crates: vec![a] }; - assert_eq!(args(&integration), ["test", "-p", "path+file:///w/a#0.1.0", "--test", "*", "--no-run"]); + let all = shards::Run::all(vec![m("a")]); + assert_eq!(args(&all), ["test", "-p", "path+file:///w/a#0.1.0", "--lib", "--bins", "--no-run"]); + assert_eq!(warm_tests(&all).1, "cargo test --lib --bins --no-run (a)"); + let units = shards::Run { targets: shards::Targets::Units, crates: vec![m("b")] }; + assert_eq!(args(&units), ["test", "-p", "path+file:///w/b#0.1.0", "--lib", "--bins", "--no-run"]); + let integration = shards::Run { targets: shards::Targets::Integration, crates: vec![m("b")] }; + let built: Vec = warm_runs(vec![all.clone(), integration, units.clone()]).collect(); + assert_eq!(built, [all, units]); } }