Skip to content

ci(coverage): disable jacoco PR comments, relax overall delta threshold to 0.4%#22

Open
bladehan1 wants to merge 1 commit intodevelopfrom
fix/ci_coverage
Open

ci(coverage): disable jacoco PR comments, relax overall delta threshold to 0.4%#22
bladehan1 wants to merge 1 commit intodevelopfrom
fix/ci_coverage

Conversation

@bladehan1
Copy link
Copy Markdown
Owner

@bladehan1 bladehan1 commented Apr 20, 2026

What

Three targeted fixes to the coverage-gate CI job in pr-build.yml:

  1. Add comment-type: summary to both jacoco-report steps — routes output to the workflow step summary instead of PR comments.
  2. Relax MAX_DROP from -0.1% to -0.4%.

Why

Issue 1 — 403 errors on PR comment posting

The coverage-gate job declares only permissions: contents: read. The madrapps/jacoco-report action defaults to comment-type: pr_comment, which calls the GitHub PR comment API and requires pull-requests: write. Every CI run was producing a 403 error in the logs, though it did not block the gate because the action's own continue-on-error default is true.

Setting comment-type: summary makes the action write to $GITHUB_STEP_SUMMARY (a local file write, no API call), so the 403 disappears entirely without needing to grant broader token permissions.

Issue 2 — coverage-changed-files reports INSTRUCTION coverage, not LINE coverage

The value shown as Changed Files Coverage is bytecode instruction coverage, not source-line coverage. This is a fixed behavior of madrapps/jacoco-report@v1.7.2 — the action has no coverage-type parameter and internally reads only the INSTRUCTION counter from JaCoCo XML.

Why INSTRUCTION ≠ LINE and why it matters:

  • JaCoCo XML records six counter types per source file: INSTRUCTION, BRANCH, LINE, COMPLEXITY, METHOD, CLASS.
  • A single source line compiles to multiple bytecode instructions. For example, a null-check if (x != null) may emit 3–5 instructions; a fluent chain on one line may emit 10+.
  • INSTRUCTION coverage is therefore sensitive to compiler expansion: generated code (constructors, getters/setters, toString, enum boilerplate) inflates the instruction count without adding meaningful semantic coverage.
  • When a PR touches one method in a class that also has many generated accessors, the changed-file INSTRUCTION coverage can read significantly lower than the LINE coverage a reviewer would intuitively expect.
  • Concretely: the 93.3% figure visible in recent CI runs is INSTRUCTION coverage of the diff files, not line coverage.

To switch to LINE coverage the action would need to be replaced with a custom script that reads the LINE counter (<counter type="LINE" covered="N" missed="M"/>) from each matching <sourcefile> node. The action itself does not expose this as a configuration option in any released version through v1.7.2.

Issue 3 — -0.1% delta threshold causes false failures

Normal variance in test execution timing, minor refactoring (renaming, extracting constants), or adding tests to previously uncovered edge-case paths can shift overall INSTRUCTION coverage by ±0.2%. A threshold of -0.1% triggered spurious gate failures in these scenarios. -0.4% still catches real coverage regressions while eliminating the noise.

Summary by CodeRabbit

  • Chores
    • Updated format of coverage report comments in pull requests to display as summary-style comments.
    • Strengthened code coverage enforcement; pull requests will now fail if overall coverage drops more than 0.4%.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 20, 2026

📝 Walkthrough

Walkthrough

The GitHub Actions workflow modifies JaCoCo report aggregation to include summary-type comments and tightens code coverage enforcement by raising the maximum allowed coverage drop threshold from -0.1% to -0.4%.

Changes

Cohort / File(s) Summary
Workflow Configuration
.github/workflows/pr-build.yml
Added comment-type: summary to JaCoCo report aggregation steps; tightened coverage delta gate by changing MAX_DROP threshold from -0.1 to -0.4 and updated corresponding failure message.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 With stricter gates and summary calls so bright,
The coverage threshold tightens—no more drops in sight!
From point-one to point-four, the standards now stand tall,
A rabbit's pledge for quality that covers all! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main changes: disabling JaCoCo PR comments and relaxing the coverage threshold to 0.4%, which align with the primary objectives documented in the PR.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/ci_coverage

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
.github/workflows/pr-build.yml (2)

391-391: Keep the threshold message in sync with MAX_DROP.

The hardcoded 0.4% in the failure message will drift if MAX_DROP is tuned again. Consider interpolating the variable.

Proposed fix
-            echo "Coverage gate failed: overall coverage dropped more than 0.4%."
+            echo "Coverage gate failed: overall coverage dropped more than ${MAX_DROP#-}%."
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/pr-build.yml at line 391, The failure message currently
hardcodes "0.4%" which can go out of sync with the MAX_DROP setting; update the
echo that prints the coverage gate failure so it interpolates the MAX_DROP
variable (referencing MAX_DROP and the echo command) instead of a literal "0.4%"
so the message always reflects the configured threshold.

361-364: Minor: status string reads awkwardly with a negative threshold.

With MAX_DROP=-0.4, the summary renders as PASS (>= -0.4%) / FAIL (< -0.4%), which conflates the delta with the threshold. Consider phrasing in terms of the delta for clarity.

Proposed wording
-          OVERALL_STATUS="PASS (>= ${MAX_DROP}%)"
+          OVERALL_STATUS="PASS (delta ${DELTA}% >= ${MAX_DROP}%)"
           if [ "$DELTA_OK" -ne 1 ]; then
-            OVERALL_STATUS="FAIL (< ${MAX_DROP}%)"
+            OVERALL_STATUS="FAIL (delta ${DELTA}% < ${MAX_DROP}%)"
           fi
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/pr-build.yml around lines 361 - 364, The status message
uses the threshold variable MAX_DROP in a way that reads awkwardly when it's
negative; update the strings set to OVERALL_STATUS to phrase them in terms of
the observed delta instead of the threshold. Replace "PASS (>= ${MAX_DROP}%)"
and "FAIL (< ${MAX_DROP}%)" with clearer wording such as "PASS (delta >=
${MAX_DROP}%)" and "FAIL (delta < ${MAX_DROP}%)" (or "delta >=/ <" whatever
style you prefer), ensuring the branch that checks DELTA_OK continues to set
OVERALL_STATUS accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In @.github/workflows/pr-build.yml:
- Line 391: The failure message currently hardcodes "0.4%" which can go out of
sync with the MAX_DROP setting; update the echo that prints the coverage gate
failure so it interpolates the MAX_DROP variable (referencing MAX_DROP and the
echo command) instead of a literal "0.4%" so the message always reflects the
configured threshold.
- Around line 361-364: The status message uses the threshold variable MAX_DROP
in a way that reads awkwardly when it's negative; update the strings set to
OVERALL_STATUS to phrase them in terms of the observed delta instead of the
threshold. Replace "PASS (>= ${MAX_DROP}%)" and "FAIL (< ${MAX_DROP}%)" with
clearer wording such as "PASS (delta >= ${MAX_DROP}%)" and "FAIL (delta <
${MAX_DROP}%)" (or "delta >=/ <" whatever style you prefer), ensuring the branch
that checks DELTA_OK continues to set OVERALL_STATUS accordingly.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 3ff2d486-cf3d-476b-b392-960144f1732f

📥 Commits

Reviewing files that changed from the base of the PR and between 2de63bb and a4fffea.

📒 Files selected for processing (1)
  • .github/workflows/pr-build.yml

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant