diff --git a/.github/workflows/clang-format.yml b/.github/workflows/clang-format.yml new file mode 100644 index 0000000..38a328a --- /dev/null +++ b/.github/workflows/clang-format.yml @@ -0,0 +1,40 @@ +name: Clang-format check + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +permissions: + contents: read + checks: write + issues: write + pull-requests: write + +jobs: + clang-format-check: + runs-on: ubuntu-latest + timeout-minutes: 5 + steps: + - name: Checkout repository + uses: actions/checkout@v5 + + - name: Install clang-format + run: sudo apt-get install -y clang-format-19 + + - name: Run clang-format + run: > + git ls-files '*.cpp' '*.c' '*.hpp' '*.h' | + xargs -r clang-format-19 -i + + - name: Suggest clang-format fixes + if: github.event_name == 'pull_request' + uses: reviewdog/action-suggester@v1 + with: + tool_name: clang-format-19 + fail_level: any + level: warning + + - name: Verify no formatting changes are needed + run: git --no-pager diff --exit-code -- .