Add I/O function tests: 98% coverage on run.ts - #1
Merged
Conversation
Export Metric interface and run/runIngest/runPRCheck/postCheckRun for testability. Mock @actions/core, @actions/github, fs, and fetch via vi.hoisted + vi.mock + vi.stubGlobal. Tests cover all early-exit paths in run(), ingest success/failure, all threshold breach types, missing GITHUB_TOKEN, baseline fetch errors, Check Run success/failure/fork degradation, and the PR head SHA selection. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Cloudflare Access blocks all /api/* requests before the Worker sees them, so the OIDC-gated baseline endpoint was returning the Access login page (<!DOCTYPE html>) instead of JSON. The fix mirrors /ingest: mount baseline at the root level so only the Worker's own requireOidc() middleware applies. Route changes: - Extract baseline handler into src/routes/baseline.ts (OIDC-gated) - Remove baseline from src/routes/api.ts (Access-gated) - Mount at /baseline in src/index.ts alongside /ingest - Update Action fetch URL: /api/projects/:o/:r/baseline → /baseline/:o/:r - Update test assertion to match new URL Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Metric,run,runIngest,runPRCheck,postCheckRunfromrun.tsfor testability@actions/core,@actions/github,fs, andfetchwithvi.hoisted+vi.mock+vi.stubGlobalrun(), ingest success/error, all threshold breach types, missing token, baseline errors, Check Run success/failure/fork degradation, PR head SHA selectionTest plan
npm testpasses locally: 52/52 greenmin-coveragethreshold passes🤖 Generated with Claude Code