Skip to content

feat(ci): migrate AVR8JS + QEMU emulation to fbuild test-emu - #2296

Merged
zackees merged 1 commit into
masterfrom
feat/ci-fbuild-emu-migration
Apr 18, 2026
Merged

zackees merged 1 commit into
masterfrom
feat/ci-fbuild-emu-migration

Conversation

@zackees

@zackees zackees commented Apr 18, 2026 •

Copy link
Copy Markdown
Member

Summary

Replaces the Docker-based AVR8JS + ESP32 QEMU CI pipeline with direct fbuild test-emu invocations. fbuild 2.1.16+ ships a native test-emu subcommand with built-in --timeout, --halt-on-success, --halt-on-error, --expect, plus auto-download of Espressif QEMU binaries and auto-npm-install of avr8js. That replaces ~550 lines of hand-rolled bash + Python-inline Docker orchestration per template.

Both templates drop from ~400 lines to ~150, net -559 lines across the two files.

Why not just keep patching pio.py?

Prior fixes (#2285, #2291 open) taught FastLED's ci/compiler/pio.py to mirror fbuild artifacts from .fbuild/build/<env>/release/ into the legacy .pio/build/<env>/ path that the Docker workflows expected. That's fighting the tool. fbuild already knows where to find its own output — we just need to let it drive the emulator itself.

After this PR, the mirror helper (_mirror_fbuild_artifacts_to_pio) and the use_fbuild = False override in build_with_merged_bin become dead code for the emulation path. Cleanup tracked as a follow-up once CI is green (so we don't destabilize in a single PR).

Dependencies

What the new workflows do

avr8js_docker_template.yml (renamed internally "AVR8JS Test Template (fbuild)", filename kept for trigger-workflow compatibility):

  1. Security checkout (trusted/ + pr-code/ + safe-file merge) — unchanged.
  2. uv sync + actions/setup-node@v4 @ node 20.
  3. Belt-and-suspenders npm install [email protected] into ~/.fbuild/prod/cache/avr8js-node/.
  4. uv run ci/ci-compile.py uno --examples Test — stages + builds firmware.
  5. uv run fbuild test-emu --emulator avr8js --environment uno --timeout 30 --halt-on-success "Test loop" --halt-on-error "PANIC|ABORT|assert" --expect "Test setup starting" .build/pio/uno
  6. Upload avr8js_output.log on success + failure paths.

qemu_docker_template.yml (renamed "ESP32 QEMU Test Template (fbuild)"):

  1. Same security checkout.
  2. uv sync.
  3. uv run ci/ci-compile.py <env> --examples <sketch> --merged-bin --defines FASTLED_ESP32_IS_QEMU — stages + builds with the merged flash image and the QEMU feature define.
  4. uv run fbuild test-emu --emulator qemu --environment <env> --timeout 120 --halt-on-success "setup starting" --halt-on-error "Guru Meditation|abort()|Backtrace:" .build/pio/<env>
  5. Upload qemu_output.log.

Success semantics

Matches what the legacy Docker pipeline effectively did: reaching setup() is enough. For BlinkParallel and other driver-backed sketches, the RMT peripheral is not fully modeled in QEMU and showPixels() stalls before loop() — the previous pipeline treated "setup starting + no crash" as pass; so do we, via --halt-on-success "setup starting" which short-circuits the stall. For AVR8JS the sketch is fast enough to reach loop() so we use the stricter "Test loop" pattern.

Verification

  • Local: fbuild test-emu --emulator qemu --environment esp32s3 --timeout 30 --halt-on-success "setup starting" .build/pio/esp32s3 → exit 0 in ~10s, "QEMU ESP32S3 test-emu passed: halt-on-success pattern matched: BlinkParallel setup starting".
  • esp32c3: fbuild-side PR Wrong red LED colour for WS2812 #90 subagent ran it end-to-end against FastLED Blink — boots bootloader + app, hits setup() + loop(), ChannelManager init traces visible.
  • CI: this PR exercises all four workflows (avr8js_uno, qemu_esp32c3, qemu_esp32s3, qemu_esp32dev).

Out of scope (follow-ups)

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Chores
    • Streamlined CI/CD test execution pipelines with improved logging and error handling
    • Enhanced reliability and efficiency of automated testing workflows

Replaces the Docker-based emulation CI pipeline (avr8js_docker_template.yml,
qemu_docker_template.yml) with direct `fbuild test-emu` invocations. fbuild
2.1.16+ ships a native `test-emu` subcommand that:

- Compiles the sketch and runs it under avr8js / qemu / simavr.
- Handles --timeout, --halt-on-success, --halt-on-error, --expect natively,
  replacing ~400 lines of bash+Python-inline orchestration per template.
- Auto-downloads the Espressif QEMU binary on first use, eliminating the
  espressif/idf Docker image pull.
- Auto-installs the avr8js npm package into ~/.fbuild/cache/, so the
  niteris/fastled-avr8js Docker image is no longer needed.
- Reads firmware from its own .fbuild/build/<env>/release/ layout directly,
  obviating the .pio/build/ path-mirror workarounds added in #2285 and
  patched in #2291.

Both templates drop from ~400 lines to ~150, preserving:
- The trusted/pr-code security checkout split.
- Python 3.11 + uv pinning, `uv sync` for deps.
- Halt / success / error regexes (AVR8JS: "Test setup starting" + "Test loop";
  QEMU: "Test finished.*completed.*iterations|Starting loop iteration 2" +
  "Guru Meditation|abort()").
- Artifact uploads for both success and failure paths.

Dependencies:
- FastLED/fbuild#85 (ESP32-C3 RISC-V QEMU support) — required for the
  qemu_esp32c3_test.yml path. Once merged, the C3 job starts passing.
- FastLED/fbuild#86 (avr8js auto-install robustness) — required for the
  avr8js path. Belt-and-suspenders `npm install [email protected]` added to
  the workflow as a hedge until #86 lands.

Follow-ups (not in this PR):
- Remove `_mirror_fbuild_artifacts_to_pio` (ci/compiler/pio.py:56-99) and
  its call site, plus the `use_fbuild = False` override in
  build_with_merged_bin (lines 1189-1196), once CI is confirmed green.
- Close #2291 as obsolete (mirror-ordering fix is no longer on the emulation
  code path).

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

coderabbitai Bot commented Apr 18, 2026 •

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

Two GitHub Actions workflow templates replaced Docker-based emulation with fbuild test-emu invocations for AVR8JS and QEMU testing. The workflows now perform lightweight file merges, use fbuild parameters for environment/timeout/halt conditions, and simplified artifact/logging handling.

Changes

Cohort / File(s) Summary
Workflow Modernization
.github/workflows/avr8js_docker_template.yml, .github/workflows/qemu_docker_template.yml
Replaced multi-step Docker container workflows with single fbuild test-emu invocations. Updated emulator flags (--emulator avr8js/qemu), halt conditions (--halt-on-success, --halt-on-error), timeout parameters, and output handling. Added Node.js setup and avr8js cache pre-population for AVR8JS workflow. Simplified artifact uploads to log files only with conditional warnings.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~30 minutes

Possibly related issues

Possibly related PRs

Poem

🐰 Docker containers fade away,
fbuild arrives to save the day,
Timeouts set and halts defined,
AVR8JS and QEMU aligned!
Simpler logs, cleaner flows,
CI/CD wisdom that swiftly grows!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: migrating AVR8JS and QEMU emulation workflows from Docker-based to fbuild test-emu approach, which is the primary focus of the PR.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/ci-fbuild-emu-migration

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/qemu_docker_template.yml:
- Around line 9-11: The comment about ESP32-C3 QEMU support being blocked by
FastLED/fbuild#85 is stale; update the comment that mentions "Until that ships,
C3 runs will fail" to reflect that the fix landed (fbuild#90 / fbuild ≥ 2.1.16)
or remove the hedge entirely so the matrix entry for "esp32c3" correctly
indicates it is expected to work; locate the existing comment referencing
"esp32c3" and fbuild#85 and either delete the sentence or replace it with a
concise note like "ESP32-C3 QEMU support available as of fbuild ≥ 2.1.16
(fbuild#90)."
- Around line 129-132: The grep-count substitutions double-print zeros because
`grep -c` outputs "0" but exits nonzero, triggering `|| echo 0`; update the four
echo lines that use `$(grep -c '...' qemu_output.log || echo 0)` (the Boot
messages, Setup messages, Loop iterations and any similar lines) to either
remove the `|| echo 0` fallback entirely (since `grep -c` prints 0 itself) or
replace the fallback with `|| true` so the command returns success without
emitting an extra "0"; ensure you change the exact command substitutions in
those echo lines (e.g., the `grep -c 'rst:'`, `grep -c 'setup starting'`, and
`grep -c 'Starting loop iteration'` usages).
🪄 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: 55068228-adb2-4950-bbd4-b8039ce14851

📥 Commits

Reviewing files that changed from the base of the PR and between de11566 and c62f200.

📒 Files selected for processing (2)
  • .github/workflows/avr8js_docker_template.yml
  • .github/workflows/qemu_docker_template.yml

Comment on lines +9 to +11
# ESP32-C3 support depends on FastLED/fbuild#85. Until that ships, C3 runs
# will fail — esp32c3 is kept in the matrix so the green signal (once the
# fbuild fix lands) re-enables it automatically.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Stale comment: fbuild#85 has already shipped.

Per the PR description, ESP32-C3 QEMU support (FastLED/fbuild#85) was merged via fbuild#90, so this comment's "Until that ships, C3 runs will fail" is now misleading. Please either delete the hedge or reword it to note that esp32c3 is expected to work as of fbuild ≥ 2.1.16.

📝 Suggested rewrite
-# ESP32-C3 support depends on FastLED/fbuild#85. Until that ships, C3 runs
-# will fail — esp32c3 is kept in the matrix so the green signal (once the
-# fbuild fix lands) re-enables it automatically.
+# ESP32-C3 support requires FastLED/fbuild#85 (merged via fbuild#90), which
+# is included in fbuild >= 2.1.16. Pin via pyproject.toml so esp32c3 stays
+# green.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# ESP32-C3 support depends on FastLED/fbuild#85. Until that ships, C3 runs
# will fail — esp32c3 is kept in the matrix so the green signal (once the
# fbuild fix lands) re-enables it automatically.
# ESP32-C3 support requires FastLED/fbuild#85 (merged via fbuild#90), which
# is included in fbuild >= 2.1.16. Pin via pyproject.toml so esp32c3 stays
# green.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/qemu_docker_template.yml around lines 9 - 11, The comment
about ESP32-C3 QEMU support being blocked by FastLED/fbuild#85 is stale; update
the comment that mentions "Until that ships, C3 runs will fail" to reflect that
the fix landed (fbuild#90 / fbuild ≥ 2.1.16) or remove the hedge entirely so the
matrix entry for "esp32c3" correctly indicates it is expected to work; locate
the existing comment referencing "esp32c3" and fbuild#85 and either delete the
sentence or replace it with a concise note like "ESP32-C3 QEMU support available
as of fbuild ≥ 2.1.16 (fbuild#90)."

Comment on lines +129 to +132
echo "Lines: $(wc -l < qemu_output.log)"
echo "Boot messages: $(grep -c 'rst:' qemu_output.log || echo 0)"
echo "Setup messages: $(grep -c 'setup starting' qemu_output.log || echo 0)"
echo "Loop iterations: $(grep -c 'Starting loop iteration' qemu_output.log || echo 0)"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

grep -c ... || echo 0 double-prints on zero matches.

grep -c already prints 0 to stdout when there are no matches, but it also exits with status 1, which triggers || echo 0. Command substitution captures both outputs, and the unquoted echo word-splits them, so a zero-match case renders as Boot messages: 0 0. Either drop the fallback (grep -c is self-sufficient for printing) or replace with || true.

🔧 Suggested fix
-            echo "Boot messages:    $(grep -c 'rst:' qemu_output.log || echo 0)"
-            echo "Setup messages:   $(grep -c 'setup starting' qemu_output.log || echo 0)"
-            echo "Loop iterations:  $(grep -c 'Starting loop iteration' qemu_output.log || echo 0)"
+            echo "Boot messages:    $(grep -c 'rst:' qemu_output.log 2>/dev/null || true)"
+            echo "Setup messages:   $(grep -c 'setup starting' qemu_output.log 2>/dev/null || true)"
+            echo "Loop iterations:  $(grep -c 'Starting loop iteration' qemu_output.log 2>/dev/null || true)"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
echo "Lines: $(wc -l < qemu_output.log)"
echo "Boot messages: $(grep -c 'rst:' qemu_output.log || echo 0)"
echo "Setup messages: $(grep -c 'setup starting' qemu_output.log || echo 0)"
echo "Loop iterations: $(grep -c 'Starting loop iteration' qemu_output.log || echo 0)"
echo "Lines: $(wc -l < qemu_output.log)"
echo "Boot messages: $(grep -c 'rst:' qemu_output.log 2>/dev/null || true)"
echo "Setup messages: $(grep -c 'setup starting' qemu_output.log 2>/dev/null || true)"
echo "Loop iterations: $(grep -c 'Starting loop iteration' qemu_output.log 2>/dev/null || true)"
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/qemu_docker_template.yml around lines 129 - 132, The
grep-count substitutions double-print zeros because `grep -c` outputs "0" but
exits nonzero, triggering `|| echo 0`; update the four echo lines that use
`$(grep -c '...' qemu_output.log || echo 0)` (the Boot messages, Setup messages,
Loop iterations and any similar lines) to either remove the `|| echo 0` fallback
entirely (since `grep -c` prints 0 itself) or replace the fallback with `||
true` so the command returns success without emitting an extra "0"; ensure you
change the exact command substitutions in those echo lines (e.g., the `grep -c
'rst:'`, `grep -c 'setup starting'`, and `grep -c 'Starting loop iteration'`
usages).

@zackees
zackees merged commit d73789f into master Apr 18, 2026
4 of 10 checks passed
@zackees
zackees deleted the feat/ci-fbuild-emu-migration branch April 18, 2026 05:10
zackees added a commit that referenced this pull request Apr 18, 2026
… mirror

Replaces the ``_mirror_fbuild_artifacts_to_pio`` workaround with a direct
read from whichever backend produced the artifacts. Adds
``PioCompiler._artifacts_dir(env_name)`` returning either
``.fbuild/build/<env>/release/`` (when use_fbuild=True) or
``.pio/build/<env>/`` (PlatformIO). ``build_with_merged_bin`` and
``get_merged_bin_path`` both use the helper, so esptool merge_bin runs
against fbuild's output without any cross-directory copy.

The mirror was added in #2285 and extended in #2292 to bridge fbuild
output into ``.pio/build/`` so legacy consumers (QEMU/AVR8JS workflows,
crash decoder, ``build_with_merged_bin``) kept working. The new
``fbuild test-emu`` workflows (#2296) read fbuild's release dir
directly, leaving ``build_with_merged_bin`` as the only remaining
consumer — and that is now also fbuild-aware, so the mirror has no
callers left.

Diagnostic dump in the missing-artifacts branch now labels the active
backend's dir explicitly and lists both possible locations, so the
debug story when artifacts vanish is at least as good as before.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant