💸Save up to $132K/month in CI costs!👉 Try Free
Skip to main content
← Back to workflows

How to Use GitHub Action to Upload Coverage Reports

codecov-codecov-action -
GitHub Action
v4.4.0
1,458
Contributors
Contributor - thomasrockhuContributor - ibrahim0814
Categories

Optimize Your CI/CD Pipeline

Get instant insights into your CI/CD performance and costs. Reduce build times by up to 45% and save on infrastructure costs.

45% Faster Builds
60% Cost Reduction
Usage
name: 'Usage of codecov-action GitHub Action'
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: codecov/codecov-action@v4
with:
fail_ci_if_error: true
files: ./coverage.xml
token: ${{ secrets.CODECOV_TOKEN }}

codecov-action logo

CodeCov Action

GitHub Action that uploads coverage to Codecov


What is codecov-action?

The Codecov GitHub Action simplifies the process of uploading coverage reports to Codecov from our GitHub repositories, allowing us to review coverage metrics and trends over time.

How to Use OIDC Uploading Coverage Reports

Using OIDC provides a secure and simplified authentication process that does not require storing or managing a Codecov token, reducing potential security risks and configuration overhead.

- uses: codecov/codecov-action@v4
with:
use_oidc: true

How to Specify a Custom Path to the Codecov YML

Set a custom path to the Codecov configuration file if it's not in the default location.

- uses: codecov/codecov-action@v3
with:
codecov_yml_path: 'config/codecov.yml'

How to Override the Parent Commit SHA

Specify the parent commit SHA to manually set the base commit Codecova should use to compare coverage changes.

- uses: codecov/codecov-action@v3
with:
commit_parent: 'a1b2c3d4e5f6g7h8i9j0k'

This can be useful in workflows where commits may be squashed or altered before merging, ensuring accurate comparison and coverage data.

How to Set the Directory for Searching Coverage Reports

Define a specific directory where the action should look for coverage reports.

- uses: codecov/codecov-action@v3
with:
directory: './coverage/reports/'

Setting a specific directory can speed up the upload process by reducing the number of directories Codecov needs to search.

How to Disable Search for Coverage Files

Prevent the action from automatically searching for coverage reports. Useful when you want to manually specify which reports to upload.

- uses: codecov/codecov-action@v3
with:
disable_search: true

This helps in workflows where you have precise control over which coverage reports are relevant for upload.

How to Disable File Fixes

Turn off automatic file fixes that normally adjust coverage to ignore common lines.

- uses: codecov/codecov-action@v3
with:
disable_file_fixes: true

This might be necessary if you need raw, unmodified reports for specific analysis purposes.

How to Perform a Dry Run

Execute the action without uploading files to Codecov, which is useful for testing the setup.

- uses: codecov/codecov-action@v3
with:
dry_run: true

This allows you to validate your configuration and the coverage report generation process without affecting your actual Codecov data.