Commit 327dae2
Add CI with embedded tests via Wokwi simulation (#138)
* chore: implement two-branch workflow (main + dev) (#134)
- Create dev branch for active development
- Update pre-commit hooks to protect both main and dev branches
- Document branching strategy in CONTRIBUTING.md
- Align with simplified workflow for small team
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
* docs: add detailed daily and release workflow instructions (#135)
* fix: remove broken image links from CONTRIBUTING.md (#136)
Remove references to non-existent assets/images directory:
- table-of-contents.png
- contribution_cta.png
These were leftover from the GitHub docs template.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
* docs: add CLAUDE.md for Claude Code guidance
Add configuration file for Claude Code AI assistant with:
- Build commands for PlatformIO
- Architecture overview and key files
- Real-time constraints and memory limitations
- Code style and safety requirements
- Git workflow and test structure
Co-Authored-By: Claude (global.anthropic.claude-opus-4-5-20251101-v1:0) <noreply@anthropic.com>
* test: add relay engine edge case tests
Add comprehensive tests for RelayEngine behavior:
- settle_change: verify 60s delay at startup, reset after state change,
blocks both turn-ON and turn-OFF operations
- relay_ordering: verify ascending order for turn-ON (surplus),
descending order for turn-OFF (import) with 3 relays
- duration_overflow: verify counter saturates at UINT16_MAX without
wrapping, which would incorrectly block relay changes
Each test suite uses separate EWMA instances (different D parameters)
to ensure test isolation.
Co-Authored-By: Claude (global.anthropic.claude-opus-4-5-20251101-v1:0) <noreply@anthropic.com>
* refactor: convert override and relay tests to native, add CI
- Extract config-dependent helpers to utils_override_helpers.h using
if constexpr for compile-time branch verification
- Remove config.h dependency from utils_override.h to fix circular deps
- Convert embedded relay tests to native tests (no Arduino required)
- Add native tests for override utilities (PinList, OverridePins, etc.)
- Add native test for RELAY_DIVERSION=false scenario
- Add native test step to CI workflow with proper ignore patterns
Co-Authored-By: Claude (global.anthropic.claude-opus-4-5-20251101-v1:0) <noreply@anthropic.com>
* chore: simplify CI test command
Remove redundant --ignore="*embedded*" flag since test_ignore in
platformio.ini already handles embedded test exclusion.
Co-Authored-By: Claude (global.anthropic.claude-opus-4-5-20251101-v1:0) <noreply@anthropic.com>
* fix: correct EWMA benchmark test assertion
The test incorrectly assumed TEMA has better cloud immunity than fast EMA.
TEMA reduces lag (for responsiveness) but can overshoot, causing more
threshold crossings. The correct assertion is that slow EMA (high α)
has fewer relay toggles than fast EMA - this is the actual cloud immunity
property.
Also remove --ignore flag from CI since the test now passes.
Co-Authored-By: Claude (global.anthropic.claude-opus-4-5-20251101-v1:0) <noreply@anthropic.com>
* ci: add dev branch to CI triggers
Run CI on push and pull requests to both main and dev branches.
Co-Authored-By: Claude (global.anthropic.claude-opus-4-5-20251101-v1:0) <noreply@anthropic.com>
* ci: restructure workflow into setup, build, and test jobs
- Split monolithic job into three separate jobs:
- setup: installs dependencies and populates cache
- build: compiles firmware (runs after setup)
- test: runs native tests (runs after setup)
- Build and test jobs run in parallel after setup completes
- Use PROJECT_DIR env variable to reduce repetition
- Improve cache key using platformio.ini hash for better invalidation
Co-Authored-By: Claude (global.anthropic.claude-opus-4-5-20251101-v1:0) <noreply@anthropic.com>
* refactor: extract bit utilities to utils_bits.h
Create utils_bits.h with bit_set, bit_read, bit_clear template functions
that have no Arduino dependencies. This eliminates code duplication in
native tests which previously had to copy these functions.
- New utils_bits.h with portable bit manipulation functions
- Update utils_pins.h to include utils_bits.h
- Update native tests to use utils_bits.h instead of inline copies
Co-Authored-By: Claude (global.anthropic.claude-opus-4-5-20251101-v1:0) <noreply@anthropic.com>
* refactor: move relay tests from native to embedded
Native tests with stubs can diverge from real code. Moving relay tests
to embedded ensures they test the actual RelayEngine and relayOutput
implementations on real hardware.
- Remove native/test_utils_relay (had stub implementations)
- Add embedded/test_utils_relay (uses real utils_relay.h)
Co-Authored-By: Claude (global.anthropic.claude-opus-4-5-20251101-v1:0) <noreply@anthropic.com>
* refactor: use real utils_override.h in native tests
Remove duplicate PinList, KeyIndexPair, OverridePins classes from tests.
Tests now include the real utils_override.h header directly, ensuring
they test the actual production code.
- Guard printOverrideConfig() with #ifdef ARDUINO for native compatibility
- Remove ~200 lines of duplicated class definitions from test file
- Tests now verify the REAL implementation
Co-Authored-By: Claude (global.anthropic.claude-opus-4-5-20251101-v1:0) <noreply@anthropic.com>
* refactor: move override tests to embedded (no stubs)
Native tests with stubs diverge from real code. Moving override tests
to embedded ensures they test the REAL RelayEngine, relayOutput, and
config values on actual hardware.
Native tests now only contain pure algorithm tests (EWMA, cloud patterns,
negative threshold) that don't need any stubs.
- Remove native/test_utils_override (had TestRelayEngine stub)
- Remove native/test_override_no_relay (had RelayEngine stub)
- Add embedded/test_utils_override (uses real config.h)
Co-Authored-By: Claude (global.anthropic.claude-opus-4-5-20251101-v1:0) <noreply@anthropic.com>
* refactor: remove native tests with stubs
Remove native tests that contained duplicated/stubbed code:
- test_ewma_benchmark (had copied EWMA_average class)
- test_cloud_patterns (had copied EWMA_average, TestRelay stub)
- test_negative_threshold (had MockRelayOutput stub)
Only test_ewma_avg remains - it uses the real ewma_avg.hpp header.
Tests requiring relay/config code must be embedded tests to use real code.
Co-Authored-By: Claude (global.anthropic.claude-opus-4-5-20251101-v1:0) <noreply@anthropic.com>
* refactor: move override tests back to native (pure C++)
Override utilities (PinList, KeyIndexPair, OverridePins) are pure
bitmask operations with no Arduino dependencies. Tests now use real
utils_override.h header with test values to cover all cases.
Co-Authored-By: Claude (global.anthropic.claude-opus-4-5-20251101-v1:0) <noreply@anthropic.com>
* fix: restore full relay test suite
Restore the comprehensive relay tests that were accidentally lost:
- settle_change tests (60s startup delay, reset after state change)
- relay_ordering tests (ascending ON, descending OFF)
- duration_overflow tests (UINT16_MAX saturation)
Co-Authored-By: Claude (global.anthropic.claude-opus-4-5-20251101-v1:0) <noreply@anthropic.com>
* fix: update FastDivision tests to match actual API
The tests were testing non-existent functions (divu5, divu15, divu60).
Updated to test only the functions that actually exist:
- divu10: AVR assembly divide by 10
- divmod10: AVR assembly divide/modulo by 10
- divu8, divu4, divu2, divu1: constexpr shift-based divisions
Co-Authored-By: Claude (global.anthropic.claude-opus-4-5-20251101-v1:0) <noreply@anthropic.com>
* fix: include FastDivision.cpp in test for linking
PlatformIO test builds don't automatically include project source files.
Include FastDivision.cpp directly in the test to resolve undefined
reference errors for divu10 and divmod10.
Co-Authored-By: Claude (global.anthropic.claude-opus-4-5-20251101-v1:0) <noreply@anthropic.com>
* ci: add Wokwi simulation for embedded tests
Configure Wokwi CI to run embedded unit tests in simulation:
- Add diagram.json for Arduino Uno simulation
- Add wokwi.toml for each embedded test
- Update workflow with test-embedded job using matrix strategy
- Tests run in parallel: fastdivision, utils_pins, utils_relay, teleinfo
Requires WOKWI_CLI_TOKEN secret to be configured in GitHub.
Co-Authored-By: Claude (global.anthropic.claude-opus-4-5-20251101-v1:0) <noreply@anthropic.com>
* fix: correct diagram_file path for Wokwi CI
Co-Authored-By: Claude (global.anthropic.claude-opus-4-5-20251101-v1:0) <noreply@anthropic.com>
* fix: specify elf path directly in Wokwi action
Co-Authored-By: Claude (global.anthropic.claude-opus-4-5-20251101-v1:0) <noreply@anthropic.com>
* fix: run embedded tests sequentially with proper filter
- Changed from parallel matrix to sequential loop
- Fixed test filter pattern to use wildcard (*test_name*)
- All tests share same build directory so must run one at a time
Co-Authored-By: Claude (global.anthropic.claude-opus-4-5-20251101-v1:0) <noreply@anthropic.com>
* fix: add wokwi-cli to PATH after installation
Co-Authored-By: Claude (global.anthropic.claude-opus-4-5-20251101-v1:0) <noreply@anthropic.com>
* fix: use relative path for diagram-file in wokwi-cli
Co-Authored-By: Claude (global.anthropic.claude-opus-4-5-20251101-v1:0) <noreply@anthropic.com>
* ci: use matrix for individual test visibility
- Native tests: matrix with test_ewma_avg, test_utils_override (parallel)
- Embedded tests: matrix with max-parallel:1 (sequential, separate jobs)
- Each test now shows as a separate job in GitHub Actions UI
- Use GITHUB_PATH for wokwi-cli instead of export
Co-Authored-By: Claude (global.anthropic.claude-opus-4-5-20251101-v1:0) <noreply@anthropic.com>
* ci: run embedded tests in parallel, add detailed results
- Remove max-parallel (each job has its own workspace)
- Add job summary with test results (PASS/FAIL lines)
- Upload wokwi-output.txt as artifact for full logs
Co-Authored-By: Claude (global.anthropic.claude-opus-4-5-20251101-v1:0) <noreply@anthropic.com>
* ci: add dorny/test-reporter for detailed test results
- Convert Unity output to JUnit XML format
- Use dorny/test-reporter to display results with expandable details
- Add checks:write permission for test reporter
- Upload both raw output and XML as artifacts
Co-Authored-By: Claude (global.anthropic.claude-opus-4-5-20251101-v1:0) <noreply@anthropic.com>
* fix: handle non-UTF-8 characters in test output
Co-Authored-By: Claude (global.anthropic.claude-opus-4-5-20251101-v1:0) <noreply@anthropic.com>
* docs: add CI badge to README
Co-Authored-By: Claude (global.anthropic.claude-opus-4-5-20251101-v1:0) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>1 parent 08b79be commit 327dae2
23 files changed
Lines changed: 1485 additions & 1433 deletions
File tree
- .github/workflows
- Mk2_3phase_RFdatalog_temp
- test
- embedded
- test_fastdivision
- test_teleinfo
- test_utils_pins
- test_utils_relay
- native
- test_cloud_patterns
- test_ewma_benchmark
- test_negative_threshold
- test_utils_override
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
| 2 | + | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
| 7 | + | |
6 | 8 | | |
7 | | - | |
8 | | - | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
14 | 17 | | |
15 | | - | |
16 | 18 | | |
17 | | - | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
18 | 50 | | |
19 | | - | |
| 51 | + | |
| 52 | + | |
20 | 53 | | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
21 | 63 | | |
22 | | - | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
23 | 89 | | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
10 | | - | |
11 | 9 | | |
12 | 10 | | |
13 | 11 | | |
| |||
18 | 16 | | |
19 | 17 | | |
20 | 18 | | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
21 | 82 | | |
22 | 83 | | |
23 | 84 | | |
| |||
40 | 101 | | |
41 | 102 | | |
42 | 103 | | |
43 | | - | |
44 | | - | |
45 | 104 | | |
46 | 105 | | |
47 | 106 | | |
| |||
125 | 184 | | |
126 | 185 | | |
127 | 186 | | |
128 | | - | |
| 187 | + | |
129 | 188 | | |
130 | 189 | | |
131 | 190 | | |
| |||
0 commit comments