Skip to content

fix(ci): skip pio check on fbuild-compiled boards to unblock esp32c2 CI - #2305

Merged
zackees merged 1 commit into
masterfrom
fix-ci-esp32c2-cppcheck-skip-on-fbuild
Apr 18, 2026
Merged

zackees merged 1 commit into
masterfrom
fix-ci-esp32c2-cppcheck-skip-on-fbuild

Conversation

@zackees

@zackees zackees commented Apr 18, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Master's esp32c2 workflow has been red on every commit since perf(ci): use fbuild for ESP32 QEMU merged-bin builds #2292 (2026-04-18). The CPP Check step fails because pio check can't resolve huge_app.csv in the PIO project tree — fbuild compiles without populating that file.
  • This PR is the short-term unblock: ci/ci-cppcheck.py now detects when fbuild was the active backend (by probing .build/.fbuild/build/<env>/release/) and skips pio check with a visible SKIP: notice, returning 0.
  • No change for PIO-compiled boards — only fbuild-compiled boards take the skip branch.

Why this is safe as a short-term measure

Issues

Test plan

🤖 Generated with Claude Code

Summary by CodeRabbit

Release Notes

  • Chores
    • Enhanced the continuous integration pipeline with automatic detection of fbuild-compiled boards. When a board is identified as fbuild-compiled, the C++ static analysis checks are now skipped, streamlining the CI workflow and reducing overall pipeline execution time. This optimization maintains code quality verification for other build methods.

`ci/ci-cppcheck.py` shells out to `pio check`, which requires a fully
populated PlatformIO project tree. Boards now compiled by fbuild don't
get their partition CSVs (e.g. `huge_app.csv`) written into the PIO
project dir, so `pio check` fails in CMake configure:

    Missing partition table file `.../.build/pio/esp32c2/huge_app.csv`
    UserSideException: Processing esp32c2 ...

This has kept esp32c2 red on master since #2292 (2026-04-18) and blocks
PR #2300.

Short-term: detect fbuild output presence by testing
`.build/.fbuild/build/<env>/release/` (the fbuild artifact dir returned
by `PioCompiler._artifacts_dir` in `ci/compiler/pio.py`). When that
directory exists for the target board, skip `pio check` with a visible
SKIP notice and return 0 rather than fail CI.

This accepts a temporary cppcheck-coverage gap on fbuild-default boards
(esp32c2 today, s3/c3/c6 on deck) until the proper clang-tool-chain-bin
integration lands — tracked by:

- #2301 — fbuild cppcheck support
- #2302 — esp32c2 CI regression (closed by this commit)
- #2303 — umbrella: clang-tool-chain-bin for IWYU + cppcheck +
  other linting tools

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

coderabbitai Bot commented Apr 18, 2026 •

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

A helper function was_compiled_with_fbuild() was added to detect boards compiled with fbuild by checking for fbuild artifact directories. The main() function was updated to skip pio check execution for fbuild-compiled boards, printing "SKIP" and returning early.

Changes

Cohort / File(s) Summary
fbuild Detection and Check Skipping
ci/ci-cppcheck.py
Added was_compiled_with_fbuild() helper to detect fbuild-produced artifacts at .build/.fbuild/build/<board_name>/release/. Modified main() to skip pio check execution for fbuild-compiled boards by detecting them upfront and returning early with SKIP notice.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related issues

Possibly related PRs

Poem

🐰 A rabbit checks the build's birthplace with care,
If fbuild's there, we skip without despair,
No platformio partition needed today,
Just a swift SKIP and we hop away! 🏃‍♂️

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

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.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: detecting fbuild-compiled boards and skipping pio check to fix esp32c2 CI failures.

✏️ 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 fix-ci-esp32c2-cppcheck-skip-on-fbuild

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: 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/ci-cppcheck.py`:
- Around line 102-112: The current was_compiled_with_fbuild function returns
True merely on the existence of build_root/.fbuild/build/<board>/release which
can produce stale-artifact false positives; update was_compiled_with_fbuild to
either (a) consult the authoritative FBUILD_BOARDS set (import from
ci.compiler.fbuild_boards and return board_name in FBUILD_BOARDS) or (b)
strengthen the check to ensure the release directory contains a real recent
firmware artifact (e.g., look for expected firmware files like *.elf/*.bin/*.hex
and optionally validate modification time is recent) before returning True,
keeping the function name and behavior but avoiding stale-directory detection.
🪄 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: a9c3a330-d2bb-4626-a38c-b6bc4e086ecc

📥 Commits

Reviewing files that changed from the base of the PR and between a6e9513 and 541dee3.

📒 Files selected for processing (1)
  • ci/ci-cppcheck.py

Comment thread ci/ci-cppcheck.py
Comment on lines +102 to +112
def was_compiled_with_fbuild(build_root: Path, board_name: str) -> bool:
"""Detect whether the active backend for this board was fbuild.

fbuild writes artifacts under ``.build/.fbuild/build/<env>/release/``
(see ``ci/compiler/pio.py::PioCompiler._artifacts_dir``). If that
directory exists for the target board, fbuild produced the compile,
and ``pio check`` will fail during CMake configure because partition
CSVs and other PIO-side metadata are never written to the PIO project
tree — see FastLED#2302 for the esp32c2 symptom.
"""
return (build_root / ".fbuild" / "build" / board_name / "release").exists()

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

Potential stale-artifact false positive.

Detecting fbuild by the mere existence of .build/.fbuild/build/<board>/release/ will also trigger if the board was previously built with fbuild and is now being recompiled with PlatformIO (e.g., a developer toggling backends locally, or CI caches persisting across runs). In that case pio check would be silently skipped even though a valid PIO project tree exists.

Given this is an explicit short-term unblock tied to #2301/#2302/#2303, this is likely acceptable, but consider either (a) preferring the authoritative FBUILD_BOARDS set from ci/compiler/fbuild_boards.py for detection, or (b) also checking that the release/ directory contains a recent firmware artifact, so stale dirs don't mask regressions.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ci/ci-cppcheck.py` around lines 102 - 112, The current
was_compiled_with_fbuild function returns True merely on the existence of
build_root/.fbuild/build/<board>/release which can produce stale-artifact false
positives; update was_compiled_with_fbuild to either (a) consult the
authoritative FBUILD_BOARDS set (import from ci.compiler.fbuild_boards and
return board_name in FBUILD_BOARDS) or (b) strengthen the check to ensure the
release directory contains a real recent firmware artifact (e.g., look for
expected firmware files like *.elf/*.bin/*.hex and optionally validate
modification time is recent) before returning True, keeping the function name
and behavior but avoiding stale-directory detection.

zackees added a commit that referenced this pull request Apr 18, 2026
Replace the short-term SKIP (#2305) with real cppcheck coverage on
fbuild-compiled boards, using fbuild's own compile database instead of
a PlatformIO project tree.

How it works:

- New helper `ci/util/fbuild_compiledb.py` wraps
  `fbuild build -e <env> --target compiledb` (built into fbuild 2.1+),
  which emits `compile_commands.json` under
  `.build/.fbuild/build/<env>/release/` without performing a full
  compile. The helper also lifts `was_compiled_with_fbuild()` out of
  `ci-cppcheck.py` so other entry points (IWYU, etc.) can share it.
- `ci/ci-cppcheck.py` now branches on `was_compiled_with_fbuild()` and
  invokes `cppcheck --project=<db>/compile_commands.json` directly when
  fbuild is the active backend. PIO-backed boards still go through
  `pio check` unchanged.
- Severity mapping preserved: `--enable=warning,performance,portability`
  covers `pio check --severity=medium`, and `--error-exitcode=1`
  replaces `--fail-on-defect=high`.
- `build_template.yml` and `build_template_custom_board.yml` install
  system `cppcheck` on Linux runners before the CPP Check step. No
  change needed on Windows/macOS runners (fbuild ESP32 boards are
  Linux-only today).

Closes #2301 (fbuild cppcheck support), #2302 (esp32c2 CI regression).
Partial progress on #2303 (clang-tool-chain-bin umbrella) — IWYU
migration to the same compile-DB pathway lands in a follow-up PR.

Supersedes #2305 (short-term SKIP). Once this lands the SKIP branch is
unreachable and can be dropped entirely.

Research memo: `ci/docs/fbuild-static-analysis-research.md` documents
the `clang-tool-chain` package surface (wrappers, Python API) and
fbuild's compile-DB generation. Kept in-tree because #2303 follow-ups
(IWYU, clang-tidy) will keep referring to it.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@zackees
zackees merged commit 095ca55 into master Apr 18, 2026
62 of 80 checks passed
zackees added a commit that referenced this pull request Apr 18, 2026
…d compile DB

Supersedes the short-term SKIP from #2305 with real static-analysis
coverage on fbuild-compiled boards, routed entirely through
`clang-tool-chain-tidy` against fbuild's own compile database. No
system-package dependency, no `pio check`, no PIO project tree.

- New helper `ci/util/fbuild_compiledb.py` wraps `fbuild build -e <env>
  --target compiledb` (built into fbuild 2.1+). Emits
  `.build/.fbuild/build/<env>/release/compile_commands.json` without a
  full compile. Also lifts `was_compiled_with_fbuild()` out of
  `ci-cppcheck.py` (previously inline from #2305) so `ci-iwyu.py` and
  future analysis tools can share it.
- `ci/ci-cppcheck.py` now branches on `was_compiled_with_fbuild()` and
  invokes `uv run clang-tool-chain-tidy -p <db-dir> <src/ files>` for
  fbuild boards. PIO-backed boards continue through `pio check`
  unchanged. `clang-tool-chain` lazily validates/fetches its bundled
  toolchain on first use, so no `apt-get install` is needed. Matches
  the invocation pattern at `ci/lint/stage_impls.py:101-114`.
- `parse_args(argv: list[str] | None = None)` per testability
  guideline. Missing-DB path fails fast with stderr + exit 1
  (per CodeRabbit: no silent fallback on missing critical resources).
- Check selection is governed by the repo-root `.clang-tidy` — already
  enables the cppcheck-equivalent families (`bugprone-*`,
  `clang-analyzer-*`, `performance-*`). No inline `--checks` override.
- Source filter preserved: compile-DB loader filters entries to files
  under `<project_root>/src/`, matching `pio check --src-filters=+<src/>`.
- Research memo `ci/docs/fbuild-static-analysis-research.md` documents
  the `clang-tool-chain` API surface and fbuild's compile-DB behavior.

Closes #2301 (fbuild static-analysis support), #2302 (esp32c2
regression). Phase A of #2303 — IWYU migration onto the same pathway
lands in a follow-up PR.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
zackees added a commit that referenced this pull request Apr 18, 2026
…d compile DB (phase A of #2303) (#2307)

* feat(ci): route static analysis through clang-tool-chain-tidy + fbuild compile DB

Supersedes the short-term SKIP from #2305 with real static-analysis
coverage on fbuild-compiled boards, routed entirely through
`clang-tool-chain-tidy` against fbuild's own compile database. No
system-package dependency, no `pio check`, no PIO project tree.

- New helper `ci/util/fbuild_compiledb.py` wraps `fbuild build -e <env>
  --target compiledb` (built into fbuild 2.1+). Emits
  `.build/.fbuild/build/<env>/release/compile_commands.json` without a
  full compile. Also lifts `was_compiled_with_fbuild()` out of
  `ci-cppcheck.py` (previously inline from #2305) so `ci-iwyu.py` and
  future analysis tools can share it.
- `ci/ci-cppcheck.py` now branches on `was_compiled_with_fbuild()` and
  invokes `uv run clang-tool-chain-tidy -p <db-dir> <src/ files>` for
  fbuild boards. PIO-backed boards continue through `pio check`
  unchanged. `clang-tool-chain` lazily validates/fetches its bundled
  toolchain on first use, so no `apt-get install` is needed. Matches
  the invocation pattern at `ci/lint/stage_impls.py:101-114`.
- `parse_args(argv: list[str] | None = None)` per testability
  guideline. Missing-DB path fails fast with stderr + exit 1
  (per CodeRabbit: no silent fallback on missing critical resources).
- Check selection is governed by the repo-root `.clang-tidy` — already
  enables the cppcheck-equivalent families (`bugprone-*`,
  `clang-analyzer-*`, `performance-*`). No inline `--checks` override.
- Source filter preserved: compile-DB loader filters entries to files
  under `<project_root>/src/`, matching `pio check --src-filters=+<src/>`.
- Research memo `ci/docs/fbuild-static-analysis-research.md` documents
  the `clang-tool-chain` API surface and fbuild's compile-DB behavior.

Closes #2301 (fbuild static-analysis support), #2302 (esp32c2
regression). Phase A of #2303 — IWYU migration onto the same pathway
lands in a follow-up PR.

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

* review(ci-cppcheck): resolve relative compile-DB file paths per JSON spec

Per the JSON Compilation Database spec, the `file` field may be absolute
or relative to the entry's `directory` field. The previous code used
`Path(raw).resolve()` which resolves against the Python CWD, so a
relative `file` would resolve incorrectly and be silently filtered out
of the src/ list — potentially yielding zero TUs (and a success return)
even though fbuild had actually emitted source entries.

Fix: when `file` is relative, resolve it against the entry's `directory`
(falling back to the compile DB's parent when `directory` is missing),
matching what clang-tidy / clangd itself does. Addresses CodeRabbit on
PR #2307 (ci/ci-cppcheck.py:128, fingerprint f24a46e1).

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

* review(fbuild-compiledb): canonical fbuild arg order + stderr + KeyboardInterrupt

Two CodeRabbit fixes on PR #2307:

- Move `str(project_root)` to position 1 (before `build`), matching the
  canonical FastLED fbuild invocation pattern at
  `ci/util/fbuild_runner.py:104-114`: `[fbuild, <project_dir>, build, -e <env>, …]`.
  `cwd=str(project_root)` stays set so config discovery is identical
  regardless of whether the positional is honored by a given fbuild
  version.
- Route the failure message to `sys.stderr` for stream consistency with
  the caller in `ci/ci-cppcheck.py`, and add an explicit
  `KeyboardInterrupt` re-raise ahead of the broader exception tuple so
  Ctrl-C can never be swallowed if the tuple is extended later.

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

---------

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
@zackees
zackees deleted the fix-ci-esp32c2-cppcheck-skip-on-fbuild branch August 30, 2026 22:22
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.

CI regression: esp32c2 CPP Check fails — pio check can't resolve huge_app.csv after fbuild compile

1 participant