Skip to content

Commit b7d2563

Browse files
Merge pull request #102 from marcel-licence/101-apply-indentation-check
add missing indentation check
2 parents a8a30b1 + df702fb commit b7d2563

File tree

1 file changed

+54
-11
lines changed

1 file changed

+54
-11
lines changed

.github/workflows/check_style.yml

Lines changed: 54 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,70 @@
11
name: Verify code formatting
2+
23
on:
34
push:
5+
branches: [ "main" ]
46
pull_request:
7+
branches: [ "main" ]
8+
workflow_dispatch:
59

610
jobs:
711
verify-formatting:
8-
if: ${{ github.event_name != 'pull_request' || github.repository != github.event.pull_request.head.repo.full_name }}
9-
runs-on: ubuntu-22.04
12+
runs-on: ubuntu-latest
1013
steps:
1114
- name: Checkout
1215
uses: actions/checkout@v4
1316
with:
1417
persist-credentials: false
1518
fetch-depth: 0
16-
- name: Checkout astyle
17-
uses: actions/checkout@v4
18-
with:
19-
repository: szepeviktor/astyle
20-
path: astyle
21-
ref: v3.4.12
2219
- name: Install astyle
20+
run: sudo apt-get update && sudo apt-get install -y astyle
21+
- name: Run astyle check
2322
run: |
24-
cd astyle/build/gcc/
25-
make
26-
sudo make install
23+
# Run astyle but don't overwrite
2724
astyle --version
25+
if astyle --style=allman \
26+
--indent=spaces=4 \
27+
--indent-col1-comments \
28+
--pad-oper \
29+
--pad-comma \
30+
--pad-header \
31+
--unpad-paren \
32+
--align-pointer=name \
33+
--align-reference=name \
34+
--break-closing-braces \
35+
--add-braces \
36+
--attach-return-type \
37+
--attach-return-type-decl \
38+
--convert-tabs \
39+
--indent-cases \
40+
--indent-namespaces \
41+
--indent-preproc-define \
42+
--recursive \
43+
--dry-run \
44+
"*.cpp" "*.h" "*.ino" | grep -q "Formatted"; then
45+
echo "::error::Indentation check failed"
46+
astyle --style=allman \
47+
--indent=spaces=4 \
48+
--indent-col1-comments \
49+
--pad-oper \
50+
--pad-comma \
51+
--pad-header \
52+
--unpad-paren \
53+
--align-pointer=name \
54+
--align-reference=name \
55+
--break-closing-braces \
56+
--add-braces \
57+
--attach-return-type \
58+
--attach-return-type-decl \
59+
--convert-tabs \
60+
--indent-cases \
61+
--indent-namespaces \
62+
--indent-preproc-define \
63+
--recursive \
64+
--dry-run \
65+
--formatted \
66+
"*.cpp" "*.h" "*.ino"
67+
exit 1
68+
else
69+
echo "Indentation check passed"
70+
fi

0 commit comments

Comments
 (0)