Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,24 @@ jobs:
key: ${{ runner.os }}-platformio-native-${{ hashFiles('platformio.ini') }}

- name: Install PlatformIO
run: pip install --upgrade platformio
run: pip install --upgrade platformio gcovr

- name: Run native unit tests
run: pio test -e native

- name: Coverage report
run: |
output=$(gcovr --root . --filter 'src/' --exclude 'src/main\.cpp' --print-summary --fail-under-line 90)
status=$?
{
echo '### Coverage (src/, excluding main.cpp)'
echo '```'
echo "$output"
echo '```'
} >> "$GITHUB_STEP_SUMMARY"
echo "$output"
exit $status

kb2040-build:
runs-on: ubuntu-latest
steps:
Expand Down
1 change: 1 addition & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- All new logic should have unit tests in `test/` to prevent regressions.
- Tests run on the native PlatformIO environment (no hardware required) — keep them that way. Do not introduce test dependencies that require Arduino or physical hardware.
- When fixing a bug, add a test that would have caught it.
- CI enforces a minimum line-coverage threshold (via `gcovr`, currently 90%) on `src/`, excluding `main.cpp` (Arduino-only, can't run on native). Keep new logic covered well enough to not drop below that bar — don't lower the threshold in `.github/workflows/ci.yml` just to unblock a PR; that's a deliberate call for a human to make.

**Bug fixes and regression test**
- Any time you fix a bug, that bugfix should be covered by a new regression test.
Expand Down
2 changes: 2 additions & 0 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,5 @@ platform = native
test_build_src = yes
build_src_filter = +<*> -<main.cpp>
test_framework = unity
build_flags = --coverage
extra_scripts = pre:scripts/native_coverage_linkflags.py
5 changes: 5 additions & 0 deletions scripts/native_coverage_linkflags.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Import("env")

# PlatformIO's `build_flags` only reach the compile step for --coverage; the
# link step needs it too so the gcov/profiling runtime gets linked in.
env.Append(LINKFLAGS=["--coverage"])
Loading