PR Comments¶
Post Delta Coverage reports directly to pull request comments using the delta-coverage-action.
Setup¶
1. Enable Markdown Reports¶
configure<io.github.surpsg.deltacoverage.gradle.DeltaCoverageConfiguration> {
diffSource.git.compareWith("refs/remotes/origin/main")
reports {
markdown.set(true)
}
}
2. Add GitHub Action¶
name: Build
on:
pull_request:
branches: [main]
permissions:
contents: read
pull-requests: write # Required for PR comments
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
- name: Run tests with coverage
run: ./gradlew test deltaCoverage
- name: Post coverage comment
uses: gw-kit/delta-coverage-action@v1
with:
report-path: build/reports/coverage-reports/delta-coverage/test/report.md
How It Works¶
The action:
- Posts coverage results to GitHub Check Runs with detailed reports
- Adds a summary comment to the PR with links to check runs and progress bars
PR Comment Example¶
π Ξelta Coverage Check
| Check | Expected | Entity | Actual |
|---|---|---|---|
| π΄ Aggregated | π― 91% π― | INSTRUCTION | |
| π― 90% π― | BRANCH | ||
| π― 91% π― | LINE | ||
| π’ FunctionalTest | π― 60% π― | INSTRUCTION | |
| π― 50% π― | BRANCH | ||
| π― 60% π― | LINE | ||
| π΄ Test | π― 90% π― | INSTRUCTION | |
| BRANCH | |||
| LINE |
Each check name links to the detailed GitHub Check Run with the full coverage report.
Multiple Views¶
Post comments for multiple views (e.g., unit and integration tests):
- name: Post unit test coverage
uses: gw-kit/delta-coverage-action@v1
with:
report-path: build/reports/coverage-reports/delta-coverage/test/report.md
title: "Unit Test Coverage"
- name: Post integration test coverage
uses: gw-kit/delta-coverage-action@v1
with:
report-path: build/reports/coverage-reports/delta-coverage/integrationTest/report.md
title: "Integration Test Coverage"
Continue on Failure¶
Post the comment even if coverage thresholds fail:
- name: Run tests with coverage
run: ./gradlew test deltaCoverage
continue-on-error: true
- name: Post coverage comment
uses: gw-kit/delta-coverage-action@v1
with:
report-path: build/reports/coverage-reports/delta-coverage/test/report.md
Updating Comments¶
By default, the action updates an existing comment instead of creating new ones. Each push to the PR updates the same comment with fresh coverage data.
Permissions¶
The workflow needs pull-requests: write permission:
For workflows triggered by forks, see the action documentation for security considerations.