Skip to content

Commit 80b0306

Browse files
baderalexbatashev
andauthored
[CI] Add clang-format checker to pre-commit checks (#1163)
Signed-off-by: Alexey Bader [email protected] Co-Authored-By: Alexander Batashev <[email protected]>
1 parent 7a9a425 commit 80b0306

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

.github/workflows/clang-format.yml

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: clang-format-check
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- sycl
7+
types: [open, edit, reopen, synchronize]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v2
14+
with:
15+
# checkout PR head
16+
ref: '${{github.event.pull_request.head.sha}}'
17+
- name: Fetch target branch
18+
run: git fetch --no-tags --prune --depth=1 origin +refs/heads/${{github.base_ref}}:refs/remotes/origin/${{github.base_ref}}
19+
20+
- name: Get clang-format first
21+
run: sudo apt-get install -yqq clang-format-9
22+
23+
- name: Run clang-format for the patch
24+
run: |
25+
git diff -U0 --no-color origin/${{github.base_ref}}..HEAD | ./clang/tools/clang-format/clang-format-diff.py -p1 -binary clang-format-9 > ./clang-format.patch
26+
27+
# Add patch with formatting fixes to CI job artifacts
28+
- uses: actions/upload-artifact@v1
29+
with:
30+
name: clang-format-patch
31+
path: ./clang-format.patch
32+
33+
- name: Check if clang-format patch is empty
34+
run: bash -c "if [ -s ./clang-format.patch ]; then cat ./clang-format.patch; exit 1; fi"

0 commit comments

Comments
 (0)