Fix Codecov 0%: fix coverage.json, rm gem codecov#2857
Merged
Conversation
Our earlier commit e2de938 created the file coverage/codecov-result.json fixing the "Found 0 coverage files" error, but the site still showed 0%. Codecov's backend rejected the upload as "Unusable report ... incorrect data format": the abandoned codecov 0.6.0 gem's formatter emits the deprecated v2 "network" report format (a filename list, a "<<<<<< network" separator, then one line of coverage JSON) which isn't even valid JSON despite the .json name. The pinned Codecov CLI uploaded it without complaint because `--plugin noop` means it never parses the file, so the upload step looked healthy while the backend silently discarded the data. This commit changes the approach for recording coverage results. Now we write coverage/coverage.json with SimpleCov::Formatter::JSONFormatter (from simplecov_json_formatter), whose output Codecov parses natively, and point the CLI --file at it. As before this runs in test:coverage_gaps rather than test_helper.rb, because CI runs with DEFER_COVERAGE set (swapping in SimpleFormatter) and the merged result is only complete once all parallel + system runs finish. This removes the abandoned codecov gem entirely and drops its dead formatter reference from test_helper.rb (it never ran in CI anyway, since DEFER_COVERAGE overrode it). The codecov gem was the only thing pulling in simplecov, including its <0.22 pin, so we now list simplecov and simplecov_json_formatter explicitly: both are required directly (in test_helper.rb and test:coverage_gaps respectively), so declaring them prevents a future simplecov release that stops bundling the JSON formatter from breaking coverage reporting in a surprising way. Signed-off-by: David A. Wheeler <dwheeler@dwheeler.com> Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: David A. Wheeler <dwheeler@dwheeler.com>
Welcome to Codecov 🎉Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests. Thanks for integrating Codecov - We've got you covered ☂️ |
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.
Our earlier commit e2de938 created the file
coverage/codecov-result.json fixing the
"Found 0 coverage files" error, but the site still showed 0%. Codecov's backend rejected the upload as "Unusable report ... incorrect data format": the abandoned codecov 0.6.0 gem's formatter emits the deprecated v2 "network" report format (a filename list, a "<<<<<< network" separator, then one line of coverage JSON) which isn't even valid JSON despite the .json name. The pinned Codecov CLI uploaded it without complaint because
--plugin noopmeans it never parses the file, so the upload step looked healthy while the backend silently discarded the data.This commit changes the approach for recording coverage results. Now we write coverage/coverage.json with SimpleCov::Formatter::JSONFormatter (from simplecov_json_formatter), whose output Codecov parses natively, and point the CLI --file at it. As before this runs in test:coverage_gaps rather than test_helper.rb, because CI runs with DEFER_COVERAGE set (swapping in SimpleFormatter) and the merged result is only complete once all parallel + system runs finish.
This removes the abandoned codecov gem entirely and drops its dead formatter reference from test_helper.rb (it never ran in CI anyway, since DEFER_COVERAGE overrode it). The codecov gem was the only thing pulling in simplecov, including its <0.22 pin, so we now list simplecov and simplecov_json_formatter explicitly: both are required directly (in test_helper.rb and test:coverage_gaps respectively), so declaring them prevents a future simplecov release that stops bundling the JSON formatter from breaking coverage reporting in a surprising way.