Repository navigation
feat(ci): fbuild native-QEMU smoke test - #2346
Conversation
📝 WalkthroughWalkthroughThis PR adds CI test infrastructure to validate fbuild's native QEMU emulation path on ESP32, including a pytest test module that invokes fbuild, a minimal PlatformIO smoke project with an Arduino sketch, and supporting documentation. Changes
Sequence DiagramsequenceDiagram
participant Pytest as Pytest Runner
participant Subprocess as subprocess.run()
participant fbuild as fbuild Executable
participant QEMU as QEMU Emulator
participant Output as Serial Output
Pytest->>Pytest: Check skip conditions<br/>(PATH, env vars, project exists)
Pytest->>Subprocess: Execute fbuild test-emu<br/>esp32dev --emulator qemu
Subprocess->>fbuild: Invoke with timeout (10 min)
fbuild->>QEMU: Build & start emulation
QEMU->>Output: Boot Arduino sketch
Output->>Output: Print FBUILD-QEMU-TEST-BOOT
Output->>Output: Initialize FastLED, set LED
Output->>Output: Print FBUILD-QEMU-TEST-OK
QEMU-->>fbuild: Complete
fbuild-->>Subprocess: Exit code 0
Subprocess-->>Pytest: Return with stdout/stderr
Pytest->>Pytest: Assert return code == 0
Pytest->>Pytest: Assert success marker in output
Pytest->>Pytest: Pass/Fail with diagnostics
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related issues
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 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: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
pyproject.toml (1)
44-50:⚠️ Potential issue | 🟡 MinorDuplicate
running-processdependency still present.Line 44 pins
running-process>=3.0.9while line 50 re-listsrunning-process>=3.0.7. The PR description mentions removing a duplicatefbuildline, but this second duplicate was missed. Pip/uv will accept it, but it's confusing and the weaker>=3.0.7is dead. Suggest removing line 50.Proposed fix
"bleak>=0.22.3", - "running-process>=3.0.7", ]🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@pyproject.toml` around lines 44 - 50, The pyproject.toml contains a duplicate dependency "running-process" with two versions (>=3.0.9 and >=3.0.7); remove the weaker duplicate entry ("running-process>=3.0.7") so only "running-process>=3.0.9" remains, keeping the dependency list clean and unambiguous; update any surrounding commas or trailing punctuation if needed to keep the TOML array syntax valid.
🧹 Nitpick comments (3)
ci/tests/test_fbuild_qemu.py (1)
63-68:subprocess.runtimeout will raiseTimeoutExpired, not xfail cleanly.With
timeout=600and notry/except, a hungfbuild(plausible given the upstream daemon bug tracked in#130) raisessubprocess.TimeoutExpired. Underxfail(strict=False)that still counts as xfail, so this is benign today — but once the xfail is removed (per the PR plan) an upstream hang would turn into a hard CI error instead of a clean failure with diagnostics. Consider catchingTimeoutExpiredand converting it to apytest.failwith captured partial output, alongsideKeyboardInterrupthandled first per the repo's Python standards.Sketch
- proc = subprocess.run( - cmd, - capture_output=True, - text=True, - timeout=600, - ) + try: + proc = subprocess.run( + cmd, + capture_output=True, + text=True, + timeout=600, + ) + except KeyboardInterrupt: + raise + except subprocess.TimeoutExpired as e: + pytest.fail( + f"fbuild test-emu timed out after {e.timeout}s.\n" + f"CMD: {subprocess.list2cmdline(cmd)}\n" + f"--- STDOUT ---\n{(e.stdout or b'').decode(errors='replace') if isinstance(e.stdout, bytes) else (e.stdout or '')}\n" + f"--- STDERR ---\n{(e.stderr or b'').decode(errors='replace') if isinstance(e.stderr, bytes) else (e.stderr or '')}" + )As per coding guidelines: "All Python try-catch blocks must handle KeyboardInterrupt before other exceptions".
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@ci/tests/test_fbuild_qemu.py` around lines 63 - 68, Wrap the subprocess.run call that invokes cmd (the block using capture_output=True, text=True, timeout=600) in a try/except that first handles KeyboardInterrupt (re-raise) and then catches subprocess.TimeoutExpired; on TimeoutExpired call pytest.fail with a message including the partial output (use the exception's stdout/stderr attributes or captured output) so CI reports a clean failure with diagnostics instead of crashing. Ensure you reference the subprocess.run invocation when adding the try/except and import pytest if not already present.tests/fbuild_qemu_smoke/README.md (1)
12-14: Nit: specify a language on the fenced code block.markdownlint flags MD040. Use
```bash(ortext) so the block renders with correct highlighting.Proposed fix
-``` +```bash fbuild test-emu tests/fbuild_qemu_smoke -e esp32dev --emulator qemu --timeout 10</details> <details> <summary>🤖 Prompt for AI Agents</summary>Verify each finding against the current code and only fix it if needed.
In
@tests/fbuild_qemu_smoke/README.mdaround lines 12 - 14, Update the fenced
code block in tests/fbuild_qemu_smoke/README.md to specify a language for syntax
highlighting (e.g., change the opening fence fromtobash) so the example
commandfbuild test-emu tests/fbuild_qemu_smoke -e esp32dev --emulator qemu --timeout 10is rendered correctly and satisfies markdownlint MD040.</details> </blockquote></details> <details> <summary>tests/fbuild_qemu_smoke/platformio.ini (1)</summary><blockquote> `10-10`: **Pin the `espressif32` platform to a specific version for CI stability.** `platform = platformio/espressif32` floats to the latest registry version, which can cause this smoke test to break unexpectedly when unrelated platform updates occur. Most of the codebase pins to specific versions (e.g., `51.03.04` in `ci/adafruit_bridge` and `ci/kitchensink`, or `55.03.35` in the root `platformio.ini`). For consistency and stability, match the version used in the primary project configuration. <details> <summary>🤖 Prompt for AI Agents</summary> ``` Verify each finding against the current code and only fix it if needed. In `@tests/fbuild_qemu_smoke/platformio.ini` at line 10, The platform declaration "platform = platformio/espressif32" should be pinned to a specific version for CI stability; update that setting to use the same fixed espressif32 version used in the main project (replace the floating platform value with the pinned version used in root platformio.ini, e.g., 55.03.35) so tests stop floating to the latest registry releases. ``` </details> </blockquote></details> </blockquote></details> <details> <summary>🤖 Prompt for all review comments with AI agents</summary>Verify each finding against the current code and only fix it if needed.
Inline comments:
In@ci/tests/test_fbuild_qemu.py:
- Around line 70-75: The assertion builds a human-readable command string using
' '.join(cmd) which misrepresents arguments with spaces; replace that with
subprocess.list2cmdline(cmd) in the assertion message (the one referencing
proc.returncode, cmd, proc.stdout, proc.stderr) and ensure the module imports
subprocess at the top of ci/tests/test_fbuild_qemu.py if it's not already
imported.
Outside diff comments:
In@pyproject.toml:
- Around line 44-50: The pyproject.toml contains a duplicate dependency
"running-process" with two versions (>=3.0.9 and >=3.0.7); remove the weaker
duplicate entry ("running-process>=3.0.7") so only "running-process>=3.0.9"
remains, keeping the dependency list clean and unambiguous; update any
surrounding commas or trailing punctuation if needed to keep the TOML array
syntax valid.
Nitpick comments:
In@ci/tests/test_fbuild_qemu.py:
- Around line 63-68: Wrap the subprocess.run call that invokes cmd (the block
using capture_output=True, text=True, timeout=600) in a try/except that first
handles KeyboardInterrupt (re-raise) and then catches subprocess.TimeoutExpired;
on TimeoutExpired call pytest.fail with a message including the partial output
(use the exception's stdout/stderr attributes or captured output) so CI reports
a clean failure with diagnostics instead of crashing. Ensure you reference the
subprocess.run invocation when adding the try/except and import pytest if not
already present.In
@tests/fbuild_qemu_smoke/platformio.ini:
- Line 10: The platform declaration "platform = platformio/espressif32" should
be pinned to a specific version for CI stability; update that setting to use the
same fixed espressif32 version used in the main project (replace the floating
platform value with the pinned version used in root platformio.ini, e.g.,
55.03.35) so tests stop floating to the latest registry releases.In
@tests/fbuild_qemu_smoke/README.md:
- Around line 12-14: Update the fenced code block in
tests/fbuild_qemu_smoke/README.md to specify a language for syntax highlighting
(e.g., change the opening fence fromtobash) so the example command
fbuild test-emu tests/fbuild_qemu_smoke -e esp32dev --emulator qemu --timeout 10is rendered correctly and satisfies markdownlint MD040.</details> <details> <summary>🪄 Autofix (Beta)</summary> Fix all unresolved CodeRabbit comments on this PR: - [ ] <!-- {"checkboxId": "4b0d0e0a-96d7-4f10-b296-3a18ea78f0b9"} --> Push a commit to this branch (recommended) - [ ] <!-- {"checkboxId": "ff5b1114-7d8c-49e6-8ac1-43f82af23a33"} --> Create a new PR with the fixes </details> --- <details> <summary>ℹ️ Review info</summary> <details> <summary>⚙️ Run configuration</summary> **Configuration used**: Path: .coderabbit.yaml **Review profile**: CHILL **Plan**: Pro **Run ID**: `5fff1b9c-d9fb-4a3c-b4d0-b3e57731d281` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between 06c4019f2a6e3a86bbf7f69a0e1fa5e0715797e3 and 44499586ef0449c61ebf2dbc24bda714dc97bee8. </details> <details> <summary>📒 Files selected for processing (7)</summary> * `ci/tests/README.md` * `ci/tests/test_fbuild_qemu.py` * `pyproject.toml` * `tests/fbuild_qemu_smoke/README.md` * `tests/fbuild_qemu_smoke/platformio.ini` * `tests/fbuild_qemu_smoke/src/README.md` * `tests/fbuild_qemu_smoke/src/main.ino` </details> </details> <!-- This is an auto-generated comment by CodeRabbit for review status -->
Adds a minimal standalone PlatformIO project under `tests/fbuild_qemu_smoke/` with a tiny FastLED sketch that prints `FBUILD-QEMU-TEST-OK` on boot, plus `ci/tests/test_fbuild_qemu.py` which invokes `fbuild test-emu` against it and asserts the marker. ## Why a dedicated project FastLED's root `platformio.ini` uses `src_dir = ./src` (the library itself, no `setup()`/`loop()`). `fbuild test-emu` needs an actual sketch. Keeping the smoke project small and standalone (single-env `esp32dev`, DIO flash mode for QEMU compat, FastLED via `lib_deps = symlink://../..`) avoids tangling with the Docker-based QEMU runner in `ci/runners/qemu_runner.py`. ## Status fbuild 2.1.20 resolves FastLED/fbuild#130 (`daemon error: request failed` on Windows despite healthy daemon) — the previous `xfail` marker is removed and this is now a passing smoke test as of the fbuild pin bump in #2353. The pytest `skipif` falls back to "fbuild not on PATH" if fbuild isn't installed. ## Review fixes - `CMD: {subprocess.list2cmdline(cmd)}` in the failure message per the repo guideline (CodeRabbit feedback on the previous revision). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
4449958 to
ecd876d
Compare
…flict markers Adds a `grep -q '^<<<<<<< ' pyproject.toml` pre-check in every `.claude` hook command. If unresolved merge conflict markers are present, the hook short-circuits through the existing `||` fallback and exits 0 with a descriptive warning instead of letting `uv run` crash with a TOML parse error (which propagates as hook failure and blocks every subsequent tool call). Without this guard, a mid-rebase state where git leaves conflict markers in `pyproject.toml` creates a catch-22: every Claude tool invocation triggers a PreToolUse hook → uv can't parse pyproject.toml → hook exits non-zero → tool is blocked → the agent literally cannot fix the file because every tool (Read, Write, Edit, Bash, Skill, ToolSearch) is locked out. We hit this today during the PR #2346 rebase — user had to fix pyproject.toml manually in a terminal to unblock the agent. Implementation: single `grep` call (~1ms) in each hook's shell command; the `||` fallback clause now covers both failure modes (no pyproject.toml found AND conflict markers present) with an updated error message. Also adds a `_conflict_marker_guard` key in settings.json documenting the rationale so future readers know why the grep is there. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@ci/tests/test_fbuild_qemu.py`:
- Around line 16-19: Mark the smoke test(s) in this module xfail on Windows when
the external `fbuild` tool is present: import pytest and sys (since only os,
shutil, subprocess, Path are currently imported) and add
pytest.mark.xfail(condition=sys.platform.startswith("win") and
shutil.which("fbuild") is not None, reason="xfail on Windows while
FastLED/fbuild#130 is open") to the relevant test function(s) in this file (the
test(s) around lines 35-43 that exercise QEMU/fbuild). Ensure the marker uses
the condition so non-Windows runs still behave normally.
🪄 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: 5db73d00-d461-4db2-8c63-236b78b04ad4
📒 Files selected for processing (6)
ci/tests/README.mdci/tests/test_fbuild_qemu.pytests/fbuild_qemu_smoke/README.mdtests/fbuild_qemu_smoke/platformio.initests/fbuild_qemu_smoke/src/README.mdtests/fbuild_qemu_smoke/src/main.ino
✅ Files skipped from review due to trivial changes (5)
- tests/fbuild_qemu_smoke/src/README.md
- ci/tests/README.md
- tests/fbuild_qemu_smoke/README.md
- tests/fbuild_qemu_smoke/platformio.ini
- tests/fbuild_qemu_smoke/src/main.ino
| import os | ||
| import shutil | ||
| import subprocess | ||
| from pathlib import Path |
There was a problem hiding this comment.
Add the intended Windows xfail marker.
The PR objective says this smoke test is expected to xfail for FastLED/fbuild#130. As written, Windows CI will hard-fail when fbuild is present.
Proposed fix
import os
import shutil
import subprocess
+import sys
from pathlib import Path
@@
`@pytest.mark.skipif`(
os.environ.get("FASTLED_SKIP_FBUILD_QEMU") == "1",
reason="FASTLED_SKIP_FBUILD_QEMU=1",
)
+@pytest.mark.xfail(
+ sys.platform == "win32",
+ reason="FastLED/fbuild#130: fbuild daemon API fails during test-emu on Windows",
+ strict=False,
+)
def test_fbuild_test_emu_esp32dev() -> None:Also applies to: 35-43
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@ci/tests/test_fbuild_qemu.py` around lines 16 - 19, Mark the smoke test(s) in
this module xfail on Windows when the external `fbuild` tool is present: import
pytest and sys (since only os, shutil, subprocess, Path are currently imported)
and add pytest.mark.xfail(condition=sys.platform.startswith("win") and
shutil.which("fbuild") is not None, reason="xfail on Windows while
FastLED/fbuild#130 is open") to the relevant test function(s) in this file (the
test(s) around lines 35-43 that exercise QEMU/fbuild). Ensure the marker uses
the condition so non-Windows runs still behave normally.
Summary
tests/fbuild_qemu_smoke/— a minimal standalone PlatformIO project with a tiny FastLED sketch that printsFBUILD-QEMU-TEST-OKon boot.ci/tests/test_fbuild_qemu.py— invokesfbuild test-emuon the smoke project and asserts the boot marker.Status: no longer xfail
The previous revision carried
xfail(strict=False)tracking FastLED/fbuild#130 (daemon error: request failedon Windows despite a healthy daemon). That upstream bug was fixed in fbuild 2.1.20 (closed 2026-04-19). Since master now pinsfbuild>=2.1.20via #2353, this smoke test should pass on all platforms — thexfailmarker is removed andsubprocess.list2cmdline()is used in the error diagnostic per CodeRabbit's guideline feedback.Why a dedicated project under
tests/fbuild_qemu_smoke/FastLED's root
platformio.iniusessrc_dir = ./src(the library itself, nosetup()/loop()).fbuild test-emuneeds an actual sketch. Keeping the smoke project small and standalone (single-envesp32dev, DIO flash mode for QEMU compat, FastLED vialib_deps = symlink://../..) avoids tangling with the Docker-based QEMU runner inci/runners/qemu_runner.py.Test plan
uv sync(resolvesfbuild==2.1.20)uv run pytest ci/tests/test_fbuild_qemu.py -v— now passes (xfail removed)uv run fbuild test-emu tests/fbuild_qemu_smoke -e esp32dev --emulator qemu --timeout 10🤖 Generated with Claude Code
Summary by CodeRabbit
Documentation
Tests