Repository navigation
fix(ci): mirror fbuild artifacts AFTER pio metadata gen (AVR8JS+QEMU still red) - #2291
Conversation
PR #2285 introduced `_mirror_fbuild_artifacts_to_pio` to copy firmware artifacts from `.fbuild/build/<env>/release/` into `.pio/build/<env>/` so QEMU and AVR8JS workflow scripts can keep finding them at the legacy path. The mirror was called immediately after a successful fbuild compile and BEFORE `generate_build_info_json_from_existing_build`. Problem: on a fresh build (CI is always fresh), the `.pio/build/<env>/` directory does not exist yet. `generate_build_info_json_from_existing_build` invokes `pio project metadata --json-output`, which prepares that directory by wiping and re-creating it — clobbering the firmware.elf / firmware.hex we just copied in. After the compile returns, only `idedata.json` remains; the workflow then fails with "firmware.elf not found in .pio/build/<env>". Reproduced locally on a freshly-deleted `.pio/` dir — mirror prints success but files are gone immediately after. Fix: swap the order. Generate build metadata first (which wipes the dir), then mirror firmware artifacts so nothing else touches them. Verified locally: after `bash compile uno --examples Blink` on a fresh `.pio/`, the mirrored dir now contains firmware.elf, firmware.hex, and idedata.json as expected. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
📝 WalkthroughWalkthroughThe Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes Possibly related issues
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 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.
🧹 Nitpick comments (1)
ci/compiler/pio.py (1)
670-686: LGTM — ordering fix is correct; minor observation on ignored return.Running
generate_build_info_json_from_existing_buildfirst is the right fix:pio project metadata --json-outputrecreates.pio/build/<env>/and would otherwise wipe the mirroredfirmware.elf/firmware.hex. The inline comment clearly documents the invariant.One small note (non-blocking, pre-existing pattern): the bool return of
generate_build_info_json_from_existing_buildis still ignored. If metadata generation fails here,_mirror_fbuild_artifacts_to_piowill still create.pio/build/<env>/and copy firmware artifacts, butidedata.json/build_info.jsonwon't be present — downstream tools (crash decoder,build_with_merged_bindiagnostics) that rely onbuild_info.jsonwill then silently operate on a partial artifact set. Consider at least logging a warning when it returnsFalseso CI failures are easier to diagnose.Optional refactor
- generate_build_info_json_from_existing_build( - self.build_dir, self.board, example - ) + if not generate_build_info_json_from_existing_build( + self.build_dir, self.board, example + ): + print( + f"Warning: build_info.json generation failed for {example} " + f"on {environment}; downstream tooling may be degraded." + )🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@ci/compiler/pio.py` around lines 670 - 686, The call to generate_build_info_json_from_existing_build currently ignores its boolean return value; detect when it returns False and emit a warning (using the existing logging/print approach) before proceeding to _mirror_fbuild_artifacts_to_pio so failures to produce idedata.json/build_info.json are visible in CI logs; ensure the warning message includes context (environment, example/board) so downstream tooling issues can be diagnosed.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@ci/compiler/pio.py`:
- Around line 670-686: The call to generate_build_info_json_from_existing_build
currently ignores its boolean return value; detect when it returns False and
emit a warning (using the existing logging/print approach) before proceeding to
_mirror_fbuild_artifacts_to_pio so failures to produce
idedata.json/build_info.json are visible in CI logs; ensure the warning message
includes context (environment, example/board) so downstream tooling issues can
be diagnosed.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 1f7bf293-901e-4c39-8204-ecebbe872a9b
📒 Files selected for processing (1)
ci/compiler/pio.py
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]>
Summary
PR #2285 added
_mirror_fbuild_artifacts_to_pioto copy firmware artifacts from fbuild's.fbuild/build/<env>/release/path into the legacy.pio/build/<env>/path. This was supposed to unblock AVR8JS + QEMU workflows that look forfirmware.{elf,hex}at the PlatformIO location.It didn't fully work. AVR8JS + QEMU still appear broken. Reproduced locally and found the bug.
Root cause
_mirror_fbuild_artifacts_to_piowas called beforegenerate_build_info_json_from_existing_build. On a fresh build (CI is always fresh), the mirror target directory does not exist yet.generate_build_info_json_from_existing_buildcallspio project metadata --json-output, which PREPARES that directory by wiping and re-creating it — clobbering the firmware files we just mirrored. Onlyidedata.jsonremains.Reproduction (local)
With pre-fix code, on a freshly-cleared
.pio/subdirectory:bash compile uno --examples BlinkprintsMirrored fbuild artifacts to ... firmware.elf, firmware.hex, thenGenerating build metadata, thenGenerated build_info_Blink.json..build/pio/uno/.pio/build/uno/contains onlyidedata.json. The mirroredfirmware.elfandfirmware.hexare gone.With the fix applied, same starting state:
bash compile uno --examples BlinkprintsGenerating build metadata, thenGenerated build_info_Blink.json, thenMirrored fbuild artifacts to ... firmware.elf, firmware.hex..build/pio/uno/.pio/build/uno/containsfirmware.elf,firmware.hex, andidedata.json.Fix
Swap the order inside
_build_with_fbuild:generate_build_info_json_from_existing_buildfirst (this is what wipes the directory)_mirror_fbuild_artifacts_to_piosecond (nothing else touches the directory after this)+9 / -6 in
ci/compiler/pio.py. No API changes.Test plan
Note: GitHub Actions runners have been sitting on 46+ min queues for these specific workflows since #2285 merged, so CI hasn't surfaced that the previous fix was incomplete. This PR should make those runs green once they dequeue.
🤖 Generated with Claude Code
Summary by CodeRabbit
Release Notes