Code Coverage Report in PRs#3693
Conversation
…port as a comment on the PR
Code Coverage
|
📝 WalkthroughWalkthroughThe PR updates the commcare-android GitHub Actions workflow to enhance JaCoCo code coverage reporting. The Build job now includes a new step that generates the JaCoCo test report, uploads it as an artifact to a nested jacoco directory, and posts a comment on pull requests with the coverage results using the madrapps/jacoco-report action. This replaces the previous JaCoCo reporting approach with an automated PR comment feature that displays coverage metrics directly in the pull request. Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. 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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
.github/workflows/commcare-android-pr-workflow.yml (1)
23-26:⚠️ Potential issue | 🟠 Major | ⚡ Quick winAdd
permissions: pull-requests: writeto the job — the action will fail without it.The
madrapps/jacoco-reportaction's official documentation requirespermissions: pull-requests: writeat the job level, and explicitly notes that without the appropriate permission, theGITHUB_TOKENwon't have sufficient access to write the coverage comment. If the repository's default token permission is set to read-only, the step will fail withHttpError: Resource not accessible by integration, which will in turn fail the entire job, blocking theAssemble Release apkand subsequent steps.🔒 Proposed fix — add permissions to the job
build-test-assemble: name: Build runs-on: ubuntu-latest + permissions: + pull-requests: write + contents: read steps:Also applies to: 100-107
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In @.github/workflows/commcare-android-pr-workflow.yml around lines 23 - 26, The GitHub Actions job "build-test-assemble" must declare job-level permissions to allow the madrapps/jacoco-report step to write coverage comments; add a permissions block with "pull-requests: write" to the build-test-assemble job (and mirror the same change for the other job around lines 100-107) so the GITHUB_TOKEN has sufficient access and the jacoco-report step doesn't fail with "Resource not accessible by integration".
🧹 Nitpick comments (1)
.github/workflows/commcare-android-pr-workflow.yml (1)
102-102: 💤 Low value
madrapps/jacoco-report@v1.7.1is one patch behind the current release.The latest published version on the GitHub Marketplace is
v1.7.2. Consider updating to pick up any bug fixes.- uses: madrapps/jacoco-report@v1.7.1 + uses: madrapps/jacoco-report@v1.7.2🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In @.github/workflows/commcare-android-pr-workflow.yml at line 102, Update the GitHub Action version reference for the jacoco report step: replace the use of "madrapps/jacoco-report@v1.7.1" with "madrapps/jacoco-report@v1.7.2" so the workflow uses the latest marketplace release; ensure the change is applied to the workflow step that currently references madrapps/jacoco-report@v1.7.1.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.github/workflows/commcare-android-pr-workflow.yml:
- Around line 92-107: The three coverage steps ("Generate JaCoCo Report",
"Upload JaCoCo Report", and "Comment JaCoCo Coverage on PR") can fail and should
not block the build; update each of those job steps in the workflow to include
continue-on-error: true so failures in jacocoTestReport, artifact upload, or the
PR comment action won't stop subsequent steps like Restore Keystore or Assemble
Release apk.
---
Outside diff comments:
In @.github/workflows/commcare-android-pr-workflow.yml:
- Around line 23-26: The GitHub Actions job "build-test-assemble" must declare
job-level permissions to allow the madrapps/jacoco-report step to write coverage
comments; add a permissions block with "pull-requests: write" to the
build-test-assemble job (and mirror the same change for the other job around
lines 100-107) so the GITHUB_TOKEN has sufficient access and the jacoco-report
step doesn't fail with "Resource not accessible by integration".
---
Nitpick comments:
In @.github/workflows/commcare-android-pr-workflow.yml:
- Line 102: Update the GitHub Action version reference for the jacoco report
step: replace the use of "madrapps/jacoco-report@v1.7.1" with
"madrapps/jacoco-report@v1.7.2" so the workflow uses the latest marketplace
release; ensure the change is applied to the workflow step that currently
references madrapps/jacoco-report@v1.7.1.
🪄 Autofix (Beta)
❌ Autofix failed (check again to retry)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 2344aa7e-c030-49de-aa89-8236cc9d7755
📒 Files selected for processing (1)
.github/workflows/commcare-android-pr-workflow.yml
|
Note Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it. ⛔ CodeRabbit does not have permission to push changes to this repository. Please ensure CodeRabbit has Contents: Read and write permission. |
Added continue-on-error in case code coverage reporting encounters any errors. Upgraded jacoco-report
https://dimagi.atlassian.net/browse/CCCT-2305
Product Description
No user-facing change
Technical Summary
Moved the jacoco code coverage report earlier in the build process (so we're more likely to get the report even if a later step fails).
Configured the coverage report to post as a comment on the PR.
Safety Assurance
Safety story
These changes do not affect the actual app that gets built, they are just a reporting metric during the build.
Automated test coverage
None
QA Plan
None