-
-
Notifications
You must be signed in to change notification settings - Fork 12
472 lines (409 loc) · 15.8 KB
/
ci.yml
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
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
name: PlatformIO CI
on:
pull_request:
branches:
- master
- develop
paths-ignore:
- "**/*.md"
push:
branches:
- master
- develop
paths-ignore:
- "**/*.md"
jobs:
build-bhaptics:
name: Build ${{ matrix.target }} ${{ matrix.coverage && 'with coverage' || 'without coverage' }}, -D ${{ matrix.battery_flag }} -D ${{ matrix.serial_plotter_flag }} -D ${{ matrix.nimble_flag }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest ]
target:
- bhaptics_tactsuit_x16
- bhaptics_tactsuit_x16_pca9685
- bhaptics_tactsuit_x40
- bhaptics_tactosy2_forearm_right
- bhaptics_tactosyh_hand_right
- bhaptics_tactosyf_foot_right
- bhaptics_tactal
- bhaptics_tactvisor
- bhaptics_tactglove_right
battery_flag: [ SENSESHIFT_BATTERY_ENABLED=true ]
serial_plotter_flag: [ SENSESHIFT_SERIAL_PLOTTER=false ]
nimble_flag: [ SENSESHIFT_BLE_USE_NIMBLE=false ]
coverage: [ false ]
include:
# Extra tests for x40, as it uses the most features
- target: bhaptics_tactsuit_x40
os: ubuntu-latest
coverage: true
battery_flag: SENSESHIFT_BATTERY_ENABLED=true
serial_plotter_flag: SENSESHIFT_SERIAL_PLOTTER=true
nimble_flag: SENSESHIFT_BLE_USE_NIMBLE=true
# - target: bhaptics_tactsuit_x40
# os: ubuntu-latest
# coverage: true
# battery_flag: SENSESHIFT_BATTERY_ENABLED=true
# serial_plotter_flag: SENSESHIFT_SERIAL_PLOTTER=true
# nimble_flag: SENSESHIFT_BLE_USE_NIMBLE=false
- target: bhaptics_tactsuit_x40
os: ubuntu-latest
coverage: false
battery_flag: SENSESHIFT_BATTERY_ENABLED=true
serial_plotter_flag: SENSESHIFT_SERIAL_PLOTTER=false
nimble_flag: SENSESHIFT_BLE_USE_NIMBLE=true
steps:
- uses: actions/checkout@v3
with:
submodules: "recursive"
- name: Get firmware name
id: firmware_name
run: |
./.github/scripts/get_firmware_name.sh ${{ matrix.target }} ${{ matrix.serial_plotter_flag }} ${{ matrix.battery_flag }} ${{ matrix.nimble_flag }}
- name: Enable coverage (non-macOS)
if: runner.os != 'macOS' && matrix.coverage
run: |
sed -i '/__OH_FIRMWARE__/p; s/-D __OH_FIRMWARE__/-lgcov --coverage/' platformio.ini
- name: Enable coverage (macOS)
if: runner.os == 'macOS' && matrix.coverage
run: |
sed -i '' '/__OH_FIRMWARE__/p; s/-D __OH_FIRMWARE__/-lgcov --coverage/' platformio.ini
- name: Update build flags (non-macOS)
if: runner.os != 'macOS'
run: |
sed -i '/__OH_FIRMWARE__/p; s/__OH_FIRMWARE__/${{ matrix.battery_flag }}/' platformio.ini
sed -i '/__OH_FIRMWARE__/p; s/__OH_FIRMWARE__/${{ matrix.serial_plotter_flag }}/' platformio.ini
sed -i '/__OH_FIRMWARE__/p; s/__OH_FIRMWARE__/${{ matrix.nimble_flag }}/' platformio.ini
- name: Update build flags (macOS)
if: runner.os == 'macOS'
run: |
sed -i '' '/__OH_FIRMWARE__/p; s/__OH_FIRMWARE__/${{ matrix.battery_flag }}/' platformio.ini
sed -i '' '/__OH_FIRMWARE__/p; s/__OH_FIRMWARE__/${{ matrix.serial_plotter_flag }}/' platformio.ini
sed -i '' '/__OH_FIRMWARE__/p; s/__OH_FIRMWARE__/${{ matrix.nimble_flag }}/' platformio.ini
- name: Speedup package installation
if: matrix.coverage
uses: abbbi/github-actions-tune@v1
- name: Setup LCOV
if: matrix.coverage
uses: hrishikesh-kadam/setup-lcov@v1
- name: Cache pip
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Cache PlatformIO
uses: actions/cache@v3
with:
path: |
~/.platformio/.cache
./.pio
key: ${{ runner.os }}-pio-${{ matrix.target }}-${{ hashFiles('**/*.ini') }}
restore-keys: |
${{ runner.os }}-pio-${{ matrix.target }}-
${{ runner.os }}-pio-
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.9"
- name: Install PlatformIO
run: |
python -m pip install --upgrade pip
pip install --upgrade platformio
pio upgrade --dev
pio pkg update --global
- name: Install libs
run: pio pkg install -e ${{matrix.target}}
- name: Change memory segments
if: matrix.coverage
run: |
sed -i "s/len\s=\s0x2c200\s-\s0xdb5c/len = 2898880/" ~/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/ld/memory.ld
sed -i "/\[env\]/p; s/\[env\]/board_build.partitions = huge_app.csv/" platformio.ini
- name: Build
run: |
echo "::group::platformio.ini"
cat platformio.ini
echo "::endgroup::"
pio run --environment ${{matrix.target}}
- name: Collect initial coverage
if: matrix.coverage
run: |
mkdir -p ./build/lcov
lcov -i -d ./.pio/build/${{matrix.target}}/ -c -o ./build/lcov/lcov.info.${{ steps.firmware_name.outputs.firmware }} -gcov-tool ~/.platformio/packages/toolchain-xtensa-esp32/bin/xtensa-esp32-elf-gcov
- name: Upload coverage Artifact
uses: actions/upload-artifact@v3
if: matrix.coverage
with:
name: lcov.info.${{ steps.firmware_name.outputs.firmware }}
path: ./build/lcov/lcov.info.${{ steps.firmware_name.outputs.firmware }}
retention-days: 1
build-opengloves:
name: Build ${{ matrix.target }} ${{ matrix.coverage && 'with coverage' || 'without coverage' }}, -D ${{ matrix.comm_flag }} -D ${{ matrix.curl_calibration_flag }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest ]
target:
- lucidgloves-prototype3
- lucidgloves-prototype4
- indexer-c
- indexer-cf
- indexer-cs
- indexer-csf
comm_flag:
- COMMUNICATION_PROTOCOL=OPENGLOVES_COMM_SERIAL
- COMMUNICATION_PROTOCOL=OPENGLOVES_COMM_BTSERIAL
coverage: [ false ]
include:
- os: ubuntu-latest
target: lucidgloves-prototype4-ffb
curl_calibration_flag: CALIBRATION_CURL="new ::SenseShift::Input::Calibration::MinMaxCalibrator<float>()"
coverage: true
- os: ubuntu-latest
target: lucidgloves-prototype4-ffb
curl_calibration_flag: CALIBRATION_CURL="new ::SenseShift::Input::Calibration::CenterPointDeviationCalibrator<float>(0.66F, 0.005F)"
coverage: true
- os: ubuntu-latest
target: lucidgloves-prototype4-ffb
curl_calibration_flag: CALIBRATION_CURL="new ::SenseShift::Input::Calibration::FixedCenterPointDeviationCalibrator<float>(0.66F, 0.005F)"
coverage: true
- os: ubuntu-latest
target: indexer-csf
comm_flag: COMMUNICATION_PROTOCOL=OPENGLOVES_COMM_BTSERIAL
coverage: true
- os: ubuntu-latest
target: indexer-csf
comm_flag: COMMUNICATION_PROTOCOL=OPENGLOVES_COMM_BLESERIAL
coverage: true
steps:
- uses: actions/checkout@v3
with:
submodules: "recursive"
- name: Get firmware name
id: firmware_name
run: |
./.github/scripts/get_firmware_name.sh ${{ matrix.target }} ${{ matrix.comm_flag }} ${{ matrix.curl_calibration_flag }}
- name: Speedup package installation
if: matrix.coverage
uses: abbbi/github-actions-tune@v1
- name: Setup LCOV
if: matrix.coverage
uses: hrishikesh-kadam/setup-lcov@v1
- name: Cache pip
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Cache PlatformIO
uses: actions/cache@v3
with:
path: |
~/.platformio/.cache
./.pio
key: ${{ runner.os }}-pio-${{ matrix.target }}-${{ hashFiles('platformio.ini') }}
restore-keys: |
${{ runner.os }}-pio-${{ matrix.target }}-
${{ runner.os }}-pio-
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.9"
- name: Enable coverage (non-macOS)
if: runner.os != 'macOS' && matrix.coverage
run: |
sed -i '/__OH_FIRMWARE__/p; s/-D __OH_FIRMWARE__/-lgcov --coverage/' platformio.ini
- name: Enable coverage (macOS)
if: runner.os == 'macOS' && matrix.coverage
run: |
sed -i '' '/__OH_FIRMWARE__/p; s/-D __OH_FIRMWARE__/-lgcov --coverage/' platformio.ini
- name: Update build flags (non-macOS)
if: runner.os != 'macOS'
run: |
sed -i '/__OH_FIRMWARE__/p; s/__OH_FIRMWARE__/${{ matrix.curl_calibration_flag }}/' platformio.ini
sed -i '/__OH_FIRMWARE__/p; s/__OH_FIRMWARE__/${{ matrix.comm_flag }}/' platformio.ini
- name: Update build flags (macOS)
if: runner.os == 'macOS'
run: |
sed -i '' '/__OH_FIRMWARE__/p; s/__OH_FIRMWARE__/${{ matrix.curl_calibration_flag }}/' platformio.ini
sed -i '' '/__OH_FIRMWARE__/p; s/__OH_FIRMWARE__/${{ matrix.comm_flag }}/' platformio.ini
- name: Install PlatformIO
run: |
python -m pip install --upgrade pip
pip install --upgrade platformio
pio upgrade --dev
pio pkg update --global
- name: Install libs
run: pio pkg install -e ${{matrix.target}}
- name: Change memory segments
if: matrix.coverage
run: |
sed -i "s/len\s=\s0x2c200\s-\s0xdb5c/len = 2898880/" ~/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/ld/memory.ld
sed -i "/\[env\]/p; s/\[env\]/board_build.partitions = huge_app.csv/" platformio.ini
- name: Build
if: matrix.coverage == false
run: |
echo "::group::platformio.ini"
cat platformio.ini
echo "::endgroup::"
pio run --environment ${{matrix.target}}
- name: Build (debug)
if: matrix.coverage
run: |
echo "::group::platformio.ini"
cat platformio.ini
echo "::endgroup::"
pio debug --environment ${{matrix.target}}
- name: Upload firmware Artifact
if: matrix.coverage == false
uses: actions/upload-artifact@v3
with:
name: ${{ steps.firmware_name.outputs.firmware }}
path: |
./.pio/build/${{matrix.target}}/firmware.bin
./.pio/build/${{matrix.target}}/firmware.elf
retention-days: 1
if-no-files-found: error
- name: Collect initial coverage
if: matrix.coverage
run: |
mkdir -p ./build/lcov
lcov -i -d ./.pio/build/${{matrix.target}}/ -c -o ./build/lcov/lcov.info.${{ steps.firmware_name.outputs.firmware }} -gcov-tool ~/.platformio/packages/toolchain-xtensa-esp32/bin/xtensa-esp32-elf-gcov
- name: Upload coverage Artifact
uses: actions/upload-artifact@v3
if: matrix.coverage
with:
name: lcov.info.${{ steps.firmware_name.outputs.firmware }}
path: ./build/lcov/lcov.info.${{ steps.firmware_name.outputs.firmware }}
retention-days: 1
if-no-files-found: error
test:
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
target:
- native
steps:
- uses: actions/checkout@v3
with:
submodules: "recursive"
- name: Speedup package installation
uses: abbbi/github-actions-tune@v1
- name: Setup LCOV
uses: hrishikesh-kadam/setup-lcov@v1
- name: Cache pip
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Cache PlatformIO
uses: actions/cache@v3
with:
path: |
~/.platformio/.cache
./.pio
key: ${{ runner.os }}-pio-${{ matrix.target }}-${{ hashFiles('platformio.ini') }}
restore-keys: |
${{ runner.os }}-pio-${{ matrix.target }}
${{ runner.os }}-pio-
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.9"
- name: Install PlatformIO
run: |
python -m pip install --upgrade pip
pip install --upgrade platformio
pio upgrade --dev
pio pkg update --global
- name: Install libs
run: pio pkg install -e ${{matrix.target}}
- name: Run Unit Tests
run: pio test -e ${{matrix.target}}
- name: Collect coverage report
run: |
mkdir -p ./build/lcov
lcov -d ./.pio/build/${{matrix.target}}/ -c -o ./build/lcov/lcov.info.${{matrix.target}}.test
- name: Upload coverage Artifact
uses: actions/upload-artifact@v3
with:
name: lcov.info.${{matrix.target}}.test
path: ./build/lcov/lcov.info.${{matrix.target}}.test
retention-days: 5
coverage-report:
needs:
- build-bhaptics
- build-opengloves
- test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Speedup package installation
uses: abbbi/github-actions-tune@v1
- name: Setup LCOV
uses: hrishikesh-kadam/setup-lcov@v1
- name: Download all workflow run artifacts
id: download
uses: actions/download-artifact@v3
with:
path: build/artifacts
- name: Merge lcov files
run: |
mkdir ./build/lcov/
find ./build/artifacts -mindepth 2 -type f -exec mv '{}' ./build/lcov/ \;
ls -lahR ./build/lcov/
find ./build/lcov -name 'lcov.info.*' -exec echo -a {} \; | xargs lcov -o ./build/lcov/lcov.info
lcov --remove ./build/lcov/lcov.info '/usr/include/*' '*.platformio/*' '*/.pio/*' '*/tool-unity/*' '*/test/*' '*/MockArduino/*' '*/lib/frozen/*' -o ./build/lcov/lcov.info.cleaned
- name: Generate HTML report
run: genhtml -p $PWD -o ./build/coverage/ --demangle-cpp ./build/lcov/lcov.info.cleaned
- name: Upload coverage Artifact
uses: actions/upload-artifact@v3
with:
name: coverage-report
path: |
./build/coverage/
retention-days: 5
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
files: ./build/lcov/lcov.info.cleaned
flags: unittests
wokwi:
needs:
- build-bhaptics
- build-opengloves
- test
runs-on: ubuntu-latest
strategy:
matrix:
variant:
- lucidgloves-prototype3+serial
- lucidgloves-prototype4+serial
steps:
- uses: actions/checkout@v3
- name: Extract target
id: target_name
run: |
target=$(echo ${{ matrix.variant }} | cut -d'+' -f1)
echo "target=$target" >> $GITHUB_OUTPUT
- name: Download firmware artifact
uses: actions/download-artifact@v3
with:
name: ${{ matrix.variant }}
path: ./.pio/build/${{ steps.target_name.outputs.target }}
- name: Run Wokwi scenario
uses: wokwi/wokwi-ci-action@v1
with:
token: ${{ secrets.WOKWI_CLI_TOKEN }}
path: ./.wokwi/${{ matrix.variant }}
scenario: "test.yaml"