Skip to content

Commit 45bb989

Browse files
committed
build: skip dependency fan-out when only test fixtures change
When all changed files reside in test/fixtures/ directories, skip the expensive dependency fan-out step in the affected-tests workflow. Changes to test fixtures cannot affect downstream packages, so searching for and testing all dependents is unnecessary and causes CI timeouts when many packages are modified at once. This also reverts the namespace CLI test exclusion from the previous commit, as the fixture-only check addresses the root cause. Assisted-by: Claude Opus 4.6 <noreply@anthropic.com> --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: missing_dependencies - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent f346a09 commit 45bb989

1 file changed

Lines changed: 23 additions & 19 deletions

File tree

  • .github/workflows/scripts/run_affected_tests

.github/workflows/scripts/run_affected_tests/run

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -122,23 +122,30 @@ main() {
122122
# Extract package names from changed package directories (e.g., @stdlib/math/base/special/sin) by removing the leading 'lib/node_modules/':
123123
packages=$(echo "${directories}" | sed -E 's/^lib\/node_modules\///')
124124

125-
# Find all package directories which `require()` one of the changed packages:
126-
required_by=""
127-
for package in ${packages}; do
128-
echo "Finding packages which depend on '${package}'..."
129-
escaped_package=$(echo "$package" | sed 's/[\/&]/\\&/g')
130-
dependents=$(find lib/node_modules/@stdlib -type f -name '*.js' -exec grep -ol -E "require\( [']${escaped_package}['] \)" {} +) || true
131-
echo "Found: ${dependents}"
132-
if [ -n "${dependents}" ]; then
133-
dependents=$(dirname $dependents | sed -E 's/\/(benchmark|bin|data|docs|etc|examples|include|lib|scripts|src|test)(\/.*)?$//' | sort -u)
134-
echo "List of dependents: ${dependents}"
135-
required_by="${required_by} ${dependents}"
125+
# Determine whether any non-fixture files changed. If only test fixtures were modified, skip dependency fan-out since downstream packages cannot be affected:
126+
non_fixture_files=$(echo "${changed}" | tr ' ' '\n' | grep -v '/test/fixtures/') || true
127+
128+
if [ -n "${non_fixture_files}" ]; then
129+
# Find all package directories which `require()` one of the changed packages:
130+
required_by=""
131+
for package in ${packages}; do
132+
echo "Finding packages which depend on '${package}'..."
133+
escaped_package=$(echo "$package" | sed 's/[\/&]/\\&/g')
134+
dependents=$(find lib/node_modules/@stdlib -type f -name '*.js' -exec grep -ol -E "require\( [']${escaped_package}['] \)" {} +) || true
135+
echo "Found: ${dependents}"
136+
if [ -n "${dependents}" ]; then
137+
dependents=$(dirname $dependents | sed -E 's/\/(benchmark|bin|data|docs|etc|examples|include|lib|scripts|src|test)(\/.*)?$//' | sort -u)
138+
echo "List of dependents: ${dependents}"
139+
required_by="${required_by} ${dependents}"
140+
fi
141+
done
142+
143+
# Concatenate the list of changed package directories and package directories which `require()` one of the changed packages:
144+
if [ -n "${required_by}" ]; then
145+
directories="${directories} ${required_by}"
136146
fi
137-
done
138-
139-
# Concatenate the list of changed package directories and package directories which `require()` one of the changed packages:
140-
if [ -n "${required_by}" ]; then
141-
directories="${directories} ${required_by}"
147+
else
148+
echo 'Only test fixture files changed. Skipping dependency fan-out.' >&2
142149
fi
143150

144151
# Build native add-ons for packages (if applicable):
@@ -164,9 +171,6 @@ main() {
164171
# Exclude files residing in test fixtures directories:
165172
files=$(echo "${files}" | grep -v '/fixtures/') || true
166173

167-
# Exclude the namespace CLI test, as it spawns child processes that dump the entire namespace and is too slow for affected-test runs:
168-
files=$(echo "${files}" | tr ' ' '\n' | grep -v '@stdlib/namespace/test/test.cli.js' | tr '\n' ' ') || true
169-
170174
if [[ -n "${files}" ]]; then
171175
# Invoke make in batches to avoid "Argument list too long" errors:
172176
printf '%s\n' ${files} | xargs sh -c 'make test-javascript-files-min FILES="$*"' _

0 commit comments

Comments
 (0)