name: clang-format
on: [pull_request]
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

jobs:
  clang-format:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 2
      - name: Install clang-format
        run: |
          sudo apt-get update
          sudo apt-get install -y clang-format-14
      - name: Run clang-format
        run: |
          ./run-clang-format.sh
          git diff --exit-code