ci: ignore generated code in codecov reporting#122
Merged
Conversation
cmd/generated (51k LOC of OpenAPI-generated command code) and cmd/gendocs are not meaningful for coverage tracking. Excluding them restores the coverage ratio from ~9% back to the true test coverage of hand-written code.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
- Add tests for cmd/root.go PersistentPreRunE/PostRunE branches (preset expansion, policy check, audit logger setup, help func) - Add tests for cmd/raw.go --body - stdin path - Add tests for cmd/batch.go stdin stat/read error branches - Add tests for internal/template loadUserTemplates missing-dir path - Add tests for Execute() success/AlreadyWrittenError/generic error paths - Ignore main.go in codecov (3-line entry point) Brings local coverage to 99.9% with only main.go uncovered (now ignored).
These anonymous closures were not exercised by existing tests, so codecov reported them as 0-hit even though named functions showed 100%. Add direct invocations of RunE for each command, including jq/pretty/error branches. Also cover the preset.Lookup error path in PersistentPreRunE and ensure makePreRunCmd resets rootCmd's persistent flags between tests to prevent state pollution across test runs.
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
./cmd/...pulled incmd/generated/(51k LOC of OpenAPI-generated commands) at 0% coverage.codecov.ymlto excludecmd/generated/**andcmd/gendocs/**so the ratio reflects hand-written code only.Test plan