fix: Tia coverage cache recorded on another machine empties the merged report and passes --min - #1798
Open
AlessioGiacobbe wants to merge 1 commit into
Open
Conversation
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.
Fixes #1796.
The bug
A TIA baseline recorded on one machine (e.g. GitHub Actions) ships its coverage cache with the recording machine's absolute paths serialized inside. When another machine downloads it via
pest()->tia()->baselined()and runs--tia --coverage,CoverageMergermerges that cache with the local run's coverage, producing a data set with two disjoint path roots.php-code-coverage's report builder silently skips every file whose reconstructed path failsis_file(), so the final report has zero file nodes: Pest prints an empty per-file table with a bogusTotal: 100.0 %, and--coverage --min=Xpasses regardless of the real coverage — the check fails open with no warning.The fix
Make the cache path-portable and refuse to merge what cannot be mapped:
serializeRelativeToProjectRoot()): the cache now stores file paths relative to the project root (canonical/separators), so a baseline recorded on CI stays meaningful on any machine that downloads it.readCache()/rebaseOntoProjectRoot()): relative entries are mapped onto the local project root before the strip + merge. Absolute entries under the local root are kept, preserving caches written by previous versions on the same machine. Absolute entries of another machine make the cache unusable — it is discarded and the current run seeds a fresh (portable) one, so the printed report falls back to correct current-run data instead of an empty table that satisfies--min.Tests
tests/Unit/Plugins/Tia/CoverageMergerPortability.php(new):Note: this touches the same
applyIfMarked()flow as #1792 — the two fixes are independent but will conflict textually; happy to rebase whichever lands second.🤖 Generated with Claude Code