Skip to content

Commit 069d64a

Browse files
andimarekclaude
andcommitted
Fix coverage gate to check per-class regressions, not just overall
The previous gate only checked overall line/branch/method coverage, which allowed per-class regressions to pass when offset by improvements elsewhere. Now fails on any class regressing any metric by >0.05%. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 1e316ed commit 069d64a

File tree

1 file changed

+11
-16
lines changed

1 file changed

+11
-16
lines changed

.github/workflows/pull_request.yml

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -391,25 +391,20 @@ jobs:
391391
});
392392
}
393393
394-
// --- Coverage gate: fail if any metric drops ---
395-
if (covLine || covBranch || covMethod) {
396-
const drops = [];
397-
for (const { name, curr, baseKey } of [
398-
{ name: 'Line', curr: covLine, baseKey: 'line' },
399-
{ name: 'Branch', curr: covBranch, baseKey: 'branch' },
400-
{ name: 'Method', curr: covMethod, baseKey: 'method' },
401-
]) {
402-
if (!curr) continue;
403-
const b = baseCov[baseKey] || zeroCov;
404-
const currPct = pct(curr.covered, curr.missed);
405-
const basePct = pct(b.covered, b.missed);
394+
// --- Coverage gate: fail if any class regresses on any metric ---
395+
const regressions = [];
396+
for (const [cls, curr] of Object.entries(classCounters)) {
397+
const base = baseClasses[cls] || { line: zeroCov, branch: zeroCov, method: zeroCov };
398+
for (const [metric, key] of [['Line', 'line'], ['Branch', 'branch'], ['Method', 'method']]) {
399+
const currPct = pct(curr[key].covered, curr[key].missed);
400+
const basePct = pct(base[key].covered, base[key].missed);
406401
if (currPct < basePct - 0.05) {
407-
drops.push(`${name}: ${currPct.toFixed(1)}% (was ${basePct.toFixed(1)}%, delta ${(currPct - basePct).toFixed(1)}%)`);
402+
regressions.push(` ${cls} ${metric}: ${currPct.toFixed(1)}% (was ${basePct.toFixed(1)}%, delta ${(currPct - basePct).toFixed(1)}%)`);
408403
}
409404
}
410-
if (drops.length > 0) {
411-
core.setFailed(`Coverage decreased:\n${drops.join('\n')}`);
412-
}
405+
}
406+
if (regressions.length > 0) {
407+
core.setFailed(`Per-class coverage regressions detected:\n${regressions.join('\n')}\n\nUpdate test-baseline.json if these changes are intentional.`);
413408
}
414409
javadoc:
415410
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)