Skip to content

ci: split the whole-tree test run into named suites - #210

Merged
nc9 merged 1 commit into
mainfrom
ci/package-test-matrix
Sep 6, 2026
Merged

nc9 merged 1 commit into
mainfrom
ci/package-test-matrix

Conversation

@nc9

@nc9 nc9 commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Refs squirrelscan/repo#1670.

The issue's premise was wrong, and that is the finding

squirrelscan/repo#1670 says "packages/* test suites never run in public-repo CI". They do, and they always have. The CLI tests job ran a bare bun test, and a bare bun test walks the whole tree, unlike bun run test (which is cd apps/cli && bun test).

Evidence from the last green run before this branch, run 33955204147, job CLI tests:

Ran 5111 tests across 400 files. [251.62s]
 5107 pass
 0 fail

Those 400 files, counted from the per-file group markers in that log:

suite files time
apps/cli 153 24.5s
packages/rules 87 2.5s
packages/audit-engine 46 143.0s
packages/crawler 43 60.9s
packages/report 30 0.2s
the other 11 packages, npm, scripts 41 20.4s

So a failure in packages/rules already failed the PR. What was missing was legibility: it happened under a job named for apps/cli, in one 400-file log, with nothing stating the arrangement or stopping it from silently changing.

What changed

Before: one step, bun test, in a job called CLI tests.

After: one step per suite in the same job, so a red step names the package. Same file set, verified below.

scripts/test-suites.ts is the single source of truth. rest is the complement of the named suites computed from the tree, not a hand-kept list, so a new package is covered the day it lands. --check runs in the quality job (first, ~20ms) and fails if:

  • a test file escapes every suite,
  • two suites would run the same file,
  • a named suite points at a package that no longer exists (a rename would otherwise leave the step running nothing while rest quietly absorbed the files),
  • ci.yml stops running a suite, runs one twice, or invents a name. Commented-out steps do not count as coverage.

Roots are handed to bun as ./<root>. A bare filter is a path substring, verified: bun test report matches 48 files across the tree, bun test scripts picks up apps/cli/scripts/ as well, and packages/report would also select a future packages/report-v2. ./scripts matches 3 files where scripts matches 4.

Acceptance criteria

  1. packages/rules, packages/crawler, packages/audit-engine run and fail the PR. They already did; now each is its own named step. Failure propagation re-verified by planting a failing test in packages/report: the step exits 1.
  2. The golden/streaming engine jobs stay separate. engine-tests and release-tooling are untouched. Both deliberately re-run files the new steps also cover, and the comment now says so, along with release.yml, which still runs its own bare whole-tree bun test.
  3. A comment in ci.yml states which suites run where. Above the job, including why the job cannot be renamed and what "every test file" means.
  4. Wall time. Unchanged: the same files, same order of magnitude, six sequential steps at ~20ms of wrapper overhead each. Steps run cheapest-first so a fast suite still reports if the slow one exhausts timeout-minutes.

The job could not be renamed

CLI tests is a required status check in this repo's ruleset (Protect main, id 19657274), alongside Format, lint, and typecheck, Audit engine golden tests and others. Renaming the job, or moving to a strategy.matrix (which renames checks to Unit tests (cli) and so on), makes the required check never report and blocks every PR until someone edits the ruleset. So the job keeps its name and the split lives in steps.

A matrix would cut this job from ~275s to ~160s of wall time, and since engine-tests already runs 179s in parallel it would take the whole workflow off this job's critical path. That is a real win, but it needs a ruleset edit landed in the same change. Happy to follow up if you want it.

Verification

Locally, per suite, file counts matching the CI table exactly:

suite result
report 325 pass, 0 fail, 30 files
rules 1609 pass, 0 fail, 87 files
rest 550 pass, 0 fail, 42 files
cli 1922 pass, 1 skip, 0 fail, 153 files, 24.7s
crawler 370 tests, 43 files
audit-engine see below
scripts/test-suites.test.ts 23 pass, 0 fail

actionlint clean, bun run format:check clean, --check green.

audit-engine was verified in two halves rather than as one run: its 29 non-golden files pass in 0.72s, and the 17 golden/streaming/deadline files are exactly what the already-green engine-tests job runs. The combined 46-file run peaks over 1.3GB, above my local test watchdog's ceiling, so CI is the arbiter for the union. It is a strict subset of the 400 files that run in one process today, so it should not be new pressure.

One thing to know: packages/crawler has a pre-existing, load-dependent flake. Running its 43 files on a loaded machine failed once in each of two runs, a different test each time (trailing-slash-canonical-crawl and seed-redirect-pinning), and passed clean on the third. Both pass in isolation. This branch touches nothing in that package, and CI has been green, but the timing-sensitive redirect tests are worth knowing about. Filed separately.

The `CLI tests` job ran a bare `bun test`, which walks the whole tree:
run 33955204147 logged "Ran 5111 tests across 400 files", including 87
files in packages/rules, 46 in packages/audit-engine and 43 in
packages/crawler. packages/* already gated every PR, invisibly, under a
job named for apps/cli.

Split that one command into a step per suite so a red step names the
package, and add scripts/test-suites.ts as the single source of truth
for the split. `rest` is the complement of the named suites, computed
from the tree, so a new package is covered the day it lands. `--check`
runs in the quality job and fails if a test file escapes every suite, if
two suites would run the same file, if a named suite points at a package
that no longer exists, or if ci.yml stops running one of them.

Roots are passed as `./<root>`: a bare `bun test` filter is a path
SUBSTRING, so `scripts` also selects apps/cli/scripts/ and
`packages/report` also selects a future packages/report-v2.

The job keeps the name `CLI tests` because that exact string is a
required status check in the repo ruleset. Renaming it, or moving to a
matrix, renames the check and blocks every PR until the ruleset changes.

Sequential steps leave the 251.6s total unchanged, cheapest suite first.

Refs squirrelscan/repo#1670

Signed-off-by: Nik Cubrilovic <[email protected]>
@nc9
nc9 force-pushed the ci/package-test-matrix branch from f24c56a to ddf200b Compare September 6, 2026 03:11
@nc9
nc9 merged commit c421a64 into main Sep 6, 2026
13 checks passed
@nc9
nc9 deleted the ci/package-test-matrix branch September 6, 2026 03:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant