Repository navigation
Description
Chore Type
CI / Build change
Description
The BATS suite is the single largest contributor to CI wall-clock time, and
Project Checks is the only job on the critical path.
Measured on run 36052799861's
predecessor 36050981328
(Project Checks, job 107806145241):
| Step | Duration |
|---|---|
| setup-env (nix dev-shell) | 46s |
| prek linters | 25s |
bats tests/bats/ |
6m 14s |
| pytest + coverage | 1m 25s |
| 6 nix/flake steps | 2m 40s |
| job total | 11m 28s |
The whole run is 11m 35s; every other job (Security Scan, Image Tests,
Integration Tests) finishes by 19:58, five minutes before Project Checks.
So BATS is ~54% of the long pole and ~50% of end-to-end CI.
Within BATS the cost is one file:
| File | Tests | CI time | Share |
|---|---|---|---|
init-workspace.bats |
300 | 291.9s | 79.6% |
install.bats |
95 | 21.2s | 5.8% |
just.bats |
58 | 10.8s | 2.9% |
release-mirror-fold.bats |
11 | 10.2s | 2.8% |
| other 17 files | 136 | 32.6s | 8.9% |
No slow individual test — 300 tests at ~1s each, because they make ~274 full
invocations of assets/init-workspace.sh (114 tests invoke it 0x, 111 once,
63 twice, 12 three or more).
Three independent levers, measured locally on 8 cores. WP1 and WP2 are
behaviour-preserving and touch no test semantics; WP3 is a test refactor.
Acceptance Criteria
WP1 — run BATS in parallel
-
parallel(GNU parallel) added tonix/devtools.nix(or to thebatswrapper innix/bats.nix), sobats --jobsresolves wherever the flake toolchain is delivered -
.github/actions/test-project/action.ymlrunsbats -j "$(nproc)" tests/bats/instead of a barebats tests/bats/ -
just test-batsdrops the per-fileparallelbranch in favour ofbats -j - Full suite green under
-jin CI (600/600)
WP2 — batch the two per-file fork loops in assets/init-workspace.sh
-
sweep_scaffold_writablecollects its targets and issues one batchedchmod u+winstead of one fork per file - The placeholder-substitution fallback uses a single
grep -rlZ ... | xargs -0 sed -iinstead of a per-filegrep -q+sed -iloop - A scaffold rendered by the new script is byte-identical to the old one, permissions included (
diff -r+find -printf '%m %p'both clean) -
shellcheck -x assets/init-workspace.shclean;just precommitgreen -
init-workspace.bats300/300 green against the changed script
WP3 — stop re-rendering trees an earlier test already built
- A
_clone_shared <mode> <ws>helper (or equivalent) copies asetup_file-rendered tree instead of re-running the script, for tests whose setup is a stock scaffold - The identical-setup groups below are collapsed onto it
-
init-workspace.bats300/300 green, and the number ofinit-workspace.shinvocations per full-file run drops measurably (record before/after)
Cross-cutting
- CI
Project Checksjob time recorded before/after in the PR body - No test deleted or weakened — this issue is about runtime, not coverage
Implementation Notes
WP1. .github/actions/test-project/action.yml runs a bare bats tests/bats/
— no --jobs. just test-bats tries to parallelize, but with GNU parallel
one file per job, and parallel is not in nix/devtools.nix, so the
command -v parallel check always falls through to the sequential branch.
Even if it didn't, file-level parallelism is the wrong axis: 80% of the time is
inside a single file. bats -j parallelizes within files.
bats tests/bats/init-workspace.bats 10m 09s
bats -j 8 tests/bats/init-workspace.bats 2m 01s 300/300 pass
bats -j 8 tests/bats/ 3m 00s 600/600 pass, exit 0
Parallel-safety was checked before measuring: every test writes only into
BATS_TEST_TMPDIR/BATS_FILE_TMPDIR, the only $PROJECT_ROOT touches are
reads, and all podman/gh/just interaction is stubbed. The setup_file shared
trees from #1417 still render once per file.
The runner is a 4-vCPU ubuntu-26.04, so expect ~2.5-3x there rather than the
5x measured on 8 cores.
WP2. Profiling one init-workspace.sh --mode both run (4,353 traced
commands, 1.74s total):
| Line | What | Share |
|---|---|---|
| 3479 | grep -q per file, placeholder fallback |
42% |
| 3200 | chmod u+w per file in sweep_scaffold_writable |
23% |
| 3175 | the actual rsync |
4% |
Both are one fork per file across a 163-file tree. Batching both:
per invocation 1770ms -> 604ms (-66%)
init-workspace.bats, -j 8 2m 01s -> 1m 16s
sequential (CPU time) 10m 14s -> 5m 38s
A prototype diff is 10 lines; rendered trees came out byte-identical and all
300 tests passed against it.
Two things worth knowing about the grep loop:
- It is the fallback branch. The fast
.placeholder-manifest.txtpath
exists only inside the image (perf: bake the build-time placeholder manifest into the Nix image #718/perf(image): bake the build-time placeholder manifest into the Nix image #802 bakes it at/root/assets/, and the
path translation hardcodes/root/assets/workspace). Real consumers go
throughinstall.sh, which runs the script in the container, so they get
the fast path. The fallback is effectively a test-only code path — which also
means the BATS suite never covers the substitution path consumers actually
run; onlytest_image.py::test_placeholder_manifest_bakeddoes. - The "fast" manifest path forks one
sed -iper manifest entry. Measured:
117 per-filesed -i= ~2.6s vs ~0.15s batched, ~15-20x slower. A single
grep -rlZ ... | xargs -0 sed -i— exactly whatflake.nix:1476already
uses to build the manifest — beats the manifest path outright. Worth
considering as a follow-up: retiring the manifest, its flake build step, its
image test and the host/image divergence in favour of one SSoT code path
that is faster than both. Out of scope here; file separately if wanted.
sweep_scaffold_writable is on the production path too, so batching it is a
small consumer-side win as well.
WP3. Grouping the 300 tests by byte-identical setup prefix:
| Tests | Identical setup | Redundant runs |
|---|---|---|
| 63 | mkdir -p "$ws"; _scaffold both "$ws" |
62 |
| 11 | _scaffold direnv "$ws" |
10 |
| 9 | seed package.json; _scaffold both |
8 |
| 8 | _upgrade both "$ws" |
7 |
| 5 | _scaffold_ex both "$ws" --workflow trunk |
4 |
| 11 more groups | 20 | |
| 111 of ~274 (40%) |
_shared_tree from #1417 exists but is used by only 14 of 300 tests. The
63-test group renders exactly what setup_file already builds as
_shared_tree both, then mutates it — so it cannot reuse the tree directly,
but it can copy it: cp -a of the scaffold tree is 36ms vs 1770ms, and
the render is path-independent (.vig-os carries no absolute path; two renders
into different directories diff clean).
Note on TDD: WP1 and WP2 are behaviour-preserving changes with no natural
failing test — the regression net is the existing 600 tests plus the
byte-identical tree/permission diff. WP3 is a test-internal refactor. Any
structural pin added (e.g. asserting the batched form) should be red-first.
Related Issues
- Follows [CHORE] Test-suite runtime: shared scaffold fixtures and consolidated nix invocations #1417 (test-suite runtime: shared scaffold fixtures) and [REFACTOR] Prune and simplify the test suite: remove cannot-fail and duplicate tests, consolidate accreted clusters #1413 (test-suite pruning).
init-workspace.batshas grown 238 -> 300 tests since, as [FEATURE] Refs policy: exempt a named set of commit types, not just the literalchore#1633/[BUG] Clearing a scaffold knob leaves the previous render in the preserved .pre-commit-config.yaml #1640/[BUG] Switching trunk -> gitflow leaves the dev-branch guard stripped from the preserved .pre-commit-config.yaml #1642/Scaffold ships Apache-2.0 LICENSE + a CHANGELOG that re-appear on every upgrade — no opt-out for private/release-less consumers #1651/[FEATURE] Release-disabled consumers keep release-only just recipes that assume a CHANGELOG #1656/[FEATURE] Ship actionlint to consumers: the workflow-lint hook plus a managed actionlint.yaml config #1660 each added a scaffold-per-test cluster — WP3 is the same copy-paste accretion regrown. - Touches the manifest fast path from perf: bake the build-time placeholder manifest into the Nix image #718/perf(image): bake the build-time placeholder manifest into the Nix image #802 (see WP2 notes).
Priority
Medium
Changelog Category
Changed
Additional Context
Content health of the suite was checked while measuring and is good — no action
needed, recorded here so it is not re-derived:
- No duplicate test bodies. The one exact-body match
(select-ghcr-prune-targetsvsselect-rc-draft-releases) is a false
positive: different$SCRIPT. - No dead pins. Every
$TEMPLATE_DIR/$PROJECT_ROOTpath referenced
either exists or is a deliberate negative assertion. - 36 tombstone tests ("requirements.yaml has been retired", "init.sh no
longer installs packages via apt/brew/dnf/apk", "devc-upgrade recipe is
gone"). Legitimate regression guards costing ~0 runtime;init.bats's five
requirements.yamltombstones are the most archaeological. - 86 negative greps (
run grep ...+assert_failure) pass vacuously if
the target file is renamed or deleted. Most have a positive pin elsewhere; a
few (e.g.consumer-doctor.bats:82onjustfile.project) do not. Low
severity, zero runtime cost. - No file declares
bats_require_minimum_version, so every run emits
BW02warnings about flags onrun. Cosmetic; one line per file if someone
wants the noise gone.
Expected outcome of WP1+WP2: CI BATS from 6m 14s to roughly 45-70s,
Project Checks from 11m 28s to ~5m 45s, total CI from 11m 35s to ~6m — at
which point Security Scan becomes the co-bottleneck and further BATS work stops
paying.
Activity
test(ci): pin the parallel BATS invocation in recipe and CI action
build(nix): ship GNU parallel with the bats wrapper
ci: run the BATS suite with bats --jobs
test(ci): serialize the worktree tmux tests under bats --jobs
perf(init): batch the scaffold chmod and placeholder passes
test(init): add a _clone_shared helper and three seeded scaffold fixt…
test(init): clone the shared per-mode fixtures instead of re-scaffolding
test(init): clone the node, python and trunk fixtures instead of re-s…
docs(changelog): record the BATS runtime work
chore(ci): cut the BATS suite runtime (#1690)
fix(init): scope placeholder substitution to the paths devkit ships (#…
test(bats): drive worktree.bats against a fixture repo
test(bats): render the shared init-workspace fixtures concurrently
docs(changelog): correct the worktree.bats note
test(bats): isolate worktree.bats and tighten the BATS suite (#1709)
c-vigo commentedon Sep 25, 2026
Solved in #1690 (merged to
dev2026-09-25, 77e1895):bats -jvia GNU parallel riding in the bats wrapper, batchedinit-workspace.shfork loops,_clone_sharedfixtures. CI: BATS step 6m14s → 3m11s,Project Checks11m28s → 9m59s (run 36108278820). Every follow-up it predicted has since shipped todevand closed: #1692 (#1702), #1693 (#1707), #1694/#1695/#1696/#1697 (#1709). Remaining spin-offs are tracked separately: #1699, #1700, #1701, #1703, #1704.docs(changelog): record the perl-free bats parallel runner
fix(nix): run bats --jobs on rush instead of GNU parallel (#1711)
chore: release 1.17.0 (#1734)