Skip to content

Commit 79dafdd

Browse files
committed
Make the CI check for bad formatting
1 parent 6706029 commit 79dafdd

2 files changed

Lines changed: 59 additions & 0 deletions

File tree

.github/workflows/source.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@ jobs:
1818
python3 -m pip install -U flake8
1919
python3 -m flake8 --exclude=thirdParty .
2020
21+
clang-format:
22+
runs-on: ubuntu-20.04
23+
steps:
24+
- uses: actions/checkout@v2
25+
- name: clang-format
26+
run: |
27+
conda install -c conda-forge clang-format
28+
.github/workflows/source/clang-format
29+
2130
static-analysis:
2231
runs-on: ubuntu-20.04
2332
steps:
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Copyright 2016-2021 Axel Huebl
4+
#
5+
# License: LGPLv3+
6+
7+
# search recursive inside a folder if a file contains tabs
8+
#
9+
# @result 0 if no files are found, else 1
10+
#
11+
12+
__awkscript() {
13+
cat << EOF
14+
BEGIN {
15+
modified = 0;
16+
}
17+
18+
{
19+
if (\$1 == "M") {
20+
modified = 1;
21+
}
22+
}
23+
END {
24+
print modified;
25+
}
26+
EOF
27+
}
28+
awkscript="$(__awkscript)"
29+
30+
./format.sh
31+
if [[ $? -ne 0 ]]
32+
then
33+
echo "# Unable to format the source tree"
34+
exit 1
35+
fi
36+
37+
modified="$(git status --short | awk "$awkscript")"
38+
if [[ "$modified" -eq 1 ]]
39+
then
40+
cat << EOF
41+
# Code must be formatted by clang-format.
42+
# Use the format.sh script contained in the source tree.
43+
# Bad files:
44+
EOF
45+
git status --short \
46+
| awk '{if ($1 == "M"){ printf "# %s\n", $2 }}'
47+
exit 1
48+
fi
49+
50+
exit 0

0 commit comments

Comments
 (0)