Skip to content

Commit 997ce34

Browse files
andimarekclaude
andcommitted
Fail PR if code coverage drops vs master baseline
Add a coverage gate in the test-summary job that checks line, branch, and method coverage against the master baseline. The PR comment is posted first so developers always see the report, then core.setFailed() is called if any metric decreased. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent b2a6a70 commit 997ce34

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

.github/workflows/pull_request.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,27 @@ jobs:
363363
body,
364364
});
365365
}
366+
367+
// --- Coverage gate: fail if any metric drops ---
368+
if (covLine || covBranch || covMethod) {
369+
const drops = [];
370+
for (const { name, curr, baseKey } of [
371+
{ name: 'Line', curr: covLine, baseKey: 'line' },
372+
{ name: 'Branch', curr: covBranch, baseKey: 'branch' },
373+
{ name: 'Method', curr: covMethod, baseKey: 'method' },
374+
]) {
375+
if (!curr) continue;
376+
const b = baseCov[baseKey] || zeroCov;
377+
const currPct = pct(curr.covered, curr.missed);
378+
const basePct = pct(b.covered, b.missed);
379+
if (currPct < basePct - 0.05) {
380+
drops.push(`${name}: ${currPct.toFixed(1)}% (was ${basePct.toFixed(1)}%, delta ${(currPct - basePct).toFixed(1)}%)`);
381+
}
382+
}
383+
if (drops.length > 0) {
384+
core.setFailed(`Coverage decreased:\n${drops.join('\n')}`);
385+
}
386+
}
366387
javadoc:
367388
runs-on: ubuntu-latest
368389
steps:

0 commit comments

Comments
 (0)