-
Notifications
You must be signed in to change notification settings - Fork 99
48 lines (38 loc) · 1.33 KB
/
format.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
name: github-FORMAT
on:
pull_request:
branches:
- master
- develop
permissions:
contents: none
jobs:
clang-format-check:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- name: Install Dependencies
run: sudo apt install clang-format-8
- name: check
run: |
# Fetch from the default remote (origin)
git fetch &> /dev/null
# For every file changed, apply clang-format
for file in $(git diff --name-only origin/$GITHUB_BASE_REF | egrep '.*\.cpp$|.*\.hpp$|.*\.h$'); do
if [ -e $file ]; then
clang-format-8 -i -style=file $file
git add $file
fi
done
# If any diffs exist, print the patch and error out
if [[ ! -z $(git status -s -uno . -- ':!.github') ]]; then
echo "The following files require formatting changes:"
git status -s -uno . -- ':!.github'
echo "==== Begin Format Patch ===="
# --cached means show staged changes (git add above)
git --no-pager diff --patch --cached
echo "==== End Format Patch ===="
echo "To automate formatting, see:"
echo " https://kokkos-kernels.readthedocs.io/en/latest/developer/style.html#id1"
exit 1
fi