Skip to content

Commit 37248f0

Browse files
committed
ci(coverage): polish diff-cover step and clarify metric semantics
- Guard against empty SRC_ROOTS before invoking diff-cover; exits with a readable error instead of letting --fail-under be consumed as a src-root value. - Verify that diff-cover actually wrote diff-cover.json; surface the exit code in the failure message so a runner/binary crash is diagnosable without hunting through logs. - Drop the trailing "diff-cover exit code" log; --fail-under=0 means DIFF_RC is always 0 in the happy path, so the line carries no signal. - Clarify the metrics panel: Changed-line is LINE coverage (diff-cover) while Overall / Delta are INSTRUCTION coverage (jacoco-report). Add a footnote to both the console output and the step summary so readers do not silently compare the two counters.
1 parent ece6e09 commit 37248f0

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

.github/workflows/pr-build.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,10 @@ jobs:
298298
PR_XMLS=$(find coverage/pr -name "jacocoTestReport.xml" | sort)
299299
SRC_ROOTS=$(find . -type d -path '*/src/main/java' \
300300
-not -path './coverage/*' -not -path './.git/*' | sort)
301+
if [ -z "$SRC_ROOTS" ]; then
302+
echo "No src/main/java directories found; cannot run diff-cover." >&2
303+
exit 1
304+
fi
301305
302306
set +e
303307
diff-cover $PR_XMLS \
@@ -309,6 +313,11 @@ jobs:
309313
DIFF_RC=$?
310314
set -e
311315
316+
if [ ! -f diff-cover.json ]; then
317+
echo "diff-cover did not produce JSON report (exit=${DIFF_RC})." >&2
318+
exit 1
319+
fi
320+
312321
TOTAL_NUM_LINES=$(jq -r '.total_num_lines // 0' diff-cover.json)
313322
if [ "${TOTAL_NUM_LINES}" = "0" ]; then
314323
echo "No changed Java source lines; skipping changed-line gate."
@@ -332,8 +341,6 @@ jobs:
332341
fi
333342
} >> "$GITHUB_STEP_SUMMARY"
334343
335-
echo "diff-cover exit code: ${DIFF_RC}"
336-
337344
- name: Aggregate base coverage
338345
id: jacoco-base
339346
uses: madrapps/jacoco-report@v1.7.2
@@ -431,6 +438,7 @@ jobs:
431438
Delta (PR - Base): ${DELTA}%
432439
Changed-line Gate: ${CHANGED_LINE_STATUS}
433440
Overall Delta Gate: ${OVERALL_STATUS}
441+
Note: Changed-line uses LINE coverage (diff-cover); Overall/Delta use INSTRUCTION coverage (jacoco-report). The two counters are not directly comparable.
434442
EOF
435443
)
436444
@@ -445,6 +453,8 @@ jobs:
445453
echo "- Delta (PR - Base): ${DELTA}%"
446454
echo "- Changed-line Gate: ${CHANGED_LINE_STATUS}"
447455
echo "- Overall Delta Gate: ${OVERALL_STATUS}"
456+
echo ""
457+
echo "_Note: Changed-line uses LINE coverage (diff-cover); Overall/Delta use INSTRUCTION coverage (jacoco-report). The two counters are not directly comparable._"
448458
} >> "$GITHUB_STEP_SUMMARY"
449459
450460
# 4) Decide CI pass/fail

0 commit comments

Comments
 (0)