Skip to content

Commit

Permalink
add clang-format action
Browse files Browse the repository at this point in the history
Signed-off-by: peter <[email protected]>
Signed-off-by: Hanqing Wu <[email protected]>
  • Loading branch information
peter5232 authored and wu-hanqing committed Aug 31, 2023
1 parent 6f5c85b commit f6b285d
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/clang-format.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Code Fomatter

# run on pull requests to develop
on:
pull_request

jobs:
format:
name: Clang Formatter
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.head_ref }}
# fetch everything to be able to compare with any ref
fetch-depth: 0

- name: Check
env:
LANG: "C.UTF-8"
LC_ALL: "C.UTF-8"
LANGUAGE: "C.UTF-8"
run: |
sudo apt install -y clang-format-15 python3 git
diff_output_file=$(mktemp)
git --no-pager diff -U0 --diff-filter=ACMRT ${{github.event.pull_request.base.sha}} ${{ github.event.pull_request.head.sha }} | clang-format-diff-15 -p1 2>&1 | tee $diff_output_file
if [ -s $diff_output_file ]; then
exit 1
else
exit 0
fi

0 comments on commit f6b285d

Please sign in to comment.