diff --git a/.github/workflows/clang-format b/.github/workflows/clang-format new file mode 100644 index 000000000..60846c7c3 --- /dev/null +++ b/.github/workflows/clang-format @@ -0,0 +1,30 @@ +name: Check formatting + +on: pull_request + +permissions: + contents: read + pull-requests: write + +jobs: + format-check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - uses: reviewdog/action-setup@v1 + + - name: Check formatting on changed lines + env: + REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + git clang-format --diff origin/${{ github.base_ref }}...HEAD -- \ + '*.c' '*.cpp' '*.cc' '*.h' '*.hpp' \ + | reviewdog \ + -name="clang-format" \ + -f=diff \ + -reporter=github-pr-review \ + -fail-level=error \ + -filter-mode=added