Skip to content

fix(ci): pin clang-format 18.1.8 in the firmware formatting check - #24806

Merged
Git-on-my-level merged 1 commit into
mainfrom
fix/repo-checks-clang-format-18
Nov 6, 2026
Merged

Git-on-my-level merged 1 commit into
mainfrom
fix/repo-checks-clang-format-18

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Nov 6, 2026 •

Copy link
Copy Markdown
Member

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-latest moved 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.8 into a dedicated venv under $RUNNER_TEMP and 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

  • The workflow file parses as YAML.
  • The local firmware formatter check is still clang-format 18, per scripts/pre-commit.
  • Not run here: the hosted Formatting job. The first real run on this PR is the check.

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.

View guided diff Turn on auto-fix

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.
@Git-on-my-level Git-on-my-level self-assigned this Nov 6, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-06T23:06:08.325413Z 32b3d2a PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@cubic-dev-ai cubic-dev-ai 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.

2 issues found across 2 files

Confidence score: 4/5

  • scripts/pre-commit accepts 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.yml installs clang-format before checking whether FILES is empty, so a firmware deletion can still depend on venv setup and PyPI. Compute FILES first 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.",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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>

@Git-on-my-level
Git-on-my-level merged commit ebd1297 into main Nov 6, 2026
61 checks passed
@Git-on-my-level
Git-on-my-level deleted the fix/repo-checks-clang-format-18 branch November 6, 2026 23:23
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