From 96a9fce149629cbb7effd7162fba0af3698c90bf Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 5 Aug 2026 19:53:04 +0530 Subject: [PATCH] Enforce formatting of C code in CI --- .github/workflows/ci.py | 3 +++ .github/workflows/ci.yml | 3 +++ 2 files changed, 6 insertions(+) diff --git a/.github/workflows/ci.py b/.github/workflows/ci.py index b83f429b1..5e1f15273 100644 --- a/.github/workflows/ci.py +++ b/.github/workflows/ci.py @@ -350,6 +350,9 @@ def main() -> None: raise SystemExit(q) if subprocess.run(['ruff', 'format', '--check']).returncode != 0: raise SystemExit('Some Python files are not formatted correctly') + c_files = subprocess.check_output(['git', 'ls-files', '*.c', '*.h', '*.m']).decode().split() + if c_files and subprocess.run(['clang-format', '--dry-run', '--Werror'] + c_files).returncode != 0: + raise SystemExit('Some C/ObjC files are not formatted correctly') elif action == 'check-dependencies': check_dependencies() else: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c6fe578f2..6de663978 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -111,6 +111,9 @@ jobs: - name: Run ruff run: ruff check . + - name: Install clang-format + run: sudo apt-get install -y clang-format + - name: Check code formatting run: go version && python .github/workflows/ci.py check_code_formatting