Skip to content

Commit 0436b4e

Browse files
committed
fix(ci): align coverage thresholds with jest.config.js
- Set individual thresholds per metric (branches: 33%, lines: 38%, statements: 39%, functions: 39%) - Update PR comment to show individual thresholds per metric - Fixes CI failure where branches coverage (34.54%) was incorrectly compared against 39% threshold
1 parent 0d677da commit 0436b4e

File tree

1 file changed

+28
-24
lines changed

1 file changed

+28
-24
lines changed

.github/workflows/ci.yml

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -385,40 +385,45 @@ jobs:
385385
BRANCHES_PCT=$(node -e "const coverage = require('./coverage/coverage-summary.json'); console.log(coverage.total.branches.pct);")
386386
FUNCTIONS_PCT=$(node -e "const coverage = require('./coverage/coverage-summary.json'); console.log(coverage.total.functions.pct);")
387387
388-
# Set minimum threshold to 39% (Phase 1.5 achieved after comprehensive testing)
389-
MIN_THRESHOLD=39
388+
# Set minimum thresholds (matching jest.config.js)
389+
MIN_BRANCHES=33
390+
MIN_LINES=38
391+
MIN_STATEMENTS=39
392+
MIN_FUNCTIONS=39
390393
391394
echo "📊 Coverage Report:"
392-
echo " Lines: ${LINES_PCT}%"
393-
echo " Statements: ${STATEMENTS_PCT}%"
394-
echo " Branches: ${BRANCHES_PCT}%"
395-
echo " Functions: ${FUNCTIONS_PCT}%"
395+
echo " Lines: ${LINES_PCT}% (threshold: ${MIN_LINES}%)"
396+
echo " Statements: ${STATEMENTS_PCT}% (threshold: ${MIN_STATEMENTS}%)"
397+
echo " Branches: ${BRANCHES_PCT}% (threshold: ${MIN_BRANCHES}%)"
398+
echo " Functions: ${FUNCTIONS_PCT}% (threshold: ${MIN_FUNCTIONS}%)"
396399
echo ""
397-
echo "Minimum threshold: ${MIN_THRESHOLD}%"
398400
399401
# Save to output for PR comment
400402
echo "lines_pct=$LINES_PCT" >> $GITHUB_OUTPUT
401403
echo "statements_pct=$STATEMENTS_PCT" >> $GITHUB_OUTPUT
402404
echo "branches_pct=$BRANCHES_PCT" >> $GITHUB_OUTPUT
403405
echo "functions_pct=$FUNCTIONS_PCT" >> $GITHUB_OUTPUT
404-
echo "min_threshold=$MIN_THRESHOLD" >> $GITHUB_OUTPUT
406+
echo "min_lines=$MIN_LINES" >> $GITHUB_OUTPUT
407+
echo "min_statements=$MIN_STATEMENTS" >> $GITHUB_OUTPUT
408+
echo "min_branches=$MIN_BRANCHES" >> $GITHUB_OUTPUT
409+
echo "min_functions=$MIN_FUNCTIONS" >> $GITHUB_OUTPUT
405410
406411
# Check if any metric is below threshold
407412
FAILED=0
408-
if awk "BEGIN {exit !($LINES_PCT < $MIN_THRESHOLD)}"; then
409-
echo "❌ Lines coverage ($LINES_PCT%) is below minimum threshold ($MIN_THRESHOLD%)"
413+
if awk "BEGIN {exit !($LINES_PCT < $MIN_LINES)}"; then
414+
echo "❌ Lines coverage ($LINES_PCT%) is below minimum threshold ($MIN_LINES%)"
410415
FAILED=1
411416
fi
412-
if awk "BEGIN {exit !($STATEMENTS_PCT < $MIN_THRESHOLD)}"; then
413-
echo "❌ Statements coverage ($STATEMENTS_PCT%) is below minimum threshold ($MIN_THRESHOLD%)"
417+
if awk "BEGIN {exit !($STATEMENTS_PCT < $MIN_STATEMENTS)}"; then
418+
echo "❌ Statements coverage ($STATEMENTS_PCT%) is below minimum threshold ($MIN_STATEMENTS%)"
414419
FAILED=1
415420
fi
416-
if awk "BEGIN {exit !($BRANCHES_PCT < $MIN_THRESHOLD)}"; then
417-
echo "❌ Branches coverage ($BRANCHES_PCT%) is below minimum threshold ($MIN_THRESHOLD%)"
421+
if awk "BEGIN {exit !($BRANCHES_PCT < $MIN_BRANCHES)}"; then
422+
echo "❌ Branches coverage ($BRANCHES_PCT%) is below minimum threshold ($MIN_BRANCHES%)"
418423
FAILED=1
419424
fi
420-
if awk "BEGIN {exit !($FUNCTIONS_PCT < $MIN_THRESHOLD)}"; then
421-
echo "❌ Functions coverage ($FUNCTIONS_PCT%) is below minimum threshold ($MIN_THRESHOLD%)"
425+
if awk "BEGIN {exit !($FUNCTIONS_PCT < $MIN_FUNCTIONS)}"; then
426+
echo "❌ Functions coverage ($FUNCTIONS_PCT%) is below minimum threshold ($MIN_FUNCTIONS%)"
422427
FAILED=1
423428
fi
424429
@@ -453,21 +458,20 @@ jobs:
453458
coverageComment += '| Metric | Coverage | Threshold | Status |\n';
454459
coverageComment += '|--------|----------|-----------|--------|\n';
455460
456-
const minThreshold = parseFloat('${{ steps.coverage_check.outputs.min_threshold }}');
457461
const metrics = [
458-
{ name: 'Lines', pct: total.lines.pct },
459-
{ name: 'Statements', pct: total.statements.pct },
460-
{ name: 'Branches', pct: total.branches.pct },
461-
{ name: 'Functions', pct: total.functions.pct }
462+
{ name: 'Lines', pct: total.lines.pct, threshold: parseFloat('${{ steps.coverage_check.outputs.min_lines }}') },
463+
{ name: 'Statements', pct: total.statements.pct, threshold: parseFloat('${{ steps.coverage_check.outputs.min_statements }}') },
464+
{ name: 'Branches', pct: total.branches.pct, threshold: parseFloat('${{ steps.coverage_check.outputs.min_branches }}') },
465+
{ name: 'Functions', pct: total.functions.pct, threshold: parseFloat('${{ steps.coverage_check.outputs.min_functions }}') }
462466
];
463467
464468
metrics.forEach(metric => {
465-
const emoji = metric.pct >= minThreshold ? '✅' : '❌';
466-
coverageComment += `| ${metric.name} | ${metric.pct.toFixed(2)}% | ${minThreshold}% | ${emoji} |\n`;
469+
const emoji = metric.pct >= metric.threshold ? '✅' : '❌';
470+
coverageComment += `| ${metric.name} | ${metric.pct.toFixed(2)}% | ${metric.threshold}% | ${emoji} |\n`;
467471
});
468472
469473
if (status !== 'passed') {
470-
coverageComment += `\n⚠️ **Coverage is below the minimum threshold of ${minThreshold}%.** Please add tests to improve coverage.\n`;
474+
coverageComment += `\n⚠️ **One or more coverage metrics are below their thresholds.** Please add tests to improve coverage.\n`;
471475
}
472476
} else {
473477
coverageComment += '❌ Coverage report not found.\n';

0 commit comments

Comments
 (0)