Skip to content

Commit 6ff2a9a

Browse files
tbjersclaude
andauthored
Add I/O function tests: 98% coverage on run.ts (#1)
* Add I/O function tests: 52 tests, 98% statement coverage 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> * Move /baseline out of Access-gated /api prefix 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> --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent bddd4f1 commit 6ff2a9a

6 files changed

Lines changed: 395 additions & 75 deletions

File tree

‎.github/actions/report/dist/run.js‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19656,6 +19656,10 @@ __export(run_exports, {
1965619656
formatDelta: () => formatDelta,
1965719657
formatValue: () => formatValue,
1965819658
parseThreshold: () => parseThreshold,
19659+
postCheckRun: () => postCheckRun,
19660+
run: () => run,
19661+
runIngest: () => runIngest,
19662+
runPRCheck: () => runPRCheck,
1965919663
thresholdConfigured: () => thresholdConfigured
1966019664
});
1966119665
module.exports = __toCommonJS(run_exports);
@@ -24752,7 +24756,7 @@ async function runPRCheck(workerUrl, oidcToken, metrics, owner, repo) {
2475224756
const maxDuplication = parseThreshold(process.env.MAX_DUPLICATION);
2475324757
const baselines = {};
2475424758
for (const m of metrics) {
24755-
const url = `${workerUrl}/api/projects/${owner}/${repo}/baseline?metric=${encodeURIComponent(m.name)}`;
24759+
const url = `${workerUrl}/baseline/${owner}/${repo}?metric=${encodeURIComponent(m.name)}`;
2475624760
const res = await fetch(url, { headers: { Authorization: `Bearer ${oidcToken}` } });
2475724761
if (res.ok) {
2475824762
const data = await res.json();
@@ -24873,6 +24877,10 @@ if (require.main === module) {
2487324877
formatDelta,
2487424878
formatValue,
2487524879
parseThreshold,
24880+
postCheckRun,
24881+
run,
24882+
runIngest,
24883+
runPRCheck,
2487624884
thresholdConfigured
2487724885
});
2487824886
/*! Bundled license information:

0 commit comments

Comments
 (0)