The GitHub Action can be found here:
Please consider starring the repo if you find it useful.
There are four problems with pytest code coverage out-of-the-box.
- It doesn't check subfolders be default.
- By default it includes the test(s) directory which biases the total code coverage upwards.
- It doesn't return an exit code if the code coverage threshold is not met.
- It doesn't allow setting a minimum code coverage threshold for individual files.
Points 1 and 2 can be solved by using a .coveragerc file, but having to manually update the file can become cumbersome fast.
The GitHub Action I've written aims to solve all of these issues. I also provide a sample workflow file that uses two other actions as well to automatically create issues and commit comments in your repo with the pytest code coverage table as a markdown table.
I've also created a YouTube video that details how to add the GitHub Action to your project, as well as a breakdown of how the Action works:
All the code for the video is on GitHub as well, with the link in the video description.
Please consider subscribing if you find the video helpful. I am trying to post a new video every few weeks on various topics surrounding Python and DevOps.