ci: ignore files inside component test directories in codecov - #8469
Open
dylan-rumble wants to merge 1 commit into
Open
ci: ignore files inside component test directories in codecov#8469dylan-rumble wants to merge 1 commit into
dylan-rumble wants to merge 1 commit into
Conversation
The `src/**/Tests/` ignore pattern compiles to the regex `(?s:src/.*/Tests/)\Z`, which is anchored right after the trailing slash and therefore only matches a path ending in `Tests/` - never a file inside it. As a result component test files were still included in the Codecov report at 0% coverage (the root phpunit.xml.dist `<source>` instruments them since it only excludes `tests` and `vendor`), which unfairly lowers patch coverage on test-heavy pull requests. Using `src/**/Tests/**` compiles to `(?s:src/.*/Tests/.*)\Z` and correctly excludes the files. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Author
|
roughly half of the 69,833 "lines" Codecov was tracking were component test files sitting at 0%, dragging the whole project metric down since Jan 2024. The real coverage was always ~66%, not ~31%... |
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.
The
src/**/Tests/ignore pattern incodecov.ymldoes not exclude anything.Codecov compiles it to:
The
\Zanchor sits right after the trailing slash, so the pattern only matches a path that ends inTests/— never a file inside that directory. (Verified againsthttps://codecov.io/validate.)Consequently component test files are still part of the Codecov report at 0% coverage — the root
phpunit.xml.dist<source>instruments them because it includes.and only excludestestsandvendor, while the per-component suites correctly exclude./Tests.The visible effect is that test-heavy pull requests get an unfairly low
codecov/patchscore. For example on #8420 the diff is 20 measured lines: 1 production line (hit) plus 19 lines of the newsrc/State/Tests/Processor/ObjectMapperOutputProcessorTest.php(counted as missed), giving 5% patch coverage.Using
src/**/Tests/**compiles to:which matches the files as intended. Validated with the Codecov config validator.