2019-08-08 14:59:24 -07:00
# Codecov GitHub Action
2019-11-19 03:36:06 -08:00
[](https://github.com/marketplace/actions/codecov)
2019-11-20 13:00:29 -08:00
### Easily upload coverage reports to Codecov from GitHub Actions
>The latest release of this Action adds support for macOS and Windows builds!
2019-07-30 18:21:05 -07:00
2019-08-06 19:29:18 -07:00
## Usage
2019-12-05 00:57:51 -08:00
To integrate Codecov with your Actions pipeline, specify the name of this repository with a tag number as a `step` within your `workflow.yml` file. This Action also requires you to [provide an upload token ](https://docs.codecov.io/docs/frequently-asked-questions#section-where-is-the-repository-upload-token-found- ) from [codecov.io ](https://www.codecov.io ) (tip: in order to avoid exposing your token, store it as a `secret` ). Optionally, you can choose to include up to five additional inputs to customize the upload context.
2019-08-07 19:17:51 -07:00
2019-08-06 19:29:18 -07:00
Inside your `.github/workflows/workflow.yml` file:
``` yaml
steps :
- uses : actions/checkout@master
2019-11-19 03:36:06 -08:00
- uses : codecov/codecov-action@v1
2019-08-06 19:29:18 -07:00
with :
2019-11-19 03:36:06 -08:00
token : ${{ secrets.CODECOV_TOKEN }} #required
2019-08-07 12:01:44 -07:00
file : ./coverage.xml #optional
2019-08-07 13:08:23 -07:00
flags : unittests #optional
2019-08-07 20:07:45 -07:00
name : codecov-umbrella #optional
2019-11-19 03:36:06 -08:00
yml : ./codecov.yml #optional
2019-12-05 00:57:51 -08:00
fail_ci_if_error : yes #optional (default = no)
2019-08-06 19:29:18 -07:00
```
2019-08-07 22:15:28 -07:00
>**Note**: This assumes that you've set your Codecov token inside * Settings > Secrets * as `CODECOV_TOKEN` . If not, you can [get an upload token ](https://docs.codecov.io/docs/frequently-asked-questions#section-where-is-the-repository-upload-token-found- ) for your specific repo on [codecov.io ](https://www.codecov.io ).
2019-08-06 19:29:18 -07:00
2019-08-07 18:44:06 -07:00
## Arguments
2019-12-05 00:57:51 -08:00
Codecov's Action currently supports five inputs from the user: `token` , `file` , `flags` ,`name` , `yml` , and `fail_ci_if_error` . These inputs, along with their descriptions and usage contexts, are listed in the table below:
2019-08-07 19:17:51 -07:00
2019-08-07 18:44:06 -07:00
| Input | Description | Usage |
| :---: | :---: | :---: |
2019-08-07 21:20:10 -07:00
| `token` | Used to authorize coverage report uploads | * Required * |
2019-11-19 03:36:06 -08:00
| `file` | Path to the coverage report(s) | Optional
2019-11-19 04:18:00 -08:00
| `flags` | Flag the upload to group coverage metrics (unittests, uitests, etc.) | Optional
2019-11-19 11:26:54 -08:00
| `name` | Custom defined name for the upload | Optional
2019-11-19 03:36:06 -08:00
| `yml` | Path to codecov.yml config file | Optional
2019-12-05 00:57:51 -08:00
| `fail_ci_if_error` | Specify whether CI pipeline should fail if there are errors related to Codecov. * Defaults to no * . | Optional
2019-08-07 18:44:06 -07:00
2019-08-07 07:59:10 -07:00
### Example `workflow.yml` with Codecov Action
``` yaml
name : Example workflow for Codecov
on : [ push]
jobs :
run :
2019-11-19 03:36:06 -08:00
runs-on : ${{ matrix.os }}
strategy :
matrix :
os : [ ubuntu-latest, macos-latest, windows-latest]
2019-08-07 07:59:10 -07:00
steps :
- uses : actions/checkout@master
- name : Setup Python
uses : actions/setup-python@master
with :
2019-12-01 13:41:06 -05:00
python-version : 3.7
2019-08-07 07:59:10 -07:00
- name : Generate coverage report
run : |
pip install pytest
pip install pytest-cov
pytest --cov=./ --cov-report=xml
- name : Upload coverage to Codecov
2019-11-19 03:36:06 -08:00
uses : codecov/codecov-action@v1
2019-08-07 07:59:10 -07:00
with :
2019-11-19 03:36:06 -08:00
token : ${{ secrets.CODECOV_TOKEN }}
2019-08-07 12:01:44 -07:00
file : ./coverage.xml
2019-08-07 13:08:23 -07:00
flags : unittests
2019-11-19 03:36:06 -08:00
name : codecov-umbrella
yml : ./codecov.yml
2019-12-05 00:57:51 -08:00
fail_ci_if_error : yes
2019-08-07 07:59:10 -07:00
```
2019-08-07 21:38:13 -07:00
## Contributing
2019-08-07 21:40:59 -07:00
Contributions are welcome! Check out the [Contribution Guide ](CONTRIBUTING.md ).
2019-08-07 07:59:10 -07:00
2019-08-06 19:29:18 -07:00
## License
2019-08-07 20:10:44 -07:00
The code in this project is released under the [MIT License ](LICENSE ).