v6 of the Codecov GitHub Action support node24
v5 of the Codecov GitHub Action will use the Codecov Wrapper to encapsulate the CLI. This will help ensure that the Action gets updates quicker.
The v5 release also coincides with the opt-out feature for tokens for public repositories. In the Global Upload Token section of the settings page of an organization in codecov.io, you can set the ability for Codecov to receive a coverage reports from any source. This will allow contributors or other members of a repository to upload without needing access to the Codecov token. For more details see how to upload without a token.
Warning
The following arguments have been changed
file(this has been deprecated in favor offiles)plugin(this has been deprecated in favor ofplugins)
The following arguments have been added:
binarygcov_argsgcov_executablegcov_ignoregcov_includereport_typeskip_validationswift_project
You can see their usage in the action.yml file.
v4 of the Codecov GitHub Action will use the Codecov CLI to upload coverage reports to Codecov.
- Tokenless uploading is unsupported. However, PRs made from forks to the upstream public repos will support tokenless (e.g. contributors to OSS projects do not need the upstream repo's Codecov token). For details, see our docs
- Various arguments to the Action have been removed
- For repositories using
Dependabot, users will need to ensure that it has access to the Codecov token for PRs from Dependabot to upload coverage. To do this, please add yourCODECOV_TOKENas a Dependabot Secret. For more information, see "Configuring access to private registries for Dependabot."
v3 versions and below will not have access to CLI features (e.g. global upload token, ATS).
Caution
In order for the Action to work seamlessly, you will need to have bash, curl, git, and gpg installed on your runner. You will also need to run actions/checkout before calling the Codecov action. If these are not present, the Action will fail. Github Actions runners will have these installed by default. If you are using a custom runner or running in a container, you will need to ensure that these are installed.
To integrate Codecov with your Actions pipeline, specify the name of this repository with a tag number (@v5 is recommended) as a step within your workflow.yml file.
This Action also requires you to provide an upload token from codecov.io (tip: in order to avoid exposing your token, store it as a secret).
Currently, the Action will identify linux, macos, and windows runners. However, the Action may misidentify other architectures. The OS can be specified as
- alpine
- alpine-arm64
- linux
- linux-arm64
- macos
- windows
Inside your .github/workflows/workflow.yml file:
steps:
- uses: actions/checkout@main
- uses: codecov/codecov-action@v5
with:
fail_ci_if_error: true # optional (default = false)
files: ./coverage1.xml,./coverage2.xml # optional
flags: unittests # optional
name: codecov-umbrella # optional
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true # optional (default = false)The Codecov token can also be passed in via environment variables:
steps:
- uses: actions/checkout@main
- uses: codecov/codecov-action@v5
with:
fail_ci_if_error: true # optional (default = false)
files: ./coverage1.xml,./coverage2.xml # optional
flags: unittests # optional
name: codecov-umbrella # optional
verbose: true # optional (default = false)
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}Important
This assumes that you've set your Codecov token inside Settings > Secrets as CODECOV_TOKEN. If not, you can get an upload token for your specific repo on codecov.io. Keep in mind that secrets are not available to forks of repositories.
As an alternative to Codecov upload tokens, you can choose to use OIDC as your upload authentication method by setting the use_oidc argument:
- uses: codecov/codecov-action@v5
with:
use_oidc: trueAny token supplied will be ignored, as Codecov will default to the OIDC token for verification.
Note that the codecov action must have write permission for id-token for this to work:
permissions:
id-token: writeThis can be set at either the workflow or job level. See GitHub's docs for more details.
Codecov's Action supports inputs from the user. These inputs, along with their descriptions and usage contexts, are listed in the table below:
name: Example workflow for Codecov
on: [push]
jobs:
run:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
env:
OS: ${{ matrix.os }}
PYTHON: "3.10"
steps:
- uses: actions/checkout@main
- name: Setup Python
uses: actions/setup-python@main
with:
python-version: "3.10"
- name: Generate coverage report
run: |
pip install pytest
pip install pytest-cov
pytest --cov=./ --cov-report=xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
with:
directory: ./coverage/reports/
env_vars: OS,PYTHON
fail_ci_if_error: true
files: ./coverage1.xml,./coverage2.xml,!./cache
flags: unittests
name: codecov-umbrella
token: ${{ secrets.CODECOV_TOKEN }}
verbose: trueContributions are welcome! Check out the Contribution Guide.
The code in this project is released under the MIT License.
