Repository navigation
[quality] scripts/run-sync-step.ts: prebuild CLI entry (argv guard, usage exit 2, exit-code propagation) is untested — 61.5% lines #242
Description
Finding
scripts/run-sync-step.ts — the prebuild gate introduced in #240 that decides whether a failed content sync fails the build — is only 61.5% line-covered. The uncovered lines (37–42) are the CLI entry block, i.e. the only code path npm run prebuild actually executes:
- the
process.argv[1]?.endsWith("run-sync-step.ts")guard, - the missing-argument usage message +
process.exit(2), process.exit(runSyncStep(script))propagating the child's status.
The existing scripts/run-sync-step.test.ts exercises only the exported helpers through an injected fake spawnSync, and never asserts the real spawn invocation (tsx, [script], stdio: "inherit", env). A regression that, say, dropped stdio: "inherit" or swallowed the exit code in the entry block would pass today's suite and only surface as a silent/stale production build — exactly the failure mode #240 was fixing.
Evidence (unit): npx vitest run --coverage at 1ac3d50 (2026-10-06T03:13Z, local run; CI vitest.yml uploads the same lcov as artifact coverage-report):
run-sync-step.ts | 61.53 | 76.92 | 100 | 61.53 | 37-42
The repository has no separate end-to-end suite, so this is a unit-only finding.
Recommendation
Add scripts/run-sync-step.main.test.ts that drives the entry block in process (set process.argv, stub process.exit, vi.mock("node:child_process"), vi.resetModules() + dynamic import) — the same pattern already used by scripts/check-internal-links.main.test.ts so v8 attributes coverage to the script itself. Cases:
- import as library (argv[1] ≠ run-sync-step.ts) → no spawn, no exit
- no script argument → usage on stderr, exit 2
- success → spawns
tsx <script>withstdio: "inherit",env: process.env, exit 0 - child exit 3 → exit 3 (build fails)
- child killed (status
null) → exit 1 -
DOCS_SYNC_OPTIONAL=1+ failure → exit 0 with the warning text -
DOCS_SYNC_OPTIONAL=true(not"1") still fails
Result with the test: run-sync-step.ts 100/100/100/100; full suite 89 files / 865 tests green.
Priority
- Impact: medium (build-gating script; a regression ships stale docs silently)
- Effort: low
Filed by quality agent (ACMM L4/L6 — full mode)
🐝 Hive Agent: quality | Instance: hosted-available-oke-11-placeholder-r05x | SHA: 1ac3d50
— hive: agent=quality backend=copilot model=claude-fable-5.1 copilot=1.0.88
Activity