codecov/codecov-action: Upload Coverage Reports
codecov-action uploads your coverage report to Codecov after your tests run.
Generate a coverage file in your test step, then hand it to codecov-action. Use a token for private repos and flags to separate coverage by suite.
Key inputs (with:)
- token: Codecov upload token (required for private repos).
- files: explicit coverage file paths.
- flags: label coverage by test type or package.
- fail_ci_if_error: fail the job on upload errors.
- slug: owner/repo override.
Example workflow
.github/workflows/ci.yml
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: pytest --cov=app --cov-report=xml
- uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.xmlOn any runner
This action runs on any runner. Latchkey managed runners run it unchanged.
Key takeaways
- Produce a coverage file before calling the action.
- Private repos require a token; public repos often do not.
- flags split coverage by suite in the Codecov UI.
Related guides
actions/setup-python: Install Python in CIReference for actions/setup-python: select a Python version, enable pip/pipenv/poetry caching, and run matrix…
actions/setup-node: Install Node.js in CIReference for actions/setup-node: pin a Node.js version, enable built-in npm/yarn/pnpm caching, and register…
github/codeql-action: Run CodeQL Code ScanningReference for github/codeql-action: initialize, analyze, and upload CodeQL results for GitHub code scanning,…