GitHub Actions Setup
This repository can use GitHub Actions to do two separate jobs:
- Run unit tests and Playwright end-to-end tests on every pull request to
mainand every push tomain. - Refresh the README coverage badge after successful pushes to
main.
The workflow file is:
.github/workflows/ci.ymlWhat the workflow does
The workflow is named CI and has two jobs.
1. Test
This job runs on:
- every pull request targeting
main - every push to
main
It does the following:
- checks out the repository
- installs Node.js 20
- runs
npm ci - installs Playwright Chromium and its Linux dependencies
- runs
npm run test:coverage - runs
npm run test:e2e
If this job fails, GitHub shows the failure directly in the pull request checks.
2. Update Coverage Badge
This job runs only when:
- the event is a push to
main - the
Testjob already passed
It does the following:
- runs unit coverage again to produce
coverage/coverage-final.json - runs
npm run update:coverage-badge - commits the updated README badge if the badge changed
The commit message contains [skip ci] so the bot commit does not trigger the workflow again.
Files involved
Workflow
.github/workflows/ci.ymlCoverage badge updater
scripts-dev/update-coverage-badge.jsThis script updates only the coverage badge block in README.md.
The older all-in-one README updater is no longer part of the repository workflow, because commit/changelog rewriting created noisy automation output and did not help branch protection or test visibility.
What you must do in GitHub
The workflow file alone is not enough to block merges. You must also enable branch protection for main.
A. Push the workflow to GitHub
Commit and push these files:
.github/workflows/ci.yml
scripts-dev/update-coverage-badge.js
tutorials/github-actions.mdYou will usually also push the README change that adds the CI badge:
README.mdB. Local equivalents
These are the same commands the workflow uses:
npm ci
npm run test:coverage
npm run test:e2e
npm run update:coverage-badgeNotes
- The workflow updates the coverage badge only after code is already on
main. - The merge gate is provided by the pull request test run plus branch protection.
- If you want the badge update to happen in a separate maintenance branch instead of committing directly to
main, the workflow should be changed to open a pull request instead of pushing.