Skip to content

ci: ignore generated code in codecov reporting#122

Merged
sofq merged 4 commits intomainfrom
fix/codecov-ignore-generated
Apr 18, 2026
Merged

ci: ignore generated code in codecov reporting#122
sofq merged 4 commits intomainfrom
fix/codecov-ignore-generated

Conversation

@sofq
Copy link
Copy Markdown
Owner

@sofq sofq commented Apr 18, 2026

Summary

  • Codecov dropped from 100% to 8.71% on ci: restore full test coverage and remove duplicate e2e stub #121 because expanding CI to ./cmd/... pulled in cmd/generated/ (51k LOC of OpenAPI-generated commands) at 0% coverage.
  • Adds codecov.yml to exclude cmd/generated/** and cmd/gendocs/** so the ratio reflects hand-written code only.

Test plan

  • Codecov report on this PR shows restored coverage (~100% on tested packages)

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

codecov Bot commented Apr 18, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

sofq added 3 commits April 18, 2026 16:35
- 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.
@sofq sofq merged commit 37ec106 into main Apr 18, 2026
15 checks passed
@sofq sofq deleted the fix/codecov-ignore-generated branch April 18, 2026 09:57
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