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: writeto 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
GitHub Actions Workflow Template for Node.jsA ready-to-use GitHub Actions workflow for Node.js with caching and best practices - copy, commit, and run fa…
How to Speed Up GitHub Actions: 9 High-Impact TacticsMake GitHub Actions faster: caching, parallelization, test splitting, Docker layer caching, slimmer images, a…