Skip to content

Commit d61ca7c

Browse files
committed
[ci] Check cmake-format
1 parent 7fd32a0 commit d61ca7c

2 files changed

Lines changed: 48 additions & 0 deletions

File tree

.cmake-format.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
format:
2+
line_width: 80
3+
tab_size: 4
4+
use_tabchars: false
5+
6+
# Command formatting
7+
command_case: lower
8+
disable_paren_padding: true
9+
10+
# Indentation
11+
continuation_indent_width: 4
12+
dangle_parens: false
13+
14+
# Lists / wrapping
15+
max_sublist_length: 3
16+
tight_list_bracket: true
17+
18+
# Comments
19+
comment_follows_code: false
20+
comment_indent: 0
21+
22+
# Blank lines
23+
max_empty_lines: 2
24+
25+
# Misc
26+
split_before_named_args: false
27+
split_before_variadic_args: false
28+
split_before_bracket: false

.github/workflows/format.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,29 @@ jobs:
1919
- name: Checkout repository
2020
uses: actions/checkout@v5
2121

22+
# clang-format
2223
- name: Run clang-format check
2324
uses: jidicula/clang-format-action@v4.16.0
2425
with:
2526
clang-format-version: "22"
2627
check-path: "."
2728
exclude-regex: 'test/catch\.hpp'
29+
30+
# cmake-format
31+
- name: Set up Python
32+
uses: actions/setup-python@v6
33+
with:
34+
python-version: '3.x'
35+
36+
- name: Install cmakelang
37+
run: pip install cmakelang pyyaml
38+
39+
- name: Run cmake-format check
40+
run: |
41+
find . \( -name "CMakeLists.txt" -o -name "*.cmake" \) -print0 | while IFS= read -r -d '' file; do
42+
if ! cmp -s "$file" <(cmake-format "$file"); then
43+
echo "Misformatted: $file"
44+
git diff --no-index --color "$file" <(cmake-format "$file")
45+
echo
46+
fi
47+
done

0 commit comments

Comments
 (0)