name: Code Format Check

on: [push, pull_request]

permissions:
  contents: read

jobs:
  formatting:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v4

      - name: Install LLVM 22
        run: |
          wget https://apt.llvm.org/llvm.sh
          chmod +x llvm.sh
          sudo ./llvm.sh 22
          clang-format-22 --version

      - name: Run clang-format
        run: |
          find src include \
            \( -name '*.cpp' -o -name '*.hpp' \) \
            -print0 | xargs -0 clang-format-22 --dry-run --Werror