Add code coverage checks to CI - #6
Merged
Merged
Conversation
Instruments the native env with --coverage (gcc/clang gcov flags). PlatformIO's build_flags only reach the compile step, not the link step, so a small extra_scripts hook appends --coverage to LINKFLAGS too — otherwise the gcov runtime symbols are undefined at link time. CI now runs gcovr against src/ (excluding main.cpp, which is Arduino-only and can't run on native) after the unit tests, prints a summary to the job summary, and fails the job if line coverage drops below 90%. No external service/account needed. Also documents the coverage bar in CLAUDE.md so future changes keep it in mind rather than lowering the threshold to unblock a PR. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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
nativePlatformIO env with--coverage. PlatformIO'sbuild_flagsonly reach the compile step, not the link step, soscripts/native_coverage_linkflags.py(wired up viaextra_scripts) appends--coveragetoLINKFLAGStoo — otherwise the gcov runtime symbols are undefined at link time.native-testsjob now runsgcovragainstsrc/(excludingmain.cpp, which is Arduino-only and can't run on the native/host target) after the unit tests, writes a summary to the job summary, and fails the job if line coverage drops below 90%. No external service or account needed.Test plan
pio test -e nativepasses locally with coverage instrumentation enabledgcovr --root . --filter 'src/' --exclude 'src/main\.cpp' --print-summary --fail-under-line 90reports 100% coverage locally (macOS/clang, via--gcov-executable "xcrun llvm-cov gcov")🤖 Generated with Claude Code