Skip to content

Commit

Permalink
Add clang-format checker GitHub action. (#5617)
Browse files Browse the repository at this point in the history
This action runs clang-format-diff on the difference between the head
and the merge base to identify introductions of clang-format violtions
in changed code.
  • Loading branch information
llvm-beanz authored Sep 19, 2023
1 parent 4d132f9 commit d4b3cb6
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/clang-format-checker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: 'PR clang-format checker'
on:
pull_request:
types:
- opened
- edited
- synchronize
- reopened
jobs:
check-pr-formatting:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: install clang-format
run: sudo apt install -y clang-format
- run: |
echo Comparing $GITHUB_BASE_REF vs HEAD
git diff -U0 --no-color origin/$GITHUB_BASE_REF..HEAD | clang-format-diff -p1 | tee format.diff
if [ -s "format.diff" ]
then
exit 1
fi
- if: failure()
uses: actions/github-script@v6
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'PR contains clang-format violations. See action log for diff.'
})

0 comments on commit d4b3cb6

Please sign in to comment.