Repository navigation
fix(ci): pin clang-format 18.1.8 in the firmware formatting check - #24806
Conversation
ubuntu-latest moved to ubuntu-26.04, whose clang-format adds a space before compound-literal braces that clang-format 18 removes. The hosted check then rejects firmware files that the pre-commit hook accepts. Install clang-format==18.1.8 into a dedicated venv and run that binary, so the check matches pre-commit and does not depend on the runner image.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
2 issues found across 2 files
Confidence score: 4/5
scripts/pre-commitaccepts any clang-format 18 release, while CI pins 18.1.8, so local and hosted formatting can differ. Pin and validate the full version, or revise the prevention record to match the actual policy.repo-checks.ymlinstalls clang-format before checking whetherFILESis empty, so a firmware deletion can still depend on venv setup and PyPI. ComputeFILESfirst and skip installation when there are no files to check.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name=".github/failure-classes/FC-clang-format-runner-image-drift.json">
<violation number="1" location=".github/failure-classes/FC-clang-format-runner-image-drift.json:5">
P2: This prevention record claims exact local/hosted version parity, but `scripts/pre-commit` accepts any clang-format 18 release while CI runs exactly 18.1.8. Pin and validate the full version in the hook, or describe the contract as major-version parity; otherwise this class can recur without the documented guard detecting it.</violation>
</file>
<file name=".github/workflows/repo-checks.yml">
<violation number="1" location=".github/workflows/repo-checks.yml:327">
P2: The job installs clang-format before checking whether any existing firmware files need formatting. A firmware deletion leaves `FILES` empty but still depends on venv creation and PyPI; compute `FILES` first and install/run the formatter only inside the non-empty branch.</violation>
</file>
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
| "schema_version": 1, | ||
| "id": "FC-clang-format-runner-image-drift", | ||
| "violated_contract": "The firmware C/C++ Formatting check in Repo Checks must use the same clang-format version as the local pre-commit hook. When the hosted runner image changes its system clang-format, a clean firmware file can fail the hosted check even though pre-commit accepted it.", | ||
| "canonical_prevention": "The Formatting job installs clang-format==18.1.8 into a dedicated venv and runs that binary, not the runner's system clang-format. scripts/pre-commit refuses to reformat firmware C unless clang-format 18 is on PATH, so the local and hosted versions match.", |
There was a problem hiding this comment.
P2: This prevention record claims exact local/hosted version parity, but scripts/pre-commit accepts any clang-format 18 release while CI runs exactly 18.1.8. Pin and validate the full version in the hook, or describe the contract as major-version parity; otherwise this class can recur without the documented guard detecting it.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At .github/failure-classes/FC-clang-format-runner-image-drift.json, line 5:
<comment>This prevention record claims exact local/hosted version parity, but `scripts/pre-commit` accepts any clang-format 18 release while CI runs exactly 18.1.8. Pin and validate the full version in the hook, or describe the contract as major-version parity; otherwise this class can recur without the documented guard detecting it.</comment>
<file context>
@@ -0,0 +1,17 @@
+ "schema_version": 1,
+ "id": "FC-clang-format-runner-image-drift",
+ "violated_contract": "The firmware C/C++ Formatting check in Repo Checks must use the same clang-format version as the local pre-commit hook. When the hosted runner image changes its system clang-format, a clean firmware file can fail the hosted check even though pre-commit accepted it.",
+ "canonical_prevention": "The Formatting job installs clang-format==18.1.8 into a dedicated venv and runs that binary, not the runner's system clang-format. scripts/pre-commit refuses to reformat firmware C unless clang-format 18 is on PATH, so the local and hosted versions match.",
+ "canonical_prevention_artifact": [
+ ".github/workflows/repo-checks.yml",
</file context>
| # Pin clang-format to the version pre-commit uses. ubuntu-latest moved to | ||
| # ubuntu-26.04, whose clang-format adds a space before compound-literal | ||
| # braces that clang-format 18 removes, so the runner image must not decide. | ||
| CLANG_FORMAT_VENV="$RUNNER_TEMP/clang-format-18" |
There was a problem hiding this comment.
P2: The job installs clang-format before checking whether any existing firmware files need formatting. A firmware deletion leaves FILES empty but still depends on venv creation and PyPI; compute FILES first and install/run the formatter only inside the non-empty branch.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At .github/workflows/repo-checks.yml, line 327:
<comment>The job installs clang-format before checking whether any existing firmware files need formatting. A firmware deletion leaves `FILES` empty but still depends on venv creation and PyPI; compute `FILES` first and install/run the formatter only inside the non-empty branch.</comment>
<file context>
@@ -321,7 +321,15 @@ jobs:
+ # Pin clang-format to the version pre-commit uses. ubuntu-latest moved to
+ # ubuntu-26.04, whose clang-format adds a space before compound-literal
+ # braces that clang-format 18 removes, so the runner image must not decide.
+ CLANG_FORMAT_VENV="$RUNNER_TEMP/clang-format-18"
+ python3 -m venv "$CLANG_FORMAT_VENV"
+ "$CLANG_FORMAT_VENV/bin/pip" install --quiet clang-format==18.1.8
</file context>
Requested by David
What changed and why
Fixes the Repo Checks / Formatting failure on PRs that touch firmware C files with compound literals, for example #24393 (run 42305654687, job 128194880599,
tests/test_power_off_queue.c).GitHub's
ubuntu-latestmoved to ubuntu-26.04. Its clang-format adds a space before compound-literal braces, while the firmware pre-commit hook pins clang-format 18, which removes it. The hosted check therefore rejects files the local hook accepts.The Formatting job now installs
clang-format==18.1.8into a dedicated venv under$RUNNER_TEMPand runs that binary. That matches the local pre-commit pin and holds when runners change again. No runner image is pinned.Product invariants affected
None. The change is limited to the CI formatting step.
How it was verified
Tests
None added. The hosted Formatting job is the test.
UI evidence
Not applicable.
Failure class (fixes)
Failure-Class: new
New class definition:
.github/failure-classes/FC-clang-format-runner-image-drift.json. This PR is its evidence.New guards (only when adding a check or ratchet)
The Formatting job now pins the formatter version itself. The local pre-commit guard already refuses other versions.