forked from odriverobotics/ODriveArduino
-
Notifications
You must be signed in to change notification settings - Fork 0
36 lines (29 loc) · 944 Bytes
/
formatting.yaml
File metadata and controls
36 lines (29 loc) · 944 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
name: Clang-Format Check
on:
push:
branches: [master]
pull_request:
paths:
- '**/*.cpp'
- '**/*.h'
- '**/*.hpp'
jobs:
clang-format-check:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Clang-Format
run: sudo apt-get install -y clang-format
- name: Run Clang-Format Check
run: |
files=$(find . -name "*.cpp" -o -name "*.hpp" -o -name "*.h")
check_ignore=$(git -c core.excludesFile="format-ignore.txt" check-ignore --stdin --no-index --non-matching --verbose <<< "$files")
files=$(awk '/^::/ {print $2}' <<< "$check_ignore")
echo "Checking $(echo "$files" | wc -l) files"
if [ -n "$files" ]; then
clang-format -style=file -i $files
git diff --exit-code || (echo "Clang-Format check failed!" && exit 1)
else
echo "No files to check."
fi