From 1b3ea180c3cc289fa71c20de1a0dfd5b9ad12941 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Wed, 2 Dec 2026 06:32:53 -0800 Subject: [PATCH 1/2] CI: build two paths without parent-step literals so test selection passes The select legs failed because the shared gate's undeclared-read check (craft-common-actions #451) still counts two paths as reads outside their crate. The engine test built a relative path to a temporary folder from "../".repeat(n), reported as a read of `crates`; the text build script joined CARGO_MANIFEST_DIR with "../..", reported as a read of the repository root. Neither reads a tracked file. The test now builds the path from Component::ParentDir, and the build script takes the manifest directory's grandparent; both give the same paths as before. --- crates/engine/src/tests/fontfiles.rs | 4 ++-- crates/text/build.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/engine/src/tests/fontfiles.rs b/crates/engine/src/tests/fontfiles.rs index e90aec1df9..e503a98691 100644 --- a/crates/engine/src/tests/fontfiles.rs +++ b/crates/engine/src/tests/fontfiles.rs @@ -143,8 +143,8 @@ fn the_fonts_folder_next_to_a_document_is_an_absolute_path() { let (_dir, root) = folder("relative"); std::fs::create_dir_all(root.join("pkg/Fonts")).unwrap(); let cwd = std::env::current_dir().unwrap(); - let up = "../".repeat(cwd.components().count().saturating_sub(1)); - let relative = format!("{up}{}", root.join("pkg/doc.vectorcraft").strip_prefix("/").unwrap().display()); + let up: std::path::PathBuf = std::iter::repeat_n(std::path::Component::ParentDir, cwd.components().count().saturating_sub(1)).collect(); + let relative = up.join(root.join("pkg/doc.vectorcraft").strip_prefix("/").unwrap()).display().to_string(); assert!(Path::new(&relative).is_relative()); let mut s = session_for(&root); let mut doc = vectorcraft_doc::Document::new(100.0, 100.0); diff --git a/crates/text/build.rs b/crates/text/build.rs index 7863efe464..a4e3dcf58c 100644 --- a/crates/text/build.rs +++ b/crates/text/build.rs @@ -103,7 +103,7 @@ fn from_workspace(dir: PathBuf) -> PathBuf { return dir; } let crate_dir = PathBuf::from(std::env::var_os("CARGO_MANIFEST_DIR").unwrap_or_default()); - crate_dir.join("../..").join(dir) + crate_dir.parent().and_then(Path::parent).unwrap_or(&crate_dir).join(dir) } /// The one craft-fonts face web builds embed (family, style). From d308e9d017c6f3c3773746e4f7b876f9bae7cf5e Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Wed, 2 Dec 2026 06:38:09 -0800 Subject: [PATCH 2/2] xtask: check the CI shard-members lines in every shard, not in one test With test selection, a pull request that moves a crate between shards in GROUPS without changing ci.yml could skip the shard holding the test that compared the two. `shards::check`, which every shard and warm leg runs, now compares them and fails with both lists. --- xtask/src/shards.rs | 52 ++++++++++++++++++++++++++++----------------- 1 file changed, 33 insertions(+), 19 deletions(-) diff --git a/xtask/src/shards.rs b/xtask/src/shards.rs index f28a881fd4..188f1bbda8 100644 --- a/xtask/src/shards.rs +++ b/xtask/src/shards.rs @@ -327,6 +327,9 @@ pub fn names(crates: &[Member]) -> String { /// The shards of this workspace, after the checks in [`assign`] and [`feature_differences`]. pub fn check() -> Result, String> { + // The shared gate runs only the shards that test a crate a pull request reaches, by these + // lines, so a mismatch fails every shard instead of one test that selection may skip. + workflow_members(include_str!("../../.github/workflows/ci.yml"))?; let members = members(&crate::metadata()?)?; let shards = assign(GROUPS, &members)?; let workspace = tree_features(&tree(&["--workspace".to_owned()])?, &members); @@ -349,6 +352,34 @@ pub fn check() -> Result, String> { Ok(shards) } +/// The lines of the `shard-members: |` block in `workflow`, trimmed. +fn shard_members(workflow: &str) -> Vec<&str> { + let mut lines = workflow.lines().skip_while(|l| l.trim() != "shard-members: |"); + let Some(key) = lines.next() else { return Vec::new() }; + let indent = |l: &str| l.len() - l.trim_start().len(); + lines.take_while(|l| !l.trim().is_empty() && indent(l) > indent(key)).map(str::trim).collect() +} + +/// Checks that `workflow`'s `shard-members` block names each shard's crates as [`GROUPS`] does. +fn workflow_members(workflow: &str) -> Result<(), String> { + let expected: Vec = GROUPS + .iter() + .map(|g| match g { + Group::Crates(crates) => crates.join(" "), + Group::Part(split, _) => split.crates.join(" "), + Group::Rest => "(rest)".to_owned(), + Group::Checks => "(always)".to_owned(), + }) + .collect(); + let found = shard_members(workflow); + if found != expected { + return Err(format!( + "shard-members in .github/workflows/ci.yml does not match xtask/src/shards.rs › GROUPS:\n found: {found:?}\n expected: {expected:?}" + )); + } + Ok(()) +} + /// `cargo xtask shards`: prints each shard's crates after [`check`], and returns the shards. pub fn run() -> Result, String> { let shards = check()?; @@ -685,27 +716,10 @@ geom v0.1.0 (/w/geom)| ); } - /// The lines of the `shard-members: |` block in `workflow`, trimmed. - fn shard_members(workflow: &str) -> Vec<&str> { - let mut lines = workflow.lines().skip_while(|l| l.trim() != "shard-members: |"); - let Some(key) = lines.next() else { return Vec::new() }; - let indent = |l: &str| l.len() - l.trim_start().len(); - lines.take_while(|l| !l.trim().is_empty() && indent(l) > indent(key)).map(str::trim).collect() - } - #[test] fn ci_names_the_crates_of_every_shard_for_test_selection() { - // The shared gate runs only the shards that test a crate a pull request reaches, by these lines. - let expected: Vec = GROUPS - .iter() - .map(|g| match g { - Group::Crates(crates) => crates.join(" "), - Group::Part(split, _) => split.crates.join(" "), - Group::Rest => "(rest)".to_owned(), - Group::Checks => "(always)".to_owned(), - }) - .collect(); - assert_eq!(shard_members(include_str!("../../.github/workflows/ci.yml")), expected, "shard-members in .github/workflows/ci.yml"); + assert_eq!(workflow_members(include_str!("../../.github/workflows/ci.yml")), Ok(())); + assert!(workflow_members(" shard-members: |\n a b\n (rest)\n next: 1\n").is_err()); assert_eq!(shard_members(" shard-members: |\n a b\n (rest)\n next: 1\n"), ["a b", "(rest)"]); assert!(shard_members("test-shards: 6\n").is_empty()); }