diff --git a/{{cookiecutter.project_name}}/.github/workflows/test.yaml b/{{cookiecutter.project_name}}/.github/workflows/test.yaml index b690b7c8..cafb8538 100644 --- a/{{cookiecutter.project_name}}/.github/workflows/test.yaml +++ b/{{cookiecutter.project_name}}/.github/workflows/test.yaml @@ -81,7 +81,11 @@ jobs: uvx hatch run ${{ matrix.env.name }}:cov-report # report visibly uvx hatch run ${{ matrix.env.name }}:coverage xml # create report for upload - name: Upload coverage + if: ${{ !cancelled() }} uses: codecov/codecov-action@v5 + with: + token: ${{ secrets.CODECOV_TOKEN }} + fail_ci_if_error: true # Check that all tests defined above pass. This makes it easy to set a single "required" test in branch # protection instead of having to update it frequently. See https://github.com/re-actors/alls-green#why. diff --git a/{{cookiecutter.project_name}}/docs/template_usage.md b/{{cookiecutter.project_name}}/docs/template_usage.md index 8b960c34..822ed1f9 100644 --- a/{{cookiecutter.project_name}}/docs/template_usage.md +++ b/{{cookiecutter.project_name}}/docs/template_usage.md @@ -88,51 +88,24 @@ line-length = 120 Coverage tells what fraction of the code is "covered" by unit tests, thereby encouraging contributors to [write tests](contributing.md#writing-tests). To enable coverage checks, head over to [codecov][] and sign in with your GitHub account. -You'll find more information in "getting started" section of the [codecov docs][]. +You'll find more information in the "quick start" section of the [codecov docs][]. -In the `Actions` tab of your projects' GitHub repository, you can see that the workflows are failing due to the **Upload coverage** step. -The error message in the workflow should display something like: - -``` -... - Retrying 5/5 in 2s.. - {'detail': ErrorDetail(string='Could not find a repository, try using repo upload token', code='not_found')} -Error: 404 Client Error: Not Found for url: -... -``` - -While [codecov docs][] has a very extensive documentation on how to get started, -_if_ you are using the default settings of this template we can assume that you are using [codecov][] in a GitHub action workflow and hence you can make use of the [codecov bot][]. +Most importantly, you **must add a codecov token to your repository secrets** for the job to succeed. +A step-by-step guide is shown in in [adding the codecov token][codecov token]. +If you want codecov to comment on pull requests, you can make use of the [codecov bot][]. To set it up, simply go to the [codecov app][] page and follow the instructions to activate it for your repository. -Once the activation is completed, go back to the `Actions` tab and re-run the failing workflows. +Once token and app are added, go back to the `Actions` tab and re-run the failing workflows. The workflows should now succeed, and you will be able to find the code coverage at this link: `https://app.codecov.io/gh/{{cookiecutter.github_user}}/{{cookiecutter.project_name}}`. -You might have to wait a couple of minutes and the coverage of this repository should be ~60%. - -If your repository is private, you will have to specify an additional token in the repository secrets. -In brief, you need to: - -1. Generate a Codecov Token by clicking _setup repo_ in the codecov dashboard. - - If you have already set up codecov in the repository by following the previous steps, you can directly go to the codecov repo webpage. -2. Go to _Settings_ and copy **only** the token `_______-____-...`. -3. Go to _Settings_ of your newly created repository on GitHub. -4. Go to _Security > Secrets > Actions_. -5. Create new repository secret with name `CODECOV_TOKEN` and paste the token generated by codecov. -6. Paste these additional lines in `/.github/workflows.test.yaml` under the **Upload coverage** step: - ```bash - - name: Upload coverage - uses: codecov/codecov-action@v3 - with: - token: {% raw %}${{ secrets.CODECOV_TOKEN }}{% endraw %} - ``` -7. Go back to GitHub `Actions` page an re-run previously failed jobs. + [codecov]: https://about.codecov.io/sign-up/ [codecov app]: https://github.com/apps/codecov [codecov bot]: https://docs.codecov.com/docs/team-bot -[codecov docs]: https://docs.codecov.com/docs +[codecov docs]: https://docs.codecov.com/docs/quick-start +[codecov token]: https://docs.codecov.com/docs/adding-the-codecov-token ### Documentation on _readthedocs_