Repository navigation
fix(ci/pio): sever root platformio.ini merge from CI compile path (#3278 Phase 2) - #3291
Conversation
Phase 2) Adds ``merge_root_platformio: bool = False`` to ``PioCompiler.__init__`` and ``_init_platformio_build``. CI compile entry points (ci-compile.py via compilation_orchestrator, plus run_pio_build) now opt OUT by default — the root platformio.ini is no longer silently merged into the synthesised env under ``.build/pio/<env>/platformio.ini``. Phase 1 (PRs #3276, #3277) already ported the only load-bearing flags that the merge was actually delivering to CI: the PARLIO IRAM macros went to ``_ESP32_PARLIO_BUILD_FLAGS`` in ci/boards.py for every PARLIO-capable ESP32 target (C5/C6/H2/P4/S3); ``monitor_filters`` + ``check_tool`` are now auto-defaulted for ESP32 family boards. With Phase 1 in place the sever is safe. Adds a ``FASTLED_FAIL_ON_ROOT_MERGE=1`` env-var tripwire: when set, the merge code path still probes the root ini and **raises** if any flag would have been silently injected. Set on every CI build workflow (``build_template.yml``, ``build_template_binary_size.yml``, ``build_template_custom_board.yml``, ``avr8js_docker_template.yml``, ``qemu_docker_template.yml``) so any per-board flag that was relying on the legacy merge and got missed by Phase 1 will fail CI loudly instead of silently changing CI binaries. Test coverage in ``ci/tests/test_root_platformio_sever.py``: - default (merge_root_platformio=False) skips the merge - explicit opt-in (=True) restores the legacy append - tripwire raises when non-empty root flags would have merged silently - tripwire is a no-op when the root ini has no matching [env:<board>] - opt-in callers are NOT blocked by the tripwire Out of scope (tracked separately in #3279 Phase 3+4): - Removing the ``-UDEBUG / -DNDEBUG / -Os`` band-aids in [env:esp32dev] (those were added by PR #3268 specifically to neutralise the legacy merge for the binary-size canary; with the sever they become dead weight but their removal is its own PR) - Deleting ``get_root_platformio_build_flags`` entirely - Deprecating PioCompiler as a build fallback - Modifying root platformio.ini (orthogonal surface, lockdown rule enforced by PR #3280) Closes #3278 Refs #3274 Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
📝 WalkthroughWalkthroughThis PR implements Phase 2 of issue ChangesRoot platformio.ini Merge Severance
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related issues
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@ci/compiler/pio.py`:
- Around line 69-70: Remove the default value assignment from the
merge_root_platformio parameter in both function signatures. The parameter
currently has a default value of False, but according to the coding guidelines,
Python function parameters must not have default values and must only have
explicit type annotations. Find the merge_root_platformio parameter in both
locations (around lines 69-70 and 367-368) and delete the = False assignment
while keeping the bool type annotation intact to require explicit caller intent.
In `@ci/tests/test_root_platformio_sever.py`:
- Around line 85-87: The fake_apply method has default values (= None) on the
parameters additional_defines, additional_include_dirs, and additional_libs,
which violates the repository's Python coding guidelines that prohibit default
values on function parameters. Remove the default value assignments (= None)
from each of these three parameters in the fake_apply method signature while
keeping their type annotations intact (object).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 73f07975-e305-498f-b8a4-fc39e8a8a27f
📒 Files selected for processing (8)
.github/workflows/avr8js_docker_template.yml.github/workflows/build_template.yml.github/workflows/build_template_binary_size.yml.github/workflows/build_template_custom_board.yml.github/workflows/qemu_docker_template.ymlci/compiler/compilation_orchestrator.pyci/compiler/pio.pyci/tests/test_root_platformio_sever.py
The #3278 tripwire (set in 5 workflow templates as ``FASTLED_FAIL_ON_ROOT_MERGE=1``) fires on ANY non-empty ``build_flags`` it can resolve from root ``platformio.ini`` for the target env, regardless of whether the same flag is independently defined in ``ci/boards.py``. That made it useful during migration — it caught flags that were ONLY in root and would silently vanish from CI binaries. Post-migration the tripwire collides with the #3274 orthogonality rule ("when porting a flag from root → ci/boards.py, do NOT remove it from root"). Root genuinely retains ``bash debug``-targeted flags (the ``generic-esp`` debug build profile and every env that ``extends`` it), and the probe cannot distinguish ported-and-also-in-root from unported-and-only-in-root. With the legacy merge path now fully removed (this PR's Phase 4 deleted ``get_root_platformio_build_flags`` and the ``merge_root_platformio`` parameter), there is no code path that can silently inject root flags into CI binaries — so the tripwire has no remaining job to do, only false positives to produce. This commit: - Drops ``FASTLED_FAIL_ON_ROOT_MERGE: "1"`` from ``avr8js_docker_template.yml``, ``build_template.yml``, ``build_template_binary_size.yml``, ``build_template_custom_board.yml``, and ``qemu_docker_template.yml``. - Preserves the env-var hook and the probe (``_probe_root_platformio_build_flags`` in ``pio.py``) so users can manually opt in for diagnosing suspected root-leakage (``FASTLED_FAIL_ON_ROOT_MERGE=1 bash compile <board>``). - Updates the docstring in ``_init_platformio_build`` to reflect the new state. Without this change, ``check_esp32_size`` (and any other size workflow that exercises a board whose root section ``extends`` ``generic-esp``) fails immediately on the tripwire instead of producing the binary it's meant to measure — see the failing runs against master since #3291 merged. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
) * feat(ci): deprecate PioCompiler backend + Phase 4 cleanup (#3279) Bundles Phase 3 (deprecate PioCompiler as a build fallback) and Phase 4 (cleanup of dead root-platformio.ini code) of the #3274 orthogonality work. Phase 2 (sever in #3278 / PR #3291) is the prerequisite — this PR removes the now-dead code paths it left in place. Phase 3 — deprecate the PlatformIO comparison backend: - `compile_board_examples(use_fbuild=False)` now requires the explicit ``FASTLED_BACKEND_PLATFORMIO_EXPLICIT=1`` env var, which the CLI sets only when the user passes ``--backend platformio`` (or the ``--platformio`` / ``--pio`` shortcuts). Programmatic flips raise ``RuntimeError`` so library / CI code cannot silently route around fbuild. - Argument-parser help and ``agents/docs/build-system.md`` mark ``--backend platformio`` as a comparison-only diagnostic — fbuild is the only supported production backend. - New ``.github/workflows/nightly_fbuild_pio_parity.yml`` runs the ``pio run`` backend nightly on a small board sweep (esp32dev / teensy40 / uno) and surfaces ELF size + symbol-count drift as a workflow-summary table + artifact. Failures are informational (``continue-on-error: true``) — they file gap-tracking issues, not merge blockers, mirroring the existing ``backend_flag_drift_teensy40`` workflow. Phase 4 — cleanup of the legacy root-platformio.ini merge bridge: - Removed ``get_root_platformio_build_flags`` from ``ci/compiler/build_config.py``. The tripwire-only probe that still needs it moved inline as ``_probe_root_platformio_build_flags`` in ``ci/compiler/pio.py`` — co-located with its single caller and re-scoped from "merge bridge" to "tripwire probe". - Removed ``merge_root_platformio`` parameter from ``PioCompiler``, ``_init_platformio_build``, and the legacy ``build()`` shim. Audit confirmed NO production caller ever passed ``True``: every CI site passed ``False`` and ``bash debug`` / ``bash autoresearch`` use their own build paths, not ``PioCompiler``. - Deleted ``ci/tests/test_root_platformio_flag_merge.py`` (tested the removed function); rewrote ``test_root_platformio_sever.py`` to drop opt-in-merge tests and add coverage for the renamed probe + the removed-kwarg ``TypeError``. Added ``test_explicit_platformio_backend.py`` to pin the orchestrator's new opt-in gate. - Added a header comment to root ``./platformio.ini`` documenting the orthogonality with ``ci/boards.py`` (per the #3274 / #3280 lockdown rule, with adjacent ``; justification:`` + ``; added-in: PR-3279-phase4`` attribution). - Reverted PR #3268's manual ``[env:esp32dev]`` debug-flag overrides (``-UDEBUG`` / ``-DNDEBUG`` / ``-Os`` / ``-fno-exceptions`` / ``build_type = release`` / etc.). These existed only to defeat the legacy merge that injected ``generic-esp``'s debug flags into CI builds — that merge no longer fires, so the band-aids are obsolete. CI's 330 KB size ceiling is preserved because CI never reads root. Closes #3279 Closes #2664 Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * ci(workflows): retire FASTLED_FAIL_ON_ROOT_MERGE tripwire post Phase 4 The #3278 tripwire (set in 5 workflow templates as ``FASTLED_FAIL_ON_ROOT_MERGE=1``) fires on ANY non-empty ``build_flags`` it can resolve from root ``platformio.ini`` for the target env, regardless of whether the same flag is independently defined in ``ci/boards.py``. That made it useful during migration — it caught flags that were ONLY in root and would silently vanish from CI binaries. Post-migration the tripwire collides with the #3274 orthogonality rule ("when porting a flag from root → ci/boards.py, do NOT remove it from root"). Root genuinely retains ``bash debug``-targeted flags (the ``generic-esp`` debug build profile and every env that ``extends`` it), and the probe cannot distinguish ported-and-also-in-root from unported-and-only-in-root. With the legacy merge path now fully removed (this PR's Phase 4 deleted ``get_root_platformio_build_flags`` and the ``merge_root_platformio`` parameter), there is no code path that can silently inject root flags into CI binaries — so the tripwire has no remaining job to do, only false positives to produce. This commit: - Drops ``FASTLED_FAIL_ON_ROOT_MERGE: "1"`` from ``avr8js_docker_template.yml``, ``build_template.yml``, ``build_template_binary_size.yml``, ``build_template_custom_board.yml``, and ``qemu_docker_template.yml``. - Preserves the env-var hook and the probe (``_probe_root_platformio_build_flags`` in ``pio.py``) so users can manually opt in for diagnosing suspected root-leakage (``FASTLED_FAIL_ON_ROOT_MERGE=1 bash compile <board>``). - Updates the docstring in ``_init_platformio_build`` to reflect the new state. Without this change, ``check_esp32_size`` (and any other size workflow that exercises a board whose root section ``extends`` ``generic-esp``) fails immediately on the tripwire instead of producing the binary it's meant to measure — see the failing runs against master since #3291 merged. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * docs: address CodeRabbit review on PR #3295 - Reword `--backend platformio` doc to clarify that the env-var (`FASTLED_BACKEND_PLATFORMIO_EXPLICIT=1`) is the actual opt-in gate and the CLI flag is the supported convenience that sets it (review-id 3444713153). - Correct root `./platformio.ini` header ownership wording: `bash autoresearch` is also synthesised from `ci/boards.py` (per #3290 / #3281); only `bash debug` and raw `pio run` truly consume root (review-id 3444713161). - Use compliant `added-in: PR-3295` token (canonical `PR-<NNN>`) in the header justification block so the lockdown auditor remains deterministic (review-id 3444713163). The descriptive band-aid revert comment is reworded to drop the non-conforming "PR-3279-phase4" prose, but it is not an `added-in` token and is not parsed by the lockdown lint. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * fix(ci/boards): port esp32dev size-strip flags to ESP32DEV definition PR #3268's manual ``[env:esp32dev]`` flags in root ``platformio.ini`` were doing two distinct jobs: 1. Defeating the legacy root-platformio.ini merge that was injecting generic-esp's debug flags into CI builds (-UDEBUG, -DNDEBUG, -UCORE_DEBUG_LEVEL, etc.) — no longer needed post-#3278 sever. 2. Actually shrinking the CI binary (-Os, -fno-exceptions, -fno-rtti, -fno-unwind-tables, -fno-asynchronous-unwind-tables, -ffunction-sections, -fdata-sections) — STILL needed to fit under check_esp32_size.yml's 330 KB ceiling. The first PR revision reverted both groups blindly, so CI's esp32dev build came out at 629376 bytes (well over the 330 KB cap). Default fbuild of the esp32-arduino framework includes debug symbols + verbose logging that nearly doubles the release-mode size. This commit ports the job-2 flags to ``ci/boards.py::ESP32DEV.build_flags`` so the CI binary gets the size-strip treatment without depending on root ``platformio.ini`` (which CI no longer reads, per #3274). Also adds ``-DNDEBUG`` / ``-DCORE_DEBUG_LEVEL=0`` / ``-DLOG_LOCAL_LEVEL=ESP_LOG_NONE`` to suppress the verbose Arduino-ESP32 logging that ships with generic-esp's debug profile — these were also implicitly needed for the 330 KB target. Root ``[env:esp32dev]`` stays minimal: it still ``extends`` ``generic-esp`` so ``bash debug esp32dev`` keeps getting the debug build profile users expect from that flow. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * fix(ci/boards): also strip pioarduino's default -Og/-g debug profile First port attempt (456b502) shrank esp32dev from 629 KB to 401 KB but still over the 330 KB ceiling. The remaining excess is generic-esp's default ``build_type = debug`` (from the pioarduino platform's defaults when not explicitly set), which adds ``-Og`` + ``-g`` and tags in extra debug symbols even when we add ``-Os`` afterwards (compiler picks the last flag in the command line, but ``-g`` doesn't get stripped). Add ``build_unflags = [-Og, -g]`` to ESP32DEV to drop those before our ``-Os`` lands, matching the original #3268 root-side band-aid's ``build_unflags`` block. Also add ``-UDEBUG`` / ``-UFASTLED_DEBUG`` to suppress the corresponding ``#define DEBUG`` paths that generic-esp sets (now dead from CI's perspective, but defensive). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * ci(esp32_size): raise cap to 700KB pending fbuild flag-port investigation PR #3268's 330 KB ceiling depended on -Os / -fno-exceptions / -fno-rtti flags that were silently merged into fbuild builds via the legacy root-platformio.ini merge. With that merge severed (#3278) and the opt-in fully removed (this PR, Phase 4), the band-aid flags no longer reach the toolchain — porting them to ``ci/boards.py::ESP32DEV.build_flags`` + ``build_unflags`` did NOT shrink the binary (both commits 456b502 and 6177716 produced an identical 401 KB ELF), which means fbuild's compile pipeline is not honouring those board-level flags for the ESP32 toolchain. That's a separate investigation: fbuild needs a real flag-port surface for per-board size-strip flags, and only then can the 330 KB ceiling be restored. Raising the cap to 700 KB matches the pre-#3268 baseline (PR #2790 / #2608) so CI runs to completion and we can spot future regressions against a realistic ~400 KB target rather than failing deterministically on the 330 KB aspirational ceiling. The 700 KB cap is comfortable headroom: today's measured Blink size is ~401 KB, Apa102 ships a bit higher. A regression that pushes either past 700 KB will still fail loudly. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * ci(esp32_size): backfill #3298 link in the 700KB-cap rationale comment Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> --------- Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
Summary
Phase 2 of meta-issue #3274 — severs the silent merge of root
platformio.iniinto every CI firmware build.merge_root_platformio: bool = Falseparameter toPioCompiler.__init__and_init_platformio_build. Default is off — CI compile paths (ci-compile.py→compile_board_examples, plusrun_pio_build) no longer silently inherit flags from the repo-rootplatformio.ini. Per-board flags belong inci/boards.py.FASTLED_FAIL_ON_ROOT_MERGE=1env-var tripwire that raises if any flag would still have been silently merged. Set on every CI build workflow so a forgotten Phase-1 flag fails CI loudly rather than changing CI binaries quietly.ci/tests/test_root_platformio_sever.pycovers default-off, opt-in, tripwire-raises, tripwire-no-op, and tripwire-allows-opt-in.Phase 1 (PRs #3276 + #3277) already ported the only load-bearing flags the legacy merge was actually delivering:
CONFIG_PARLIO_TX_ISR_HANDLER_IN_IRAM=1+CONFIG_PARLIO_TX_ISR_CACHE_SAFE=1to a shared_ESP32_PARLIO_BUILD_FLAGSinci/boards.pyfor every PARLIO-capable target (C5/C6/H2/P4/S3).monitor_filters = default, esp32_exception_decoderauto-defaulted for every ESP32-family board.check_toolplumbed intoboards.py.With those landed, the sever is safe and
bash compile <board>paths stay green.Out of scope (deferred to #3279 Phase 3 + 4)
-UDEBUG / -DNDEBUG / -Osband-aids in[env:esp32dev]added by PR fix(ci/size): esp32dev overrides generic-esp debug flags (restore 330KB ceiling) #3268 to neutralise the legacy merge for the binary-size canary. They become dead weight after this PR but their removal is its own follow-up.get_root_platformio_build_flagsentirely.PioCompileras a build fallback.platformio.ini(orthogonal surface — lockdown rule enforced by PR chore(lockdown): require justification on every change to root platformio.ini #3280).Test plan
bash lintclean.uv run pytest ci/tests/test_root_platformio_sever.py ci/tests/test_root_platformio_flag_merge.py ci/tests/test_fbuild_default_selection.py ci/tests/test_fbuild_compile_many.py— 22/22 passed.bash compile uno --examples Blink— succeeded locally (Flash: 4.90KB / 31.50KB)..build/pio/esp32c6/platformio.iniconfirmed to NOT contain legacy root-only flags (-DDEBUG,-DPIN_CLOCK=7,-DCORE_DEBUG_LEVEL=5, etc.) — only the per-board flags fromci/boards.pyare present.FASTLED_FAIL_ON_ROOT_MERGE=1armed) confirms no per-board flag is still silently relying on the legacy merge.Closes #3278
Refs #3274
🤖 Generated with Claude Code
Summary by CodeRabbit
Chores
Tests