Patch coverage passes but the project coverage drops.
This discrepancy might be caused if you have removed covered lines from your project. This can cause the ratio between covered lines and total lines of codes to decrease.
Here's an example:
You have 20 covered lines in a file with 60 code lines. Therefore, this file is 30% covered.
Let's say you refactor and remove 10 covered lines. You now have 10 covered lines, out of 50 possible code lines. Your file coverage is now 1/5, instead of 1/3.
You can determine if this is happening by:
- Downloading the raw reports from the build tab on Codecov for the head and base of your pull request;
- Checking if the total number of covered lines has dropped between the reported files.
If this is the case, you can add an acceptable margin of change to the target percentage for the project status by setting the threshold value for the status check in your codecov.yml file. See more details about this here: https://docs.codecov.com/docs/commit-status#threshold