-
Notifications
You must be signed in to change notification settings - Fork 3
229 lines (199 loc) · 7.18 KB
/
ci.yml
File metadata and controls
229 lines (199 loc) · 7.18 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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
# FPBInject CI/CD Pipeline
#
# This workflow runs comprehensive tests for both lower machine (embedded firmware)
# and upper machine (WebServer) components.
name: FPBInject CI
on:
push:
branches: [main, master, develop]
paths:
- "Source/**"
- "App/**"
- "Tools/**"
- "cmake/**"
- "CMakeLists.txt"
- ".github/workflows/ci.yml"
pull_request:
branches: [main, master, develop]
paths:
- "Source/**"
- "App/**"
- "Tools/**"
- "cmake/**"
- "CMakeLists.txt"
- ".github/workflows/ci.yml"
jobs:
# ============================================================
# Lower Machine Tests (Embedded Firmware)
# ============================================================
lower-machine:
name: Lower Machine Tests
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install dependencies
run: |
Tools/install-prerequisites.sh
sudo apt-get install -y clang-format-14 shfmt
sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-14 100
pip install cmake-format kconfiglib
- name: CMake format check
working-directory: .
run: |
echo "🔍 Checking CMake file format..."
chmod +x Tools/cmake_format.sh
Tools/cmake_format.sh --check
echo "✅ CMake format check completed!"
- name: Kconfig lint check
working-directory: .
run: |
echo "🔍 Checking Kconfig syntax..."
python3 Tools/kconfig_lint.py $(find . -name 'Kconfig*')
echo "✅ Kconfig lint check completed!"
- name: Check C/C++ code format
working-directory: .
run: |
echo "🔍 Checking C/C++ code format..."
chmod +x Tools/code_format.sh
Tools/code_format.sh --check
# Check if there are any formatting differences
if ! git diff --quiet; then
echo "❌ Code formatting check failed!"
echo "The following files need formatting:"
git diff --name-only
echo ""
echo "Please run 'Tools/code_format.sh' locally and commit the changes."
exit 1
fi
echo "✅ Code format check passed!"
- name: Build test (all configurations)
working-directory: .
run: |
echo "🔨 Running build tests..."
chmod +x Tools/build_test.sh
Tools/build_test.sh
echo "✅ Build tests passed!"
- name: Run firmware unit tests with coverage
working-directory: App/tests
run: |
echo "🧪 Running firmware unit tests..."
sudo apt-get install -y lcov bc
chmod +x run_tests.sh
./run_tests.sh coverage --threshold 80
echo "✅ Firmware unit tests passed with 80%+ coverage!"
- name: Upload firmware coverage report
uses: actions/upload-artifact@v4
if: always()
with:
name: firmware-coverage-report
path: App/tests/build/coverage/
retention-days: 7
# ============================================================
# Upper Machine Tests (WebServer)
# ============================================================
upper-machine:
name: Upper Machine Tests
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: "pip"
cache-dependency-path: "Tools/requirements.txt"
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
- name: Install ARM toolchain (for ELF symbol tests)
run: |
sudo apt-get update
sudo apt-get install -y gcc-arm-none-eabi gdb-multiarch
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install -r Tools/requirements.txt
pip install -r Tools/WebServer/tests/requirements.txt
# mcp is optional (only needed by fpb_mcp_server.py), not in requirements.txt
pip install mcp
# Install additional tools for formatting and linting
pip install black flake8
- name: Check Python/JS code format and lint
working-directory: Tools/WebServer
run: |
echo "🔍 Checking Python/JavaScript code format and lint..."
chmod +x format.sh
./format.sh --check --lint
# Check if there are any formatting differences
if ! git diff --quiet; then
echo "❌ Code formatting check failed!"
echo "The following files need formatting:"
git diff --name-only
echo ""
echo "Please run 'Tools/WebServer/format.sh' locally and commit the changes."
exit 1
fi
echo "✅ Code format check passed!"
- name: Run backend tests
working-directory: Tools/WebServer
run: |
echo "🧪 Running backend Python tests..."
python tests/run_tests.py --coverage --html --target 85
echo "✅ Backend tests passed!"
- name: Install Node.js dependencies
working-directory: Tools/WebServer
run: |
echo "📦 Installing Node.js dependencies..."
npm install
echo "✅ Node.js dependencies installed!"
- name: Run frontend tests
working-directory: Tools/WebServer
run: |
echo "🧪 Running frontend JavaScript tests with coverage..."
node tests/test_frontend.js --coverage --ci --threshold 80
echo "✅ Frontend tests passed!"
- name: Upload coverage report
uses: actions/upload-artifact@v4
if: always()
with:
name: coverage-report
path: |
Tools/WebServer/tests/htmlcov/
Tools/WebServer/tests/coverage/
retention-days: 7
# ============================================================
# Summary Job
# ============================================================
ci-summary:
name: CI Summary
runs-on: ubuntu-latest
needs: [lower-machine, upper-machine]
if: always()
steps:
- name: Check job results
run: |
echo "========================================="
echo " FPBInject CI Summary"
echo "========================================="
echo ""
if [ "${{ needs.lower-machine.result }}" == "success" ]; then
echo "✅ Lower Machine Tests: PASSED"
else
echo "❌ Lower Machine Tests: FAILED"
fi
if [ "${{ needs.upper-machine.result }}" == "success" ]; then
echo "✅ Upper Machine Tests: PASSED"
else
echo "❌ Upper Machine Tests: FAILED"
fi
echo ""
if [ "${{ needs.lower-machine.result }}" == "success" ] && [ "${{ needs.upper-machine.result }}" == "success" ]; then
echo "🎉 All CI checks passed!"
exit 0
else
echo "💥 Some CI checks failed!"
exit 1
fi