-
Notifications
You must be signed in to change notification settings - Fork 0
133 lines (117 loc) · 3.72 KB
/
code-quality.yml
File metadata and controls
133 lines (117 loc) · 3.72 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
name: Code Quality
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
quality:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
submodules: recursive
- name: Install Analysis Tools
run: |
sudo apt-get update -qq
sudo apt-get install -y -qq cppcheck clang-format
- name: Run Cppcheck
run: |
echo "Running cppcheck static analysis..."
SRC_DIRS=()
for d in core imgproc board device wrapper; do
[ -d "$d" ] && SRC_DIRS+=("$d")
done
if [ ${#SRC_DIRS[@]} -eq 0 ]; then
echo "No source directories found for cppcheck"
exit 1
fi
INCLUDE_ARGS=()
for d in "${SRC_DIRS[@]}"; do
INCLUDE_ARGS+=("-I" "$d")
done
cppcheck \
--enable=warning,performance,portability \
--error-exitcode=1 \
--inline-suppr \
--suppress=missingIncludeSystem \
--suppress=unusedFunction \
--suppress=unmatchedSuppression \
--std=c11 \
--force \
"${INCLUDE_ARGS[@]}" \
"${SRC_DIRS[@]}" \
--xml \
2> cppcheck-report.xml
- name: Run Cppcheck Style Report
continue-on-error: true
run: |
echo "Running cppcheck style analysis (non-blocking)..."
SRC_DIRS=()
for d in core imgproc board device wrapper; do
[ -d "$d" ] && SRC_DIRS+=("$d")
done
if [ ${#SRC_DIRS[@]} -eq 0 ]; then
echo "No source directories found for cppcheck style scan"
exit 0
fi
INCLUDE_ARGS=()
for d in "${SRC_DIRS[@]}"; do
INCLUDE_ARGS+=("-I" "$d")
done
cppcheck \
--enable=style \
--inline-suppr \
--suppress=missingIncludeSystem \
--suppress=unusedFunction \
--suppress=unmatchedSuppression \
--std=c11 \
--force \
"${INCLUDE_ARGS[@]}" \
"${SRC_DIRS[@]}" \
--xml \
2> cppcheck-style-report.xml || true
- name: Check Code Formatting
run: |
echo "Checking code formatting..."
if [ ! -f .clang-format ]; then
cat > .clang-format << 'FMT'
---
BasedOnStyle: LLVM
IndentWidth: 4
ColumnLimit: 100
PointerAlignment: Left
AllowShortIfStatementsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Empty
IndentCaseLabels: true
BreakBeforeBraces: Allman
FMT
fi
# Fail if any file is not properly formatted
SRC_DIRS=()
for d in core imgproc board device wrapper; do
[ -d "$d" ] && SRC_DIRS+=("$d")
done
if [ ${#SRC_DIRS[@]} -eq 0 ]; then
echo "No source directories found for format check"
exit 1
fi
find "${SRC_DIRS[@]}" \( -name "*.c" -o -name "*.cpp" -o -name "*.h" -o -name "*.hpp" \) \
-print0 | xargs -0 clang-format --dry-run --Werror
- name: Upload Cppcheck Report
if: always()
uses: actions/upload-artifact@v4
with:
name: cppcheck-report
path: cppcheck-report.xml
retention-days: 30
if-no-files-found: warn
- name: Upload Cppcheck Style Report
if: always()
uses: actions/upload-artifact@v4
with:
name: cppcheck-style-report
path: cppcheck-style-report.xml
retention-days: 30
if-no-files-found: warn