Skip to content
Latchkey

GitHub Actions Workflow for Comment Coverage on PRs

Post a test-coverage summary right on the pull request.

This workflow runs coverage, then a reporter action posts (and updates) a sticky comment on the PR.

The workflow

.github/workflows/coverage.yml
name: Coverage
on: [pull_request]
permissions:
  contents: read
  pull-requests: write
jobs:
  coverage:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with: { node-version: 20, cache: npm }
      - run: npm ci
      - run: npm test -- --coverage
      - uses: davelosert/vitest-coverage-report-action@v2
        if: always()

Notes

  • Needs pull-requests: write to comment.
  • The reporter updates the same comment instead of spamming new ones.
  • Generate a clover/lcov report your reporter understands.

Run it cheaper

Point runs-on: at a Latchkey label to run this workflow at roughly 69% lower per-minute cost, with self-healing for transient failures.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →