Worker unit tests, coverage floors, and an SBOM per main build #52

Merged
jared merged 3 commits from ci-sbom-worker-tests into main 2026-11-22 16:01:39 -05:00
Owner

Part of #45 (phases 3 and 4).

Worker unit tests

  • worker/worker.js now exports PulseWorker and starts only when it's run directly. Running it as a service behaves exactly as before, so CT 153 needs no redeploy.
  • tests/worker.test.js adds 7 tests with no server involved:
    • success returns stdout, stderr and duration;
    • a failure returns its exit code and output;
    • a timeout kills the command and reports timed_out with SIGTERM;
    • at capacity, the worker rejects at once instead of staying silent;
    • a slot is freed after a failure;
    • ping is answered with pong;
    • nothing is sent while disconnected.

Coverage floors

Jest now fails if coverage drops below today's levels:

  • lib/: 90% of statements and lines, 80% of branches and functions;
  • worker/: 40% (the connect and heartbeat code isn't unit-tested yet).

I checked that it works: raising the worker floor to 50% fails the run. Jest also ignores tests/ui and tests/integration explicitly.

SBOM

The audit job writes a CycloneDX 1.5 SBOM of the production dependencies (96 components) and keeps it for 90 days as the sbom-cyclonedx artifact of each main build. No job or check names change.

Locally: jest 74/74, lint has 0 errors, actionlint is clean.

🤖 Generated with Claude Code

Part of #45 (phases 3 and 4). ## Worker unit tests - `worker/worker.js` now exports `PulseWorker` and starts only when it's run directly. Running it as a service behaves exactly as before, so **CT 153 needs no redeploy**. - `tests/worker.test.js` adds 7 tests with no server involved: - success returns stdout, stderr and duration; - a failure returns its exit code and output; - a timeout kills the command and reports `timed_out` with `SIGTERM`; - at capacity, the worker rejects at once instead of staying silent; - a slot is freed after a failure; - ping is answered with pong; - nothing is sent while disconnected. ## Coverage floors Jest now fails if coverage drops below today's levels: - `lib/`: 90% of statements and lines, 80% of branches and functions; - `worker/`: 40% (the connect and heartbeat code isn't unit-tested yet). I checked that it works: raising the worker floor to 50% fails the run. Jest also ignores `tests/ui` and `tests/integration` explicitly. ## SBOM The audit job writes a CycloneDX 1.5 SBOM of the production dependencies (96 components) and keeps it for 90 days as the `sbom-cyclonedx` artifact of each `main` build. No job or check names change. Locally: jest 74/74, lint has 0 errors, actionlint is clean. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
jared added 1 commit 2026-11-22 15:28:36 -05:00
Worker unit tests, coverage floors, and an SBOM per main build
CI / Lint (eslint) (push) Successful in 17s
CI / Test (jest) (push) Successful in 18s
CI / Security (npm audit) (push) Failing after 12s
CI / Scan (secrets, workflows, shell) (push) Successful in 18s
CI / Integration (api) (push) Successful in 2m58s
CI / Lint (eslint) (pull_request) Successful in 24s
CI / Test (jest) (pull_request) Successful in 15s
CI / UI (playwright) (push) Successful in 3m11s
CI / Deploy (push) Skipped
CI / Notify (push) Skipped
CI / Security (npm audit) (pull_request) Failing after 12s
CI / Scan (secrets, workflows, shell) (pull_request) Successful in 15s
CI / Integration (api) (pull_request) Successful in 1m18s
CI / UI (playwright) (pull_request) Successful in 1m31s
CI / Deploy (pull_request) Skipped
CI / Notify (pull_request) Skipped
38a6d1158d
- worker/worker.js exports PulseWorker and starts only when run directly
  (no behaviour change for the service; CT 153 needs no redeploy).
- tests/worker.test.js: success, exit code and stderr, timeout kill,
  capacity rejection, slot release after failure, ping/pong, no sends
  while disconnected.
- jest coverage floors (ratchet at today's levels): lib/ 90% lines and
  statements, 80% branches and functions; worker/ 40%.
- The audit job writes a CycloneDX SBOM of production dependencies and
  keeps it 90 days for each main build.

Part of #45 phases 3 and 4.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jared added 1 commit 2026-11-22 15:34:57 -05:00
CI: build the SBOM from the lockfile (the audit job has no node_modules)
CI / Lint (eslint) (push) Successful in 17s
CI / Test (jest) (push) Successful in 18s
CI / Security (npm audit) (push) Successful in 12s
CI / Scan (secrets, workflows, shell) (push) Successful in 12s
CI / Integration (api) (push) Failing after 1m25s
CI / Lint (eslint) (pull_request) Successful in 31s
CI / Test (jest) (pull_request) Successful in 17s
CI / Security (npm audit) (pull_request) Successful in 18s
CI / UI (playwright) (push) Successful in 2m17s
CI / Deploy (push) Skipped
CI / Notify (push) Skipped
CI / Scan (secrets, workflows, shell) (pull_request) Successful in 14s
CI / Integration (api) (pull_request) Successful in 1m19s
CI / UI (playwright) (pull_request) Successful in 1m39s
CI / Deploy (pull_request) Skipped
CI / Notify (pull_request) Skipped
394665e88a
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jared added 1 commit 2026-11-22 15:54:40 -05:00
Integration tests: wait for a worker's WebSocket, not just its heartbeat
CI / Security (npm audit) (push) Successful in 21s
CI / Test (jest) (push) Successful in 23s
CI / Scan (secrets, workflows, shell) (push) Successful in 14s
CI / Integration (api) (push) Successful in 1m58s
CI / Lint (eslint) (pull_request) Successful in 44s
CI / UI (playwright) (push) Successful in 3m9s
CI / Test (jest) (pull_request) Successful in 42s
CI / Security (npm audit) (pull_request) Successful in 30s
CI / Scan (secrets, workflows, shell) (pull_request) Successful in 11s
CI / Integration (api) (pull_request) Successful in 1m44s
CI / Lint (eslint) (push) Successful in 13s
CI / Deploy (push) Skipped
CI / Notify (push) Skipped
CI / UI (playwright) (pull_request) Successful in 1m45s
CI / Deploy (pull_request) Skipped
CI / Notify (pull_request) Skipped
67a9e1c009
Under load a new worker's first heartbeat marked it online before its
WebSocket had connected, so a test's first command was refused, and the
cleanup in finally then threw its own error and hid the real one.
startWorker now waits until the server accepts a probe command for the
worker, and cleanup never throws (offline status has its own test).
Reproduced 1 in 6 under UI-test load before; 0 in 10 after.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jared merged commit 1474b0aa3f into main 2026-11-22 16:01:39 -05:00
jared deleted branch ci-sbom-worker-tests 2026-11-22 16:01:40 -05:00
Sign in to join this conversation.