patchThreshold and patchFailUnder for PR diff coverage threshold control#636
patchThreshold and patchFailUnder for PR diff coverage threshold control#636Yasu-umi wants to merge 1 commit into
Conversation
|
Thank you for the PR and for using octocov! The functionality you're looking for can actually be achieved with the existing For example: coverage:
acceptable: diff >= 0%
diff:
datastores:
- local://.octocov
You can also combine it with an absolute threshold: coverage:
acceptable: current >= 80% && diff >= 0%When the condition is not met, octocov exits with code 1 and reports an error message, which is the same behavior this PR aims to add. Also, one note on the implementation: the PR uses the name "patch coverage" (coverage of the lines changed in the PR), but |
|
@k1LoW Thank you for your feedback! I understand now that the current diff variable in octocov only represents the overall coverage difference, not the coverage of the lines changed in the PR ("patch coverage"). What I am looking for is the actual patch coverage, i.e., the coverage of only the lines added or modified in the pull request. Since coverage reports alone do not contain information about which lines were changed, it seems that calculating patch coverage would require combining coverage data with git diff information. I would like to implement this feature, but I am wondering what would be the best approach. For example, would it make sense to implement patch coverage calculation as an octocov feature that only works on GitHub Actions (where git diff information is available)? Or is there a recommended way to combine coverage data and git diff to achieve this? Any advice or suggestions would be greatly appreciated! |
|
I understand what you want to achieve. Introducing |
First of all, thank you for providing and maintaining this great OSS. I use octocov in my projects and really appreciate its features and quality.
This Pull Request adds a feature to control CI behavior based on patch (PR diff) coverage threshold. With this, CI can be failed automatically if the coverage of the patch falls below a specified threshold, making octocov even more useful for code review and quality assurance in pull requests.
Main changes
patchThresholdandpatchFailUnderto thecoveragesection in config (octocov.yml) for PR diff coverage threshold control.patchThresholdandpatchFailUnderis true,octocov diffwill exit with code 1 (fail CI).Example config