Codecov¶
The CI workflow runs coverage on every push and pull request, and uploads the results to Codecov. This gives you per-PR coverage diffs, a coverage badge, and trend graphs over time.
Steps¶
1. Create a Codecov account¶
Go to codecov.io and sign in with your GitHub account.
2. Add your repository¶
- In the Codecov dashboard, click + Add new repository
- Find and select your repository
- Copy the Repository Upload Token shown on the setup page
3. Add the secret to GitHub¶
- Go to your GitHub repository → Settings → Secrets and variables → Actions
- Click New repository secret
- Name:
CODECOV_TOKEN - Value: paste the token from Codecov
- Click Add secret
That's it. The next CI run will upload coverage automatically.
How the Workflow Uses It¶
In ci.yml, after running tests with coverage, the workflow uploads the report:
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v5
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
Coverage Badge¶
Your generated README.md already includes a Codecov badge. Once you've completed setup and the first CI run has uploaded a report, the badge will show your current coverage percentage.
Running Coverage Locally¶
This generates both a JSON report (used by the CI upload) and a text report printed to the terminal.