Create check-code-format
This commit is contained in:
40
.github/workflows/check-code-format
vendored
Normal file
40
.github/workflows/check-code-format
vendored
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
name: check-code-format
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
pull_request:
|
||||||
|
types: [opened, reopened]
|
||||||
|
push:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
clang-format:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Install clang-format
|
||||||
|
run: sudo apt-get install -y clang-format-14
|
||||||
|
|
||||||
|
- name: Check style
|
||||||
|
run: |
|
||||||
|
FILES=`find . -type f -name "*.h" -o -name "*.c" -o -name "*.cpp"`
|
||||||
|
FILTERED_FILES=()
|
||||||
|
for file in ${FILES[@]};
|
||||||
|
do
|
||||||
|
[[ $file =~ "./src/" ]] &&
|
||||||
|
[[ ! $file =~ "spatialmedia" ]] &&
|
||||||
|
[[ ! $file =~ "defaultlayouts.h" ]] &&
|
||||||
|
[[ ! $file =~ "_autogen" ]] &&
|
||||||
|
FILTERED_FILES+=($file)
|
||||||
|
done
|
||||||
|
clang-format-14 --verbose --dry-run --Werror -style=file -i ${FILTERED_FILES[@]}
|
||||||
|
if [ $? -eq 0 ]
|
||||||
|
then
|
||||||
|
echo "SUCCESS: All files are formatted correctly"
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
echo "FAILURE: some files are formatted incorrectly"
|
||||||
|
exit 99
|
||||||
|
fi
|
||||||
Reference in New Issue
Block a user