Skip to content

ci: ignore files inside component test directories in codecov - #8469

Open
dylan-rumble wants to merge 1 commit into
api-platform:4.3from
dylan-rumble:ci/codecov-ignore-tests
Open

ci: ignore files inside component test directories in codecov#8469
dylan-rumble wants to merge 1 commit into
api-platform:4.3from
dylan-rumble:ci/codecov-ignore-tests

Conversation

@dylan-rumble

Copy link
Copy Markdown

The src/**/Tests/ ignore pattern in codecov.yml does not exclude anything.

Codecov compiles it to:

(?s:src/.*/Tests/)\Z

The \Z anchor sits right after the trailing slash, so the pattern only matches a path that ends in Tests/ — never a file inside that directory. (Verified against https://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 excludes tests and vendor, while the per-component suites correctly exclude ./Tests.

The visible effect is that test-heavy pull requests get an unfairly low codecov/patch score. For example on #8420 the diff is 20 measured lines: 1 production line (hit) plus 19 lines of the new src/State/Tests/Processor/ObjectMapperOutputProcessorTest.php (counted as missed), giving 5% patch coverage.

Using src/**/Tests/** compiles to:

(?s:src/.*/Tests/.*)\Z

which matches the files as intended. Validated with the Codecov config validator.

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>
@dylan-rumble

Copy link
Copy Markdown
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%...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant