mirror of
https://github.com/sysprog21/lkmpg.git
synced 2024-11-25 09:41:47 +08:00
Check coding style in CI
This commit is contained in:
parent
48cb100473
commit
2db805da2c
21
.ci/check-format.sh
Executable file
21
.ci/check-format.sh
Executable file
|
@ -0,0 +1,21 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
SOURCES=$(find $(git rev-parse --show-toplevel) | egrep "\.(cpp|cc|c|h)\$")
|
||||
|
||||
CLANG_FORMAT=$(which clang-format-11)
|
||||
if [ $? -ne 0 ]; then
|
||||
CLANG_FORMAT=$(which clang-format)
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "[!] clang-format not installed. Unable to check source file format policy." >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
set -x
|
||||
|
||||
for file in ${SOURCES};
|
||||
do
|
||||
$CLANG_FORMAT ${file} > expected-format
|
||||
diff -u -p --label="${file}" --label="expected coding style" ${file} expected-format
|
||||
done
|
||||
exit $($CLANG_FORMAT --output-replacements-xml ${SOURCES} | egrep -c "</replacement>")
|
11
.github/workflows/generate_doc.yaml
vendored
11
.github/workflows/generate_doc.yaml
vendored
|
@ -35,3 +35,14 @@ jobs:
|
|||
lkmpg-html.tar.gz
|
||||
tag_name: "latest"
|
||||
prerelease: true
|
||||
|
||||
coding_style:
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
- name: checkout code
|
||||
uses: actions/checkout@v2
|
||||
- name: style check
|
||||
run: |
|
||||
sudo apt-get install -q -y clang-format-11
|
||||
sh .ci/check-format.sh
|
||||
shell: bash
|
||||
|
|
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -29,3 +29,6 @@ lkmpg.pdf
|
|||
*.lg
|
||||
*.idv
|
||||
*.xref
|
||||
|
||||
# format checks
|
||||
expected-format
|
||||
|
|
Loading…
Reference in New Issue
Block a user