-
Notifications
You must be signed in to change notification settings - Fork 16
68 lines (58 loc) · 1.94 KB
/
format-check.yml
File metadata and controls
68 lines (58 loc) · 1.94 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
name: Format Check
on:
push:
branches: [ develop ]
pull_request:
branches: [ develop ]
jobs:
clang-format-check:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install clang-format
run: |
sudo apt-get update
sudo apt-get install -y clang-format-18
- name: Check C++ code format
run: |
EXIT_CODE=0
while read file; do
if ! clang-format --dry-run --Werror "$file"; then
echo "$file is not properly formatted"
echo "Run: clang-format -i $file"
EXIT_CODE=1
fi
done < <(find . -name "*.cpp" -o -name "*.hpp" -o -name "*.c" -o -name "*.h" -o -name "*.cc" -o -name "*.cxx")
if [ $EXIT_CODE -eq 1 ]; then
echo "Some C/C++ files are not properly formatted. Reformat with clang-format-18."
exit 1
fi
echo "All C/C++ files are properly formatted"
cmake-format-check:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install cmake-format
run: |
pip install PyYAML cmake-format==0.6.11
- name: Check CMake code format
run: |
EXIT_CODE=0
while read file; do
if ! cmake-format --check -c .cmake-format.yaml "$file"; then
echo "$file is not properly formatted"
echo "Run: cmake-format -i $file"
EXIT_CODE=1
fi
done < <(find . -name "CMakeLists.txt" -o -name "*.cmake")
if [ $EXIT_CODE -eq 1 ]; then
echo "Some CMake files are not properly formatted. Reformat with cmake-format 0.6.11"
exit 1
fi
echo "All CMake files are properly formatted"