Files
codecov-action/README.md
T

67 lines
2.3 KiB
Markdown
Raw Normal View History

2019-08-07 06:14:40 -07:00
# Codecov GitHub Action
2019-08-07 06:28:17 -07:00
### Easily upload coverage reports to Codecov from GitHub Actions
2019-07-30 18:21:05 -07:00
2019-08-06 19:29:18 -07:00
## Usage
2019-08-07 21:38:13 -07: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. The Action also requires you to provide an upload token from [codecov.io](https://www.codecov.io) - in order to avoid exposing your token, store it as a `secret`. Optionally, you can choose to include three 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-08-07 18:30:01 -07:00
- uses: actions/codecov-action@v1
2019-08-06 19:29:18 -07:00
with:
2019-08-07 21:20:10 -07: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-08-06 19:29:18 -07:00
```
2019-08-07 21:20:10 -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 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-08-07 21:03:14 -07:00
Codecov's Action currently supports four inputs from the user: `token`, `file`, `flags`, and `name`. 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-08-07 18:44:06 -07:00
| `file` | Location of the coverage report | Optional
2019-08-07 20:56:18 -07:00
| `flags` | Flag upload under a certain group | Optional
2019-08-07 18:44:06 -07:00
| `name` | Custom defined name for the upload | Optional
2019-08-07 07:59:10 -07:00
### Example `workflow.yml` with Codecov Action
```yaml
name: Example workflow for Codecov
on: [push]
jobs:
run:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Setup Python
uses: actions/setup-python@master
with:
version: 3.7
- name: Generate coverage report
run: |
pip install pytest
pip install pytest-cov
pytest --cov=./ --cov-report=xml
- name: Upload coverage to Codecov
2019-08-07 18:30:01 -07:00
uses: codecov/codecov-action@v1
2019-08-07 07:59:10 -07:00
with:
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-08-07 20:07:45 -07:00
name: codecov-umbrella
2019-08-07 07:59:10 -07:00
```
2019-08-07 21:38:13 -07:00
## Contributing
If you want to contribute code to this repository, check out [CONTRIBUTING](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).