This guide enhances a GitHub Actions workflow by adding a code coverage job that runs parallel to unit tests and archives coverage reports.
In this guide, we’ll enhance an existing GitHub Actions workflow by adding a dedicated code coverage job. The new job runs in parallel with unit tests, generates coverage reports using npm run coverage, and archives the results for later inspection.
Artifacts from each workflow run appear in the Artifacts section of the run summary. You can remove individual artifacts manually or rely on the retention-days setting for automatic cleanup.
If your global coverage threshold (for example, 90%) isn’t met, the coverage step exits with a non-zero code. Subsequent steps—including artifact uploads—are skipped.
Copy
Ask AI
ERROR: Coverage for lines (88.88%) does not meet global threshold (90%)File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s-----------|---------|----------|---------|---------|-------------------All files | 88.88 | 50 | 87.5 | 88.88 | 21, 47-48, 56app.js | 88.88 | 50 | 87.5 | 88.88 | 21, 47-48, 56Error: Process completed with exit code 1.
To ensure artifact upload even on failure, consider using continue-on-error: true for the coverage step or placing the upload step in a separate always() conditional.