43 lines
1.1 KiB
YAML
43 lines
1.1 KiB
YAML
name: check-code-format
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
pull_request:
|
|
types: [opened, reopened, synchronize]
|
|
push:
|
|
branches: [main, master]
|
|
|
|
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 ./src -type f \( -name "*.h" -o -name "*.c" -o -name "*.cpp" \) \
|
|
! -path "*/spatialmedia/*" \
|
|
! -name "defaultlayouts.h" \
|
|
! -path "*_autogen*")
|
|
|
|
if [ -z "$FILES" ]; then
|
|
echo "No source files found to check"
|
|
exit 0
|
|
fi
|
|
|
|
echo "Checking $(echo "$FILES" | wc -l) files..."
|
|
clang-format-14 --dry-run --Werror -style=file $FILES
|
|
|
|
if [ $? -eq 0 ]; then
|
|
echo "SUCCESS: All files are formatted correctly"
|
|
else
|
|
echo "FAILURE: Some files are formatted incorrectly"
|
|
echo "Run 'clang-format-14 -i <files>' locally to fix"
|
|
exit 1
|
|
fi
|