Skip to content

Backend test coverage: CI ingestion, webhooks, badges, admin, scheduled rollup - #53

Merged
tbjers merged 2 commits into
mainfrom
ci/backend-coverage-in-ci
Jul 6, 2026
Merged

Backend test coverage: CI ingestion, webhooks, badges, admin, scheduled rollup#53
tbjers merged 2 commits into
mainfrom
ci/backend-coverage-in-ci

Conversation

@tbjers

@tbjers tbjers commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds a CI job that runs the Worker vitest suite with Istanbul coverage and reports coverage/lcov.info to the coverage-tracker Worker itself (already on this branch).
  • Raises backend test coverage from ~21% to ~88% lines by testing the areas that had none: CI coverage ingestion (/api/ci/coverage), the GitHub webhook handler, the badge endpoint, the admin API, and the scheduled cron rollup — plus the OIDC/webhook-HMAC middleware gating them and supporting lib/ helpers.
  • Adds test/helpers/ (signed OIDC tokens via a keypair generated fresh per test run, HMAC signing, and a fake GitHub REST API wired up through Miniflare's outboundService) so tests can exercise real auth success paths and GitHub API calls instead of only asserting "missing credential → 401".
File Before After
routes/ci.ts 14% 100%
routes/webhooks.ts 4% 96%
routes/badge.ts 8% 100%
routes/admin.ts 12% 100%
routes/api.ts 43% 100%
middleware/webhook.ts 4% 100%
middleware/oidc.ts 21% 100%
lib/github.ts 7% 100%
lib/resync.ts 0% 93%
lib/db.ts 33% 94%
index.ts scheduled() untested 100%

Not touched (out of scope): routes/baseline.ts, middleware/access.ts — admin/api tests use the existing ENVIRONMENT=development dev-bypass instead of a full Access-JWT test harness.

Test plan

  • npm test — 91 tests passing across 13 files
  • npm run typecheck — clean
  • npm run test:coverage — 87.78% lines / 85.3% statements / 77.77% branches / 89.65% functions overall

🤖 Generated with Claude Code

tbjers and others added 2 commits July 6, 2026 17:27
Add a backend-coverage job to ci.yml that runs the Worker vitest suite with Istanbul coverage (v8 is unsupported under vitest-pool-workers) and reports coverage/lcov.info to the coverage-tracker Worker via the report Action. Broaden the workflow path filter to backend files and scope the OIDC/checks-write permissions to the new job only. Drop the copied Python coverage.yml example.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…rollup

Backend test coverage was ~21% and never exercised auth success paths,
GitHub API calls, or the cron entry point beyond direct calls to
rollupAndPrune(). Adds a test/helpers layer (signed OIDC tokens, HMAC
signing, and a fake GitHub REST API wired up via Miniflare's
outboundService, since fetchMock isn't exported by the installed
vitest-pool-workers version) and route/middleware/lib tests built on it,
bringing coverage to ~88% lines with ci.ts, badge.ts, admin.ts,
webhook.ts, and oidc.ts at or near 100%.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@tbjers
tbjers merged commit 714b8ca into main Jul 6, 2026
7 checks passed
@tbjers
tbjers deleted the ci/backend-coverage-in-ci branch July 6, 2026 23:03
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