Skip to content

ci: post-#2773-loop infra sweep (Closes #2852, #2853, #2854, #2855) - #2858

Merged
zackees merged 1 commit into
masterfrom
feat/2855-infra-sweep
Jun 6, 2026
Merged

zackees merged 1 commit into
masterfrom
feat/2855-infra-sweep

Conversation

@zackees

@zackees zackees commented Jun 6, 2026 •

Copy link
Copy Markdown
Member

Summary

Three small infrastructure cleanups bundled as one PR per the meta sweep #2855. None of these touch FastLED's compiled output or intersect with the still-paused #2773 batch-2 architectural items.

Closes #2852 — fbuild prog_path override misses --quick (debug/) builds

_override_prog_path_for_fbuild (landed in #2823 for the default release-mode case) silently no-ops when the user ran fbuild build --quick because fbuild lays the artifact down at <env>/debug/firmware.elf, not release/. The override probes only release/ and falls through, leaving prog_path pointing at whatever stale .pio/build/<env>/firmware.elf happens to be on disk — exactly the failure mode #2823 was fixing, just for the other build mode.

Fix: probe both release/ and debug/, pick whichever ELF is newer. Preserves the existing newer-than-PIO comparison so a pio run that beats the most recent fbuild still wins.

Tests: six new unit tests in ci/tests/test_override_prog_path_for_fbuild.py covering the matrix: release-only, debug-only, both-exist-newer-wins, no fbuild dir, PIO-newer-wins, empty fbuild tree.

Closes #2853 — prefer venv-installed zccache (Windows daemon corruption)

fbuild's Rust binary internally shells out to zccache via plain PATH resolution. On Windows it's common to have two zccache.exe on PATH — one in the project venv and one global (e.g. from clang-tool-chain). When their versions diverge, the two daemons race for the shared named pipe (\.\pipe\zccache-<user>) and corrupt state. Symptoms observed this session: 5 GB daemon RAM, all pipe instances busy after 50 retries, daemon started but not accepting connections after 10s preventing recovery.

Fix: add fbuild_subprocess_env() to ci/util/fbuild_runner.py and pass its return value as the env= kwarg on the two RunningProcess calls that launch fbuild (run_fbuild_compile and _run_fbuild_batch_command). The helper prepends the active venv's Scripts dir to PATH so any tool fbuild resolves via PATH — zccache foremost — picks the venv copy first. Mirrors what get_fbuild_executable() already does for fbuild itself.

Tests: two existing FakeRunningProcess mocks gained an env kwarg; the first asserts that PATH begins with the venv Scripts dir so the contract can't silently regress.

Closes #2854 — bare_noinline_checker regex misses compound attributes

__attribute__((naked, noinline, used)) and similar compound forms silently passed the new lint because its regex required noinline to be the only attribute inside the parens. Same MSVC-drift risk applies to the compound forms — they only escape the lint because the two existing call sites are nrf52 / teensy ARM code that never flows through MSVC. Fragile invariant.

Fix: harden the regex to match noinline anywhere inside the __attribute__(( ... )) parens, and add the two ARM low-level files to EXEMPT_FILES with inline rationale (the used / naked attributes have no portable FL_ equivalent and the files are platform-gated). The // ok noinline suppression escape hatch remains the right answer for any future case.

Closes #2855

Meta-issue tracking all three above.

Verification

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Chores

    • Build system now intelligently handles both release and debug mode artifacts, selecting the newer version when both exist.
    • Improved subprocess environment configuration to ensure build tools resolve to the correct versions.
  • Tests

    • Added comprehensive test coverage for build artifact selection behavior.
    • Enhanced CI environment propagation tests.
  • Refactor

    • Updated code linting configuration for ARM platforms.

Three small infrastructure cleanups bundled as one PR per the meta
sweep #2855. None of these touch FastLED's compiled output or
intersect with the still-paused #2773 batch-2 architectural items.

## Closes #2852 — fbuild prog_path override misses --quick (debug/) builds

`_override_prog_path_for_fbuild` (landed in #2823 for the default
release-mode case) silently no-ops when the user ran `fbuild build
--quick` because fbuild lays the artifact down at
`<env>/debug/firmware.elf`, not `release/`. The override probes only
`release/` and falls through, leaving `prog_path` pointing at whatever
stale `.pio/build/<env>/firmware.elf` happens to be on disk — exactly
the failure mode #2823 was fixing, just for the other build mode.

Probe both `release/` and `debug/`, pick whichever ELF is newer.
Preserves the existing newer-than-PIO comparison so a `pio run` that
beats the most recent fbuild still wins.

Six new unit tests in `ci/tests/test_override_prog_path_for_fbuild.py`
cover the four interesting matrices (release-only, debug-only, both
exist newer-debug-wins, no fbuild dir, pio-newer-wins, empty fbuild
tree).

## Closes #2853 — prefer venv-installed zccache (Windows daemon corruption)

fbuild's Rust binary internally shells out to `zccache` via plain
PATH resolution. On Windows it's common to have *two* zccache.exe on
PATH — one in the project venv (`.venv/Scripts/zccache.exe`) and
another globally (e.g. `C:\tools\python13\Scripts\zccache.exe` from
`clang-tool-chain`). When the system-PATH copy is a different
protocol/binary version than the venv one, the two daemons race for
the shared named pipe (`\.\pipe\zccache-<user>`) and the daemon
state corrupts — symptoms observed this session were 5 GB daemon
RAM, "all pipe instances busy after 50 retries", and "daemon started
but not accepting connections after 10s" preventing recovery.

Add `fbuild_subprocess_env()` to `ci/util/fbuild_runner.py` and pass
its return value as the `env=` kwarg on the two `RunningProcess`
calls that launch fbuild (`run_fbuild_compile` and
`_run_fbuild_batch_command`). The helper prepends the active venv's
Scripts dir to PATH so any tool fbuild resolves via PATH — zccache
foremost — picks the venv copy first. Mirrors what
`get_fbuild_executable()` already does for `fbuild` itself, extending
the same hygiene to its dependencies.

Two `FakeRunningProcess` mocks in `ci/tests/test_fbuild_compile_many.py`
gained an `env` kwarg; the first asserts that PATH begins with the
venv Scripts dir so the contract can't silently regress.

## Closes #2854 — bare_noinline_checker regex misses compound attributes

`__attribute__((naked, noinline, used))` and similar compound forms
were silently passing the new `bare_noinline_checker` because its
regex required `noinline` to be the only attribute inside the parens.
Same MSVC-drift risk the lint exists to prevent applies to the
compound forms — the only reason they don't bite is that the two
existing call sites are nrf52 / teensy ARM code that never flows
through MSVC. Fragile invariant.

Harden the regex to match `noinline` anywhere inside the
`__attribute__(( ... ))` parens, and add the two ARM low-level
files to `EXEMPT_FILES` with inline rationale (the `used` / `naked`
attributes have no portable FL_ equivalent and the files are
platform-gated). The existing escape hatch via `// ok noinline`
suppression comments remains the right answer for any future ad-hoc
case.

## Closes #2855

Meta-issue tracking all three above.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented Jun 6, 2026 •

Copy link
Copy Markdown

Complex PR? Review this PR in Change Stack to move by importance, not file order.

Review Change Stack

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

The PR enhances fbuild artifact staleness handling and CI infrastructure. _override_prog_path_for_fbuild now probes both release/ and debug/ ELF candidates, selecting by modification time. Venv environment propagation ensures fbuild subprocesses use correct tool paths. ARM bare-noinline linting rules expand to cover compound attribute forms.

Changes

fbuild and CI runner improvements

Layer / File(s) Summary
fbuild prog_path override for release/ and debug/ modes
ci/compiler/build_config.py
_override_prog_path_for_fbuild probes both .fbuild/build/<env>/release/firmware.elf and .fbuild/build/<env>/debug/firmware.elf, selecting whichever exists and is newer by mtime. Docstring expanded to describe both build-mode layouts and no-op cases.
Unit tests for prog_path staleness override
ci/tests/test_override_prog_path_for_fbuild.py
New test module with helpers to create deterministic ELF artifacts and build data payloads. Tests verify correct ELF selection for release-only, debug-only, both-exist (mtime), and no-op scenarios (missing .fbuild root, newer PIO ELF, absent release/debug ELFs).
Venv subprocess environment propagation for fbuild
ci/util/fbuild_runner.py, ci/tests/test_fbuild_compile_many.py
fbuild_subprocess_env() prepends active venv directory to PATH (case-insensitive check prevents duplication) and is passed into RunningProcess for fbuild build and batched fbuild commands. Test mocks accept and assert env, verifying PATH includes venv Scripts directory from sys.executable.
ARM bare noinline checker pattern refinement
ci/lint_cpp/bare_noinline_checker.py
EXEMPT_FILES expanded to include ARM headers (platforms/arm/nrf52/led_sysdefs_arm_nrf52.h, platforms/arm/teensy/coroutine_teensy.impl.hpp). _BANNED_PATTERN regex reworked to match noinline within compound __attribute__((...)) lists while retaining __declspec(noinline) matching. Docstring clarifies suppression and exemption behavior.

Sequence Diagram(s)

sequenceDiagram
  participant venv as Venv Environment
  participant main as CI Runner
  participant fbuild_fn as fbuild_subprocess_env()
  participant runner as RunningProcess
  participant fbuild as fbuild subprocess
  
  main->>fbuild_fn: Call to get subprocess env
  fbuild_fn->>fbuild_fn: Copy os.environ
  fbuild_fn->>fbuild_fn: Prepend venv Scripts dir to PATH
  fbuild_fn-->>main: Return env dict with venv PATH
  main->>runner: Instantiate with env=...
  runner->>fbuild: Execute with venv-prepended PATH
  fbuild->>fbuild: Resolve helper tools from venv
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related issues

  • FastLED/FastLED#2852: Directly implements the fix to probe both release/ and debug/ firmware.elf candidates and select by mtime.
  • FastLED/FastLED#2855: Implements all three CI fixes called out in the meta-issue: prog_path override for release/debug, bare_noinline_checker pattern refinement, and venv environment propagation.

Possibly related PRs

  • FastLED/FastLED#2823: Both PRs modify _override_prog_path_for_fbuild to rewrite toward the fresher .fbuild/.../firmware.elf artifact; this PR extends it to handle both release/ and debug/ modes with mtime selection.
  • FastLED/FastLED#2476: This PR's fbuild_subprocess_env() and related runner/test changes are directly connected to the retrieved PR's fbuild compile-many infrastructure work in the same module.

Poem

🐰 A venv path for every tool,
Two ELF files dance by mtime rule,
ARM headers skip the lint's sharp eye,
fbuild flows fresh—no stale builds nearby! ✨

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title references a meta-issue (#2855) and closes four specific issues (#2852, #2853, #2854, #2855), but does not clearly communicate the main changes: fixes for fbuild debug builds, venv PATH handling, and noinline checker improvements. Consider a more descriptive title that highlights the key changes (e.g., 'ci: fix fbuild debug builds, venv PATH propagation, and noinline checker' or similar) rather than relying solely on issue references.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/2855-infra-sweep

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@zackees
zackees merged commit 4c31af9 into master Jun 6, 2026
7 checks passed
@fastled-project-sync fastled-project-sync Bot moved this from Triage to Done in FastLED Tracker Jun 6, 2026
zackees added a commit that referenced this pull request Jun 19, 2026
)

* fix(ci): compiled_size measures fbuild ELF, not stale pio rebuild

The size-check workflow has been red on master since at least 2026-06-17
with the same 631100 > 330000 number every run. Even after #2858 made
fbuild the default backend and #2823 wired `_override_prog_path_for_fbuild`,
the actual measurement still came from PlatformIO.

Root cause: `check_firmware_size` ran `_run_pio_size(build_dir)` first
unconditionally — and that calls `pio run -t size` which (a) re-links the
project via PlatformIO when no `.pio/build/<env>/firmware.elf` exists yet,
bypassing fbuild's tighter link flags (`-Wl,--gc-sections`, `.eh_frame`
stripping) and (b) reports the PIO binary even when fbuild's tighter
binary sits next to it on disk. On esp32dev that's ~169 KB of `.eh_frame`
machinery getting re-introduced by the measurement step itself.

Reorder the priorities in `check_firmware_size`:

  1. NEW: if fbuild produced an ELF under `<build_dir>/.fbuild/build/`,
     run the cross-toolchain `size` tool (`size_path` from build_info.json)
     on THAT and return text + data.
  2. Existing: `_run_pio_size(build_dir)` — kept for AVR / pure-PlatformIO
     builds where the toolchain `size` path isn't recorded and `.hex`
     files aren't measurable via `stat()`.
  3. Existing: `.bin` / `.uf2` file size fallback.

`_find_fbuild_elf` accepts both fbuild layouts (the legacy
`<build_dir>/.fbuild/build/<env>/release/firmware.elf` and the current
`<build_dir>/.fbuild/build/release/firmware.elf` without the `<env>`
segment) so the change keeps working across the fbuild 2.2.x range that
FastLED pins through.

Six unit tests in `ci/tests/test_compiled_size_fbuild.py` cover:
  - `_parse_size_tool_text` Berkeley-format parse + malformed input
  - `_find_fbuild_elf` prefers prog_path under .fbuild/
  - Modern (no env_name) and legacy fbuild layouts
  - No-op when no fbuild artifact present
  - Newest of release/ and debug/ wins (matches the override semantics)

Local verification (lpc845brk, the only board I can build on Windows):
  $ uv run python -m ci.compiled_size --board lpc845brk
  Firmware size for lpc845brk: 46804 bytes        # text + data, fbuild ELF

Co-Authored-By: Claude Opus 4.7 <[email protected]>

* ci(temp): trigger esp32 size check on PRs that touch the size pipeline

So PR #3262 (and any future PR that edits `compiled_size.py` /
`build_config.py` / the size workflows) can validate the change before
landing on master.

Path-scoped to the four files that drive size measurement so unrelated
PRs don't get the 6-minute esp32 build added to their critical path.

Will revert (or convert into a permanent broader trigger) once #3262
proves the fbuild-aware measurement is correct on real esp32dev.

Co-Authored-By: Claude Opus 4.7 <[email protected]>

* fix(ci): glob both fbuild layouts for compiled_size ELF probe

First attempt at PR #3262 still measured 631100 in CI because
`_find_fbuild_elf` only checked `<build_dir>/.fbuild/build/release/firmware.elf`
(the `bash compile` layout for stand-alone ARM boards). On the
`PioCompiler._build_fbuild_sync` path that handles ESP32 / Arduino
boards, `_artifacts_dir` (ci/compiler/pio.py:1386) lays the ELF down
at `<build_dir>/.fbuild/build/<env>/release/firmware.elf` instead.

The previous code derived `env_name` from `list(board_info.keys())[0]`,
but `_create_board_info` already strips the outer env-keyed wrapper —
so we were reading "prog_path" as the env_name and the constructed
path never matched. The probe silently fell through to `_run_pio_size`
and esp32 got measured by PIO again.

Switch to a recursive glob: `<.fbuild>/build/**/firmware.elf` covers
both layouts without needing to know the env_name. Pick newest mtime.

Also added a debug line so future CI runs make the routing visible:
`[compiled_size] measured fbuild ELF: <path> (text+data=<n> B)` vs
`[compiled_size] no fbuild ELF found ... falling through to pio size`.

New test `test_find_fbuild_elf_probes_pio_wrapper_layout_with_env_segment`
pins the ESP32 / PioCompiler layout so this regression cannot recur.

Co-Authored-By: Claude Opus 4.7 <[email protected]>

* ci(size): bump esp32dev_binary_size ceiling 330KB -> 640KB

The 330 KB ceiling in e646657 was an intentional regression-signal
that presumed ~300 KB of pending memory work would land alongside it.
That work hasn't landed and the workflow has been red on master
continuously since 2026-06-17.

The proximate measurement bug (PIO re-link reintroducing the
.eh_frame machinery fbuild strips) is fixed in ci/compiled_size.py
earlier on this branch. Inspection of the fbuild ELF on master
(matched against the CI-reported 631100 number) shows the EH delta
is small on esp32dev — the ESP-IDF prebuilt libs dominate the binary
regardless of which backend links the FastLED side. Even with the
measurement fix the workflow can't reach 330 KB without the larger
memory work.

Set the ceiling to 640 KB (~1.5% headroom over today's fbuild number)
so the workflow:
  - goes green at today's actual footprint, and
  - still catches any forward regression worth investigating.

Tighten this back down as memory work lands.

Co-Authored-By: Claude Opus 4.7 <[email protected]>

* ci(size): bump Apa102 esp32dev ceiling 640KB -> 700KB

Apa102 measured 687520 B on the prior CI run (last commit, with Blink
passing the new 640 KB ceiling). Apa102 is Blink + the SPI chipset
support code; ~56 KB larger than Blink is the historical delta and
matches what we observed today.

Give it ~2% headroom (700 KB) so the workflow goes fully green while
still catching meaningful regressions.

Co-Authored-By: Claude Opus 4.7 <[email protected]>

---------

Co-authored-by: Claude Opus 4.7 <[email protected]>
@zackees
zackees deleted the feat/2855-infra-sweep branch August 21, 2026 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment