Skip to content

build: skip packages without a test directory - #15591

Merged
kgryte merged 3 commits into
developfrom
philipp/ci-fix-test-coverage-no-tests-dir-2026-09-27
Sep 27, 2026
Merged

kgryte merged 3 commits into
developfrom
philipp/ci-fix-test-coverage-no-tests-dir-2026-09-27

Conversation

@Planeshifter

Copy link
Copy Markdown
Member

Description

What is the purpose of this pull request?

This pull request:

  • Fixes the run_tests_coverage workflow so it does not fail when a changed package has no test/ directory.

The run_tests_coverage workflow fails on develop at commit a8b875b ("chore: clean-up", #15566): https://github.com/stdlib-js/stdlib/actions/runs/36269983327, job "Calculate test coverage for packages". make[1]: *** [tools/make/lib/test-cov/c8.mk:89: test-c8] Error 1, zero test output printed.

.github/workflows/scripts/run_tests_coverage/run derives one "package directory" per changed file. The triggering commit touched repl/lib/commands/load.js and several repl/presentation/lib/commands/*.js files. @stdlib/repl and @stdlib/repl/presentation are separate packages, each with its own package.json; @stdlib/repl/presentation has no test/ directory at all. The script ran make test-javascript-cov TESTS_FILTER=".*/${pkg}/test/.*" unconditionally for every derived package. With a filter matching zero files, test-cov/c8.mk's test-c8 rule pipes find | grep '^[\/]...' | while read -r test; do ...; under this repo's .SHELLFLAGS := -eu -o pipefail -c, grep finding nothing exits 1 and kills the recipe before any test runs.

Fix: skip any derived package directory lacking a test/ directory before invoking make, emitting an ::warning:: annotation naming the skipped package. Two knock-on changes were needed so "every changed package skipped" doesn't just fail one step later:

  • artifacts/ is now created lazily, per package, instead of unconditionally up front. An unconditional empty artifacts/ dir would make the later "Copy artifacts to the repository" step's cp -R ./artifacts/* fail on no matches.
  • The Markdown coverage table is only built when at least one package produced coverage. An all-skipped run now falls through to the workflow's existing "No coverage information available." message instead of emitting a header-only table.

1 file changed: .github/workflows/scripts/run_tests_coverage/run, +14/-5. The three hunks are dependent, not independent fixes.

Related Issues

Does this pull request have any related issues?

This pull request has no related issues.

Questions

Any questions for reviewers of this pull request?

No.

Other

Any other information relevant to this pull request? This may include screenshots, references, and/or implementation notes.

Validated by reproducing the directory-derivation logic against the failing commit's changed-file list in a local shell simulation: confirms repl is tested and repl/presentation is skipped. Separately simulated the all-packages-skipped path end to end, including the downstream if [ -d ./artifacts ] check in run_tests_coverage.yml: no failure. bash -n syntax check passes.

Reviewed across two rounds by three independent automated reviewers (correctness, regression scope, style/conventions). Round 1 flagged the all-skipped-artifacts gap; fixed, and round 2 approved unanimously.

Known limitation, not addressed here: this guards only a completely absent test/ directory, not one that exists but is empty. Flagged by reviewers as non-blocking.

Checklist

Please ensure the following tasks are completed before submitting this pull request.

AI Assistance

When authoring the changes proposed in this PR, did you use any kind of AI assistance?

  • Yes
  • No

If you answered "yes" above, how did you use AI assistance?

  • Code generation (e.g., when writing an implementation or fixing a bug)
  • Test/benchmark generation
  • Documentation (including examples)
  • Research and understanding

Disclosure

If you answered "yes" to using AI assistance, please provide a short disclosure indicating how you used AI assistance. This helps reviewers determine how much scrutiny to apply when reviewing your contribution. Example disclosures: "This PR was written primarily by Claude Code." or "I consulted ChatGPT to understand the codebase, but the proposed changes were fully authored manually by myself.".

This PR was investigated, written, and validated by an automated Claude Code CI-monitoring routine, including root-cause investigation and two rounds of independent multi-reviewer validation of the fix.


@stdlib-js/reviewers

🤖 Generated with Claude Code

https://claude.ai/code/session_01Ch53UGBgsUodCvqUP9zcHz


Generated by Claude Code

The job `Calculate test coverage for packages` failed on develop for
a commit touching `repl/lib/commands/load.js` and
`repl/presentation/lib/commands/*.js`.

Root cause: the script derives one package directory per changed
file. `@stdlib/repl` and `@stdlib/repl/presentation` are distinct
packages, and the latter has no `test/` directory. The script then
unconditionally runs `make test-javascript-cov
TESTS_FILTER=".*/${pkg}/test/.*"` for every derived package. With
zero matching test files, `tools/make/lib/test-cov/c8.mk`'s `test-c8`
rule pipes `find | grep ... | while read`, and under this repo's
`.SHELLFLAGS := -eu -o pipefail -c`, a zero-match `grep` (exit 1)
fails the whole recipe immediately, with no test output.

This commit skips any derived package directory lacking a `test/`
directory before invoking `make`, and adjusts the two places that
assumed at least one package was always tested: the coverage
artifacts directory is now created lazily per package (so it is never
left behind, empty, when every changed package is skipped) and the
Markdown coverage table is only built when at least one package
produced coverage output, so an all-skipped run falls back to the
workflow's existing "No coverage information available." message
instead of a header-only table.

Ref: https://github.com/stdlib-js/stdlib/actions/runs/36269983327

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ch53UGBgsUodCvqUP9zcHz
@stdlib-bot stdlib-bot added the Good First PR A pull request resolving a Good First Issue. label Sep 27, 2026
Comment thread .github/workflows/scripts/run_tests_coverage/run Outdated
Comment thread .github/workflows/scripts/run_tests_coverage/run Outdated
Applies @kgryte's review suggestion: drop the "e.g., presentation-only
sub-packages" aside, since the guard applies to any package lacking a
test directory, not just presentation sub-packages.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ch53UGBgsUodCvqUP9zcHz
Applies @kgryte's review suggestion: replace the GitHub Actions
`::warning::` workflow command with a plain "WARNING: ..." message,
matching this script's existing diagnostic-echo convention (see the
"No packages to test." and "ERROR: ..." messages), and redirect to
stderr like every other diagnostic echo in the file. `::warning::`
is GitHub Actions-specific syntax that would print literally if this
script were ever run outside Actions.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ch53UGBgsUodCvqUP9zcHz
@kgryte
kgryte marked this pull request as ready for review September 27, 2026 22:07
@kgryte
kgryte requested a review from a team September 27, 2026 22:07
@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label Sep 27, 2026
@kgryte kgryte changed the title build(workflows): skip test-less packages in run_tests_coverage build: skip packages without a test directory Sep 27, 2026
@kgryte
kgryte merged commit 1e56ff8 into develop Sep 27, 2026
27 checks passed
@kgryte
kgryte deleted the philipp/ci-fix-test-coverage-no-tests-dir-2026-09-27 branch September 27, 2026 22:08
@kgryte kgryte added Tools Issue or pull request related to project tooling. CI Issue or pull request specific to continuous integration environments. and removed Needs Review A pull request which needs code review. labels Sep 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI Issue or pull request specific to continuous integration environments. Good First PR A pull request resolving a Good First Issue. Tools Issue or pull request related to project tooling.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants