Skip to content

Commit ea89b78

Browse files
peter5232wu-hanqing
authored andcommitted
add clang-format action
Signed-off-by: peter <[email protected]> Signed-off-by: Hanqing Wu <[email protected]>
1 parent 6f5c85b commit ea89b78

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

.github/workflows/clang-format.yaml

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Code Formatter
2+
3+
# run on pull requests to develop
4+
on:
5+
pull_request
6+
7+
jobs:
8+
format:
9+
name: Clang Formatter
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v2
13+
with:
14+
ref: ${{ github.head_ref }}
15+
# fetch everything to be able to compare with any ref
16+
fetch-depth: 0
17+
18+
- name: Check
19+
env:
20+
LANG: "C.UTF-8"
21+
LC_ALL: "C.UTF-8"
22+
LANGUAGE: "C.UTF-8"
23+
run: |
24+
sudo apt-get install -y clang-format-14 python3 git
25+
diff_output_file=$(mktemp)
26+
git --no-pager diff -U0 --diff-filter=ACMRT ${{github.event.pull_request.base.sha}} ${{ github.event.pull_request.head.sha }} | clang-format-diff-14 -p1 2>&1 | tee $diff_output_file
27+
if [ -s $diff_output_file ]; then
28+
exit 1
29+
else
30+
exit 0
31+
fi
32+

0 commit comments

Comments
 (0)