fix: add coverage gate to block PRs on coverage reduction#245
Merged
Conversation
The coverage job collected data and uploaded to Codecov but never enforced thresholds. Codecov status checks (codecov/project, codecov/patch) weren't appearing on PRs, likely due to a missing or invalid CODECOV_TOKEN, and fail_ci_if_error was set to false so the failure was silent. Add an in-workflow coverage gate that: - Enforces a minimum 85% line coverage threshold - Caches the main branch baseline and compares on PRs - Fails the job if coverage drops by more than 1% Also change fail_ci_if_error from false to true on the Codecov upload step so token issues surface immediately. Note: branch protection currently has no required status checks. To fully block merges, add "all-tests-passed" as a required check in the repo's branch protection settings.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
thresholds — it always succeeded regardless of coverage values
codecov/project,codecov/patch) weren't appearingon PRs, likely due to a missing/invalid
CODECOV_TOKEN, andfail_ci_if_errorwasfalseso the upload failure was silentall-tests-passedwasnot listed), so CI failures couldn't block merges — now fixed
Changes
ci.ymlandcoverage.ymlthat:actions/cachefail_ci_if_errorfromfalsetotrueon Codecov uploadall-tests-passedto branch protection required status checksHow the baseline works
main, the coverage percentage is saved to GitHub Actionscache with key
coverage-baseline-<sha>the PR's coverage
and establish the initial baseline
Testing
reduction check was skipped, but the minimum threshold check ran and passed)