Enforce formatting of C code in CI

This commit is contained in:
Kovid Goyal 2026-08-05 19:53:04 +05:30
parent 2af2d313de
commit 96a9fce149
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
2 changed files with 6 additions and 0 deletions

View file

@ -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:

View file

@ -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