mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-12-05 13:32:45 -05:00
xtask: the cache warm no longer builds integration test executables
Since #10163, `cargo xtask ci warm` built each test shard with `--lib --bins --tests --no-run`, so the dependency-cache entry also held the integration test executables. The gate-crates entry grew from about 4.7 GB to 10.3 to 10.5 GB, above the repository's 10 GB cache budget, and the slowest test shard on main took 30 to 31 minutes afterwards against 26 to 28 minutes before. The warm build now builds the library and binary tests of each shard's crates (`--lib --bins --no-run`) and skips a run of integration tests alone, whose crate has its library tests built on another shard. The integration tests take the same dependencies and dev-dependencies, so the entry still holds every dependency the shards build. Cargo again warns `unused dependency vectorcraft-testkit` for vectorcraft-cli in the warm log; only that crate's integration tests use it.
This commit is contained in:
1 parent
88851063c0
commit
5bfe35996b
2 files changed
+32
-19
No files matched your search
@@ -67,7 +67,8 @@ jobs:
|
||||
# The warm build runs as one `cache warm <k>/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
|
||||
|
||||
+30
-18
@@ -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<Step> = 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<Step>) {
|
||||
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<shards::Run>) -> impl Iterator<Item = shards::Run> {
|
||||
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::<Vec<String>>();
|
||||
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<shards::Run> = warm_runs(vec![all.clone(), integration, units.clone()]).collect();
|
||||
assert_eq!(built, [all, units]);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user