-
Notifications
You must be signed in to change notification settings - Fork 9
63 lines (61 loc) · 1.93 KB
/
check-code-formatting.yml
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
name: Check Code Formatting
on: [push, pull_request]
jobs:
cpp-formatting:
runs-on: ubuntu-latest
env:
CLANG_FORMAT: clang-format-15
steps:
- uses: actions/checkout@v2
- name: Install clang-format
run: sudo apt-get update && sudo apt-get install -y --no-install-recommends $CLANG_FORMAT && $CLANG_FORMAT --version
- name: Run clang-format
run: |
files=$(find . -iregex '.*\.\(h\|hh\|hpp\|c\|cc\|cpp\|cxx\)')
for f in $files; do
echo "Checking: ${f}"
d=$(diff -u "$f" <($CLANG_FORMAT -style=file "$f") || true)
if ! [ -z "$d" ]; then
echo "$d"
fail=1
fi
done
if [ "$fail" = 1 ]; then
echo -e "\033[1;31mYou must pass the clang-format checks before submitting a pull request.\033[0m"
exit 1
fi
cmake-formatting:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install cmake-format
run: pip install pyyaml cmakelang && cmake-format --version
- name: Run cmake-format
run: |
files=$(find . -name CMakeLists.txt)
for f in $files; do
echo "Checking: ${f}"
d=$(diff -u "$f" <(cmake-format "$f") || true)
if ! [ -z "$d" ]; then
echo "$d"
fail=1
fi
done
if [ "$fail" = 1 ]; then
echo -e "\033[1;31mYou must pass the cmake-format checks before submitting a pull request.\033[0m"
exit 1
fi
python-formatting:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install ruff
run: pip install ruff && ruff --version
- name: Run ruff
run: ruff check