-
Notifications
You must be signed in to change notification settings - Fork 66
61 lines (57 loc) · 1.66 KB
/
clang-format.yml
File metadata and controls
61 lines (57 loc) · 1.66 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
name: Check Code Formatting
on:
pull_request:
paths:
- '**.c'
- '**.h'
- '**.cpp'
- '**.hpp'
push:
branches:
- master
paths:
- '**.c'
- '**.h'
- '**.cpp'
- '**.hpp'
jobs:
clang-format:
name: clang-format
runs-on: ubuntu-22.04
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
submodules: false
- name: Run clang-format
shell: bash
working-directory: ${{ github.workspace }}
run: |
cf_vers=14
echo -n "Checking coding style with clang-format ${cf_vers}..."
fail=0
while read -r i; do
if ! clang-format-${cf_vers} --Werror --dry-run "${i}" > /dev/null 2>&1;
then
if [ "${fail}" == "0" ]; then
echo "[FAIL]"
echo "::group::Required Fix-up Commands"
fi
fail=1
msg="::warning file=${i}::Please run clang-format-${cf_vers} "
msg+="-i ${i}"
echo "${msg}"
fi
done < <(find NFIQ2 \( -name "*.c" -o -name "*.h" \
-o -name "*.cpp" -o -name "*.hpp" \) -a \! -path '*wsq*' \
-a \! -name 'RandomForestTrainedParams.h')
if [ "${fail}" == "1" ]; then
echo "::endgroup::"
msg="Please run the above files through clang-format ${cf_vers} "
msg+="using the .clang-format configuration and push your changes "
msg+="to the same branch. See CONTRIBUTING.md for more information."
echo "::error ::${msg}"
exit 1
else
echo "[OKAY]"
fi