Skip to content

Commit 2db805d

Browse files
committed
Check coding style in CI
1 parent 48cb100 commit 2db805d

File tree

3 files changed

+35
-0
lines changed

3 files changed

+35
-0
lines changed

.ci/check-format.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env bash
2+
3+
SOURCES=$(find $(git rev-parse --show-toplevel) | egrep "\.(cpp|cc|c|h)\$")
4+
5+
CLANG_FORMAT=$(which clang-format-11)
6+
if [ $? -ne 0 ]; then
7+
CLANG_FORMAT=$(which clang-format)
8+
if [ $? -ne 0 ]; then
9+
echo "[!] clang-format not installed. Unable to check source file format policy." >&2
10+
exit 1
11+
fi
12+
fi
13+
14+
set -x
15+
16+
for file in ${SOURCES};
17+
do
18+
$CLANG_FORMAT ${file} > expected-format
19+
diff -u -p --label="${file}" --label="expected coding style" ${file} expected-format
20+
done
21+
exit $($CLANG_FORMAT --output-replacements-xml ${SOURCES} | egrep -c "</replacement>")

.github/workflows/generate_doc.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,14 @@ jobs:
3535
lkmpg-html.tar.gz
3636
tag_name: "latest"
3737
prerelease: true
38+
39+
coding_style:
40+
runs-on: ubuntu-20.04
41+
steps:
42+
- name: checkout code
43+
uses: actions/checkout@v2
44+
- name: style check
45+
run: |
46+
sudo apt-get install -q -y clang-format-11
47+
sh .ci/check-format.sh
48+
shell: bash

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,6 @@ lkmpg.pdf
2929
*.lg
3030
*.idv
3131
*.xref
32+
33+
# format checks
34+
expected-format

0 commit comments

Comments
 (0)