-
Notifications
You must be signed in to change notification settings - Fork 0
92 lines (76 loc) · 2.36 KB
/
code-quality.yml
File metadata and controls
92 lines (76 loc) · 2.36 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
name: Code Quality
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]
jobs:
format-check:
runs-on: ubuntu-latest
name: Check Code Formatting
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install clang-format
run: |
sudo apt-get update
sudo apt-get install -y clang-format
- name: Check formatting
run: |
find src/ -name "*.cpp" -o -name "*.h" -o -name "*.ino" | \
xargs clang-format --dry-run --Werror --style=file
format-fix:
runs-on: ubuntu-latest
name: Auto-fix Formatting
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Install clang-format
run: |
sudo apt-get update
sudo apt-get install -y clang-format
- name: Format code
run: |
find src/ -name "*.cpp" -o -name "*.h" -o -name "*.ino" | \
xargs clang-format -i --style=file
- name: Check for changes
id: verify-changed-files
run: |
if [ -n "$(git status --porcelain)" ]; then
echo "changed=true" >> $GITHUB_OUTPUT
else
echo "changed=false" >> $GITHUB_OUTPUT
fi
- name: Commit formatted code
if: steps.verify-changed-files.outputs.changed == 'true'
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add .
git commit -m "Auto-format code with clang-format [skip ci]"
git push
lint:
runs-on: ubuntu-latest
name: Static Analysis
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install cppcheck
run: |
sudo apt-get update
sudo apt-get install -y cppcheck
- name: Run cppcheck
run: |
cppcheck --enable=all --inconclusive --xml --xml-version=2 \
--suppress=missingIncludeSystem \
--suppress=unusedFunction \
--suppress=unmatchedSuppression \
src/ 2> cppcheck-report.xml || true
- name: Upload cppcheck results
uses: actions/upload-artifact@v3
with:
name: cppcheck-report
path: cppcheck-report.xml