-
-
Notifications
You must be signed in to change notification settings - Fork 1
288 lines (248 loc) · 8.31 KB
/
ci.yml
File metadata and controls
288 lines (248 loc) · 8.31 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
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
name: CI
on:
push:
branches: [main, develop]
pull_request:
branches: [main]
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
jobs:
check:
name: Check Compilation
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v4
- name: Install Rust nightly
uses: dtolnay/rust-toolchain@nightly
with:
components: rust-src
- name: Cache cargo (using Swatinem/rust-cache)
uses: Swatinem/rust-cache@v2
with:
workspaces: sensors/blackbox
cache-on-failure: true
- name: Cache cargo tools
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/espup
~/.cargo/bin/ldproxy
key: ${{ runner.os }}-cargo-tools-v1
restore-keys: |
${{ runner.os }}-cargo-tools-
- name: Cache ESP-IDF
uses: actions/cache@v4
with:
path: |
~/.espup/
~/export-esp.sh
key: ${{ runner.os }}-espup-v2-partition-fix
restore-keys: |
${{ runner.os }}-espup-v2-
- name: Install ESP-IDF prerequisites
run: |
sudo apt-get update
sudo apt-get install -y git wget flex bison gperf python3 python3-pip python3-venv cmake ninja-build ccache libffi-dev libssl-dev dfu-util libusb-1.0-0
- name: Install tools from cache or compile
run: |
if ! command -v espup &> /dev/null; then
echo "Installing espup..."
cargo install espup
else
echo "✓ espup found in cache"
fi
if ! command -v ldproxy &> /dev/null; then
echo "Installing ldproxy..."
cargo install ldproxy
else
echo "✓ ldproxy found in cache"
fi
- name: Install ESP-IDF
run: |
if [ ! -f ~/export-esp.sh ]; then
echo "Installing ESP-IDF..."
espup install
else
echo "✓ ESP-IDF found in cache"
fi
. $HOME/export-esp.sh
- name: Check compilation
run: |
. $HOME/export-esp.sh
cd sensors/blackbox
cargo check
fmt:
name: Format Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- name: Check formatting
run: cargo fmt --all -- --check
clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust nightly
uses: dtolnay/rust-toolchain@nightly
with:
components: rust-src, clippy
- name: Cache cargo (using Swatinem/rust-cache)
uses: Swatinem/rust-cache@v2
with:
workspaces: sensors/blackbox
cache-on-failure: true
- name: Run clippy
run: |
cd sensors/blackbox
cargo clippy -- -D warnings
build:
name: Build Firmware
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v4
- name: Install Rust nightly
uses: dtolnay/rust-toolchain@nightly
with:
components: rust-src
- name: Cache cargo (using Swatinem/rust-cache)
uses: Swatinem/rust-cache@v2
with:
workspaces: sensors/blackbox
cache-on-failure: true
shared-key: partition-fix-v2
- name: Cache cargo tools
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/espup
~/.cargo/bin/ldproxy
~/.cargo/bin/cargo-espflash
~/.cargo/bin/espflash
key: ${{ runner.os }}-cargo-tools-v1
restore-keys: |
${{ runner.os }}-cargo-tools-
- name: Cache ESP-IDF
uses: actions/cache@v4
with:
path: |
~/.espup/
~/export-esp.sh
key: ${{ runner.os }}-espup-v2-partition-fix
restore-keys: |
${{ runner.os }}-espup-v2-
- name: Install ESP-IDF prerequisites
run: |
sudo apt-get update
sudo apt-get install -y git wget flex bison gperf python3 python3-pip python3-venv cmake ninja-build ccache libffi-dev libssl-dev dfu-util libusb-1.0-0
- name: Install tools from cache or compile
run: |
# Check if tools are already in cache
if ! command -v espup &> /dev/null; then
echo "Installing espup..."
cargo install espup
else
echo "✓ espup found in cache"
fi
if ! command -v ldproxy &> /dev/null; then
echo "Installing ldproxy..."
cargo install ldproxy
else
echo "✓ ldproxy found in cache"
fi
if ! command -v cargo-espflash &> /dev/null; then
echo "Installing cargo-espflash and espflash..."
cargo install cargo-espflash espflash
else
echo "✓ cargo-espflash found in cache"
fi
- name: Install ESP-IDF
run: |
if [ ! -f ~/export-esp.sh ]; then
echo "Installing ESP-IDF..."
espup install
else
echo "✓ ESP-IDF found in cache"
fi
. $HOME/export-esp.sh
- name: Clean build to force partition table update
run: |
cd sensors/blackbox
rm -rf ../../target/riscv32imc-esp-espidf
rm -rf ../../.embuild
echo "✓ Cleaned ESP-IDF build cache (.embuild and target)"
- name: Build firmware
run: |
. $HOME/export-esp.sh
cd sensors/blackbox
cargo build --release
echo "Built binary size:"
ls -lh ../../target/riscv32imc-esp-espidf/release/blackbox
echo "Checking generated partition configuration:"
grep "CONFIG_PARTITION_TABLE" ../../target/riscv32imc-esp-espidf/release/build/esp-idf-sys-*/out/sdkconfig | head -10
echo "Partition table binary:"
ls -lh ../../target/riscv32imc-esp-espidf/release/partition-table.bin
python3 -c "import sys; data = open('../../target/riscv32imc-esp-espidf/release/partition-table.bin', 'rb').read(); print(f'Partition table size: {len(data)} bytes')"
- name: Create merged binary for web flasher
run: |
cd sensors/blackbox
cargo espflash save-image \
--chip esp32c3 \
--merge \
--release \
../../target/blackbox.bin
ls -lh ../../target/blackbox.bin
- name: Upload merged firmware
uses: actions/upload-artifact@v4
with:
name: firmware-esp32c3
path: target/blackbox.bin
- name: Upload individual components (debug)
uses: actions/upload-artifact@v4
with:
name: firmware-components
path: |
target/riscv32imc-esp-espidf/release/blackbox
target/riscv32imc-esp-espidf/release/bootloader.bin
target/riscv32imc-esp-espidf/release/partition-table.bin
python-lint:
name: Python Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check if Python files exist
id: check_files
run: |
if ls *.py 1> /dev/null 2>&1; then
echo "files_exist=true" >> $GITHUB_OUTPUT
else
echo "files_exist=false" >> $GITHUB_OUTPUT
echo "⚠️ No Python files found in root - skipping lint"
fi
- name: Set up Python
if: steps.check_files.outputs.files_exist == 'true'
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Install dependencies
if: steps.check_files.outputs.files_exist == 'true'
run: |
python -m pip install --upgrade pip
pip install flake8 black paho-mqtt
- name: Lint with flake8
if: steps.check_files.outputs.files_exist == 'true'
run: |
flake8 *.py --count --select=E9,F63,F7,F82 --show-source --statistics
flake8 *.py --count --exit-zero --max-complexity=10 --max-line-length=100 --statistics
- name: Check formatting with black
if: steps.check_files.outputs.files_exist == 'true'
run: black --check *.py