Skip to content

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:

  1. Posts coverage results to GitHub Check Runs with detailed reports
  2. 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 89%
🎯 90% 🎯 BRANCH 72%
🎯 91% 🎯 LINE 91%
🟒 FunctionalTest 🎯 60% 🎯 INSTRUCTION 82%
🎯 50% 🎯 BRANCH 51%
🎯 60% 🎯 LINE 82%
πŸ”΄ Test 🎯 90% 🎯 INSTRUCTION 85%
BRANCH 56%
LINE 86%

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:

permissions:
  contents: read
  pull-requests: write

For workflows triggered by forks, see the action documentation for security considerations.