diff --git a/.github/workflows/run_tests.yml b/.github/workflows/run_tests.yml
index fe6c123b9b6afcfb449127ce41e11ad40e7e476c..dd0eee2efe0fbdb6d7cc8ad9d046cce5a81aaf4e 100644
--- a/.github/workflows/run_tests.yml
+++ b/.github/workflows/run_tests.yml
@@ -55,11 +55,28 @@ jobs:
echo "Toolchain, cargo config, or root Cargo files changed, will run all tests"
echo "changed_packages=" >> "$GITHUB_OUTPUT"
else
- # Extract changed packages from file paths
- FILE_CHANGED_PKGS=$(echo "$CHANGED_FILES" | \
+ # Extract changed directories from file paths
+ CHANGED_DIRS=$(echo "$CHANGED_FILES" | \
grep -oP '^(crates|tooling)/\K[^/]+' | \
sort -u || true)
+ # Build directory-to-package mapping using cargo metadata
+ DIR_TO_PKG=$(cargo metadata --format-version=1 --no-deps 2>/dev/null | \
+ jq -r '.packages[] | select(.manifest_path | test("crates/|tooling/")) | "\(.manifest_path | capture("(crates|tooling)/(?
[^/]+)") | .dir)=\(.name)"')
+
+ # Map directory names to package names
+ FILE_CHANGED_PKGS=""
+ for dir in $CHANGED_DIRS; do
+ pkg=$(echo "$DIR_TO_PKG" | grep "^${dir}=" | cut -d= -f2 | head -1)
+ if [ -n "$pkg" ]; then
+ FILE_CHANGED_PKGS=$(printf '%s\n%s' "$FILE_CHANGED_PKGS" "$pkg")
+ else
+ # Fall back to directory name if no mapping found
+ FILE_CHANGED_PKGS=$(printf '%s\n%s' "$FILE_CHANGED_PKGS" "$dir")
+ fi
+ done
+ FILE_CHANGED_PKGS=$(echo "$FILE_CHANGED_PKGS" | grep -v '^$' | sort -u || true)
+
# If assets/ changed, add crates that depend on those assets
if echo "$CHANGED_FILES" | grep -qP '^assets/'; then
FILE_CHANGED_PKGS=$(printf '%s\n%s\n%s\n%s' "$FILE_CHANGED_PKGS" "settings" "storybook" "assets" | sort -u)
diff --git a/tooling/xtask/src/tasks/workflows/run_tests.rs b/tooling/xtask/src/tasks/workflows/run_tests.rs
index 331d6956288a8b8008ec5b49ff28c5b71a02519b..d474f4c08758abb11864458ffaaf39538017858b 100644
--- a/tooling/xtask/src/tasks/workflows/run_tests.rs
+++ b/tooling/xtask/src/tasks/workflows/run_tests.rs
@@ -163,11 +163,28 @@ fn orchestrate_impl(rules: &[&PathCondition], include_package_filter: bool) -> N
echo "Toolchain, cargo config, or root Cargo files changed, will run all tests"
echo "changed_packages=" >> "$GITHUB_OUTPUT"
else
- # Extract changed packages from file paths
- FILE_CHANGED_PKGS=$(echo "$CHANGED_FILES" | \
+ # Extract changed directories from file paths
+ CHANGED_DIRS=$(echo "$CHANGED_FILES" | \
grep -oP '^(crates|tooling)/\K[^/]+' | \
sort -u || true)
+ # Build directory-to-package mapping using cargo metadata
+ DIR_TO_PKG=$(cargo metadata --format-version=1 --no-deps 2>/dev/null | \
+ jq -r '.packages[] | select(.manifest_path | test("crates/|tooling/")) | "\(.manifest_path | capture("(crates|tooling)/(?[^/]+)") | .dir)=\(.name)"')
+
+ # Map directory names to package names
+ FILE_CHANGED_PKGS=""
+ for dir in $CHANGED_DIRS; do
+ pkg=$(echo "$DIR_TO_PKG" | grep "^${dir}=" | cut -d= -f2 | head -1)
+ if [ -n "$pkg" ]; then
+ FILE_CHANGED_PKGS=$(printf '%s\n%s' "$FILE_CHANGED_PKGS" "$pkg")
+ else
+ # Fall back to directory name if no mapping found
+ FILE_CHANGED_PKGS=$(printf '%s\n%s' "$FILE_CHANGED_PKGS" "$dir")
+ fi
+ done
+ FILE_CHANGED_PKGS=$(echo "$FILE_CHANGED_PKGS" | grep -v '^$' | sort -u || true)
+
# If assets/ changed, add crates that depend on those assets
if echo "$CHANGED_FILES" | grep -qP '^assets/'; then
FILE_CHANGED_PKGS=$(printf '%s\n%s\n%s\n%s' "$FILE_CHANGED_PKGS" "settings" "storybook" "assets" | sort -u)