Repository navigation
1131 lines (1015 loc) · 45.4 KB
/
Copy pathci.yml
File metadata and controls
1131 lines (1015 loc) · 45.4 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
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
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
name: CI
on:
push:
branches: ['**']
tags: ['**']
pull_request:
branches: [develop]
workflow_dispatch:
permissions:
contents: read
concurrency:
group: ci-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
# Preserve publication sources; dispatched snapshots recheck whether the commit is current.
cancel-in-progress: ${{ github.event_name != 'push' || (github.ref_type != 'tag' && github.ref != 'refs/heads/main' && github.ref != 'refs/heads/develop') }}
jobs:
# Run preparation and the host-side checks as one parallel stage.
prepare:
name: Prepare Build
runs-on: ubuntu-24.04
timeout-minutes: 10
outputs:
publication: ${{ steps.metadata.outputs.publication }}
version: ${{ steps.metadata.outputs.version }}
channel: ${{ steps.metadata.outputs.channel }}
release_tag: ${{ steps.metadata.outputs.release_tag }}
artifact_suffix: ${{ steps.metadata.outputs.artifact_suffix }}
ota_channel: ${{ steps.metadata.outputs.ota_channel }}
sign: ${{ steps.metadata.outputs.sign }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
persist-credentials: false
fetch-depth: 0
- name: Select publication and validate release metadata
id: metadata
env:
GH_TOKEN: ${{ github.event_name == 'push' && github.ref_type == 'tag' && github.token || '' }}
PUSH_DELETED: ${{ github.event.deleted || false }}
run: |
publication=none
version="$(python3 .github/scripts/detect_git_version.py)"
channel=preview
release_tag=ci
artifact_suffix=ci
ota_channel=release
sign=false
if [[ "$GITHUB_EVENT_NAME" == push && "$PUSH_DELETED" != true ]]; then
if [[ "$GITHUB_REF_TYPE" == tag && "$GITHUB_REF_NAME" =~ ^[0-9]+\.[0-9]+\.[0-9]+($|-) ]]; then
git -c 'credential.helper=!gh auth git-credential' fetch --no-tags origin main
git merge-base --is-ancestor "$GITHUB_SHA" origin/main \
|| { echo "Release commit is not reachable from main." >&2; exit 1; }
python3 .github/scripts/validate_release.py --tag "$GITHUB_REF_NAME"
publication=release
version="$GITHUB_REF_NAME"
channel=release
release_tag="$GITHUB_REF_NAME"
artifact_suffix="$GITHUB_REF_NAME"
sign=true
elif [[ "$GITHUB_REF" == refs/heads/main || "$GITHUB_REF" == refs/heads/develop ]]; then
publication=snapshot
channel=preview
release_tag=snapshot
if [[ "$GITHUB_REF" == refs/heads/develop ]]; then
channel=develop
release_tag=snapshot-dev
fi
artifact_suffix="$channel"
ota_channel="$channel"
sign=true
fi
fi
{
echo "publication=$publication"
echo "version=$version"
echo "channel=$channel"
echo "release_tag=$release_tag"
echo "artifact_suffix=$artifact_suffix"
echo "ota_channel=$ota_channel"
echo "sign=$sign"
} >> "$GITHUB_OUTPUT"
test-site:
name: Website Unit Tests
runs-on: ubuntu-24.04
timeout-minutes: 20
permissions:
contents: read
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
persist-credentials: false
fetch-depth: 0
- name: Verify committed website asset hashes
run: python3 .github/scripts/web_asset_versions.py --check-current
- name: Set up Node.js
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: '22'
cache: npm
cache-dependency-path: docs/web/package-lock.json
- name: Audit website dependencies
run: npm --prefix docs/web audit --package-lock-only --include=dev --audit-level=low
- name: Build and verify Pages tree
uses: ./.github/actions/build-pages
env:
WEB_COVERAGE_LOG: .cache/reports/coverage/web-coverage.log
- name: Build web coverage badge
if: always() && hashFiles('.cache/reports/coverage/web-coverage.log') != ''
run: |
python .github/scripts/build_coverage_badges.py \
--kind web \
--report .cache/reports/coverage/web-coverage.log \
--thresholds test/web/coverage-thresholds.json \
--output .cache/reports/coverage/coverage-web.json
- name: Upload web coverage badge
if: always() && hashFiles('.cache/reports/coverage/coverage-web.json') != ''
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7
with:
overwrite: true
include-hidden-files: true
name: web-coverage-badge
path: .cache/reports/coverage/coverage-web.json
retention-days: 14
test-cpp:
name: C++ Unit Tests
runs-on: ubuntu-24.04
timeout-minutes: 30
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
persist-credentials: false
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7
with:
python-version: '3.14'
cache: 'pip'
cache-dependency-path: requirements.txt
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Run Host-side Tests with Coverage
run: |
sudo apt-get update
sudo apt-get install -y libssl-dev
./test/cpp/run_coverage.sh --ci
- name: Build C++ coverage badge
if: always() && hashFiles('.cache/reports/coverage/cpp/coverage-summary.json') != ''
run: |
python .github/scripts/build_coverage_badges.py \
--kind cpp-runtime \
--report .cache/reports/coverage/cpp/coverage-summary.json \
--thresholds test/cpp/coverage-thresholds.json \
--output .cache/reports/coverage/coverage-cpp-runtime.json
- name: Upload C++ coverage badge
if: always() && hashFiles('.cache/reports/coverage/coverage-cpp-runtime.json') != ''
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7
with:
overwrite: true
include-hidden-files: true
name: cpp-coverage-badge
path: .cache/reports/coverage/coverage-cpp-runtime.json
retention-days: 14
test-python:
name: Python Unit Tests
runs-on: ubuntu-24.04
timeout-minutes: 45
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
persist-credentials: false
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7
with:
python-version: '3.14'
cache: 'pip'
cache-dependency-path: requirements.txt
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Restore shared NPZ cache
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
with:
path: .cache/npz
key: ${{ format('npz-cache-v2-{0}-{1}', runner.os, hashFiles('data/dataset_info.json', 'src/python/micro_espectre/runtime_policy.py', 'tools/lib/csi_io.py', 'tools/lib/dataset_metadata.py', 'tools/lib/npz_cache.py', 'tools/lib/performance_report.py', 'tools/train_ml_model.py', 'tools/validate_dataset_quality.py', 'test/python/performance/test_packet_rate_adaptation_regression.py')) }}
restore-keys: |
npz-cache-v2-${{ runner.os }}-
- uses: ./.github/actions/setup-doxygen
- name: Run Product and Performance Tests with Coverage
run: ./test/python/run_coverage.sh
env:
PYTEST_XDIST_AUTO_NUM_WORKERS: '4'
- name: Build Python coverage badge
if: always() && hashFiles('.cache/reports/coverage/python-coverage.json') != ''
run: |
python .github/scripts/build_coverage_badges.py \
--kind python \
--report .cache/reports/coverage/python-coverage.json \
--thresholds test/python/coverage-thresholds.json \
--output .cache/reports/coverage/coverage-python.json
- name: Upload Python coverage badge
if: always() && hashFiles('.cache/reports/coverage/coverage-python.json') != ''
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7
with:
overwrite: true
include-hidden-files: true
name: python-coverage-badge
path: .cache/reports/coverage/coverage-python.json
retention-days: 14
build-esphome:
needs: [prepare, test-site, test-cpp, test-python]
permissions:
contents: read
name: Build ESPHome ${{ matrix.chip }}
runs-on: ubuntu-24.04
timeout-minutes: 90
strategy:
fail-fast: false
matrix:
include:
- chip: ESP32
target: esp32
config: src/cpp/frontend/esphome/examples/espectre-esp32.yaml
- chip: ESP32-S3
target: esp32s3
config: src/cpp/frontend/esphome/examples/espectre-s3.yaml
- chip: ESP32-S2
target: esp32s2
config: src/cpp/frontend/esphome/examples/espectre-s2.yaml
- chip: ESP32-C3
target: esp32c3
config: src/cpp/frontend/esphome/examples/espectre-c3.yaml
- chip: ESP32-C5
target: esp32c5
config: src/cpp/frontend/esphome/examples/espectre-c5.yaml
- chip: ESP32-C6
target: esp32c6
config: src/cpp/frontend/esphome/examples/espectre-c6.yaml
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
persist-credentials: false
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7
with:
python-version: '3.14'
cache: 'pip'
cache-dependency-path: requirements.txt
- name: Install ESPHome
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Compile signed ESPHome firmware
id: esphome-artifacts
env:
ESPECTRE_GIT_VERSION: ${{ needs.prepare.outputs.version }}
FIRMWARE_SIGNING_KEY_RSA: ${{ needs.prepare.outputs.sign == 'true' && secrets.FIRMWARE_SIGNING_KEY_RSA || '' }}
FIRMWARE_SIGNING_KEY_ESP32: ${{ needs.prepare.outputs.sign == 'true' && secrets.FIRMWARE_SIGNING_KEY_ESP32 || '' }}
run: |
TARGET=$(echo "${{ matrix.chip }}" | tr '[:upper:]' '[:lower:]' | tr -d '-')
python .github/scripts/build_signed_firmware.py esphome \
--config "${{ matrix.config }}" --target "$TARGET" \
--version "$ESPECTRE_GIT_VERSION" ${{ needs.prepare.outputs.sign != 'true' && '--test-key' || '' }}
- name: Rename ESPHome firmware
run: |
mkdir -p .cache/firmware
CHIP=$(echo "${{ matrix.chip }}" | tr '[:upper:]' '[:lower:]' | tr -d '-')
PREFIX="espectre-esphome-${{ needs.prepare.outputs.artifact_suffix }}"
cp "${{ steps.esphome-artifacts.outputs.factory_bin }}" ".cache/firmware/${PREFIX}-${CHIP}.bin"
cp "${{ steps.esphome-artifacts.outputs.ota_bin }}" ".cache/firmware/${PREFIX}-${CHIP}-ota.bin"
- name: Compile the S3 LED example for the emulator
if: matrix.target == 'esp32s3'
env:
ESPHOME_BUILD_PATH: ${{ runner.temp }}/ws2812-build
ESPECTRE_GIT_VERSION: ${{ needs.prepare.outputs.version }}
run: |
esphome -s component_source local compile src/cpp/frontend/esphome/examples/espectre-s3-led.yaml
cp "${ESPHOME_BUILD_PATH}/espectre/build/firmware.factory.bin" .cache/firmware/led-example-esp32s3.bin
- name: Upload emulator replay image
if: success() && contains(fromJSON('["esp32c3", "esp32c5", "esp32c6", "esp32s3"]'), matrix.target)
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7
with:
overwrite: true
name: replay-esphome-${{ matrix.target }}
path: |
.cache/firmware/espectre-esphome-${{ needs.prepare.outputs.artifact_suffix }}-${{ matrix.target }}.bin
.cache/firmware/led-example-${{ matrix.target }}.bin
retention-days: 1
- name: Build ESPHome compliance artifacts
env:
ESPECTRE_GIT_VERSION: ${{ needs.prepare.outputs.version }}
run: |
PROJECT_DESCRIPTION="${{ steps.esphome-artifacts.outputs.project_description }}"
test -n "${PROJECT_DESCRIPTION}"
for FIRMWARE in .cache/firmware/espectre-esphome-*.bin; do
python .github/scripts/build_firmware_compliance.py \
--frontend esphome \
--project-description "${PROJECT_DESCRIPTION}" \
--firmware "${FIRMWARE}" \
--output-dir .cache/firmware
done
- name: Stage ESPHome firmware audit input
run: |
mkdir -p .cache/audit-input
for SBOM in .cache/firmware/espectre-esphome-*-sbom.spdx.json; do
case "${SBOM}" in *-ota-sbom.spdx.json) continue ;; esac
cp "${SBOM}" ".cache/audit-input/${{ matrix.chip }}.spdx.json"
done
test -f ".cache/audit-input/${{ matrix.chip }}.spdx.json"
- name: Upload ESPHome firmware audit input
if: success()
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7
with:
overwrite: true
name: audit-firmware-esphome-${{ matrix.chip }}
path: .cache/audit-input/${{ matrix.chip }}.spdx.json
retention-days: 1
- name: Upload ESPHome firmware artifact
if: success() && github.event_name == 'push'
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7
with:
overwrite: true
include-hidden-files: true
name: firmware-esphome-${{ matrix.chip }}
path: .cache/firmware/espectre-esphome-*
retention-days: 7
# An eFuse marker enables timestamped UART replay in ESPHome and Native.
# esp-emu supports the C3, C5, C6, and S3 images in this matrix.
emulator-replay:
# Runs after the audits so it never competes with builds for runners.
# Publication waits only for this job, so it must not run past a failed
# audit; it keeps the default success() condition.
needs: [audit-esphome, audit-native, audit-matter]
permissions:
contents: read
name: Emulator CSI replay ${{ matrix.frontend }}
runs-on: ubuntu-24.04
timeout-minutes: 30
env:
# Bump together with EFUSE_DEFAULT_WORDS in tools/emulator/emulator_csi_replay.py.
ESP_EMU_VERSION: 1.2.0
ESP_EMU_SHA256: 560236344fd69dc8d74bc862c79aea01f7a69ac626ae3f54b1b0946bbce078c1
strategy:
fail-fast: false
matrix:
frontend: [esphome, native]
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7
with:
python-version: '3.14'
cache: 'pip'
cache-dependency-path: requirements.txt
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Install esp-emu
run: |
ARCHIVE="esp-emu-${ESP_EMU_VERSION}-x86_64-unknown-linux-gnu.tar.gz"
curl -fsSL -o "${RUNNER_TEMP}/${ARCHIVE}" \
"https://github.com/espressif/esp-emulator/releases/download/v${ESP_EMU_VERSION}/${ARCHIVE}"
echo "${ESP_EMU_SHA256} ${RUNNER_TEMP}/${ARCHIVE}" | sha256sum -c -
tar -xzf "${RUNNER_TEMP}/${ARCHIVE}" -C "${RUNNER_TEMP}"
echo "ESP_EMU=${RUNNER_TEMP}/esp-emu-${ESP_EMU_VERSION}-x86_64-unknown-linux-gnu/esp-emu" >> "${GITHUB_ENV}"
- name: Download replay images
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8
with:
pattern: replay-${{ matrix.frontend }}-*
path: .cache/replay
merge-multiple: true
# Each chip gets its own ports; the four emulators share the runner.
- name: Replay recorded CSI in esp-emu
env:
FRONTEND: ${{ matrix.frontend }}
run: |
mkdir -p .cache/reports/emulator
PIDS=()
INDEX=0
for CHIP in c3 c5 c6 s3; do
REPORT=".cache/reports/emulator/replay-${FRONTEND}-${CHIP}"
# Only this run's replay images are downloaded, one per chip.
FIRMWARE=$(compgen -G ".cache/replay/espectre-${FRONTEND}-*-esp32${CHIP}.bin" | head -n 1 || true)
if [ -n "${FIRMWARE}" ]; then
python tools/emulator/emulator_csi_replay.py --chip "${CHIP}" --firmware "${FIRMWARE}" \
--emulator "${ESP_EMU}" --uart-port $((5556 + INDEX)) --direct-port $((18690 + INDEX)) \
--log "${REPORT}.log" --json "${REPORT}.json" > "${REPORT}.out" 2>&1 &
PIDS+=($!)
else
echo "No replay image: the ${FRONTEND} build for esp32${CHIP} did not finish." > "${REPORT}.out"
PIDS+=("")
fi
INDEX=$((INDEX + 1))
done
STATUS=0
INDEX=0
for CHIP in c3 c5 c6 s3; do
PID="${PIDS[${INDEX}]}"
if [ -n "${PID}" ] && wait "${PID}"; then RESULT=passed; else RESULT=failed; STATUS=1; fi
echo "::group::${FRONTEND} ${CHIP} ${RESULT}"
cat ".cache/reports/emulator/replay-${FRONTEND}-${CHIP}.out"
echo "::endgroup::"
INDEX=$((INDEX + 1))
done
exit "${STATUS}"
- name: Verify Native C6 Wi-Fi rollback with the co-simulation clock
if: matrix.frontend == 'native'
run: |
curl -fsSL -o "${RUNNER_TEMP}/cosim_tcp.py" \
"https://raw.githubusercontent.com/espressif/esp-emulator/v${ESP_EMU_VERSION}/tools/cosim_tcp.py"
echo "994efe25821405cc51bf050b1500478a783dfc08da6454c3b4956758d8702347 ${RUNNER_TEMP}/cosim_tcp.py" | sha256sum -c -
PYTHONPATH="${RUNNER_TEMP}" python tools/emulator/emulator_integration.py rollback \
--emulator "${ESP_EMU}" --firmware .cache/replay/espectre-native-*-esp32c6.bin \
--log .cache/reports/emulator/rollback.log | tee .cache/reports/emulator/rollback.json
shell: bash
- name: Verify ESPHome S3 motion and idle colors on the emulated WS2812
if: matrix.frontend == 'esphome'
run: |
KIT="esp-emu-${ESP_EMU_VERSION}-examples"
curl -fsSL -o "${RUNNER_TEMP}/${KIT}.tar.gz" \
"https://github.com/espressif/esp-emulator/releases/download/v${ESP_EMU_VERSION}/${KIT}.tar.gz"
echo "2951a0f7596a2e622cd9c1f034d68fc21549da2614467bde0f4e52115d75fbcb ${RUNNER_TEMP}/${KIT}.tar.gz" | sha256sum -c -
tar -xzf "${RUNNER_TEMP}/${KIT}.tar.gz" -C "${RUNNER_TEMP}" "${KIT}/ws2812/ws2812.wasm"
python tools/emulator/emulator_integration.py led --emulator "${ESP_EMU}" \
--firmware .cache/replay/led-example-esp32s3.bin --ws2812 "${RUNNER_TEMP}/${KIT}/ws2812/ws2812.wasm" \
--log .cache/reports/emulator/led.log | tee .cache/reports/emulator/led.json
shell: bash
- name: Upload emulator replay report
if: always() && hashFiles('.cache/reports/emulator/*') != ''
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7
with:
overwrite: true
include-hidden-files: true
name: emulator-replay-${{ matrix.frontend }}
path: .cache/reports/emulator/
retention-days: 7
build-matter:
needs: [prepare, test-site, test-cpp, test-python]
permissions:
contents: read
name: Build Matter ${{ matrix.chip }}
runs-on: ubuntu-24.04
timeout-minutes: 90
strategy:
fail-fast: false
matrix:
include:
- chip: ESP32
target: esp32
sdkconfig_defaults: sdkconfig.defaults;sdkconfig.defaults.esp32
- chip: ESP32-C3
target: esp32c3
- chip: ESP32-C5
target: esp32c5
- chip: ESP32-C6
target: esp32c6
- chip: ESP32-S3
target: esp32s3
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
persist-credentials: false
fetch-depth: 0
# Keep dependencies and compiled objects per target. The target suffix
# prevents parallel matrix jobs from competing to populate one cache.
- name: Cache Matter toolchain, components, and compiler objects
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
with:
path: |
.cache/build/matter-home
src/cpp/frontend/matter/app/managed_components
key: matter-${{ runner.os }}-idf-v5.5-build-v3-${{ matrix.target }}-${{ hashFiles('requirements.txt', 'src/cpp/frontend/matter/app/main/idf_component.yml', 'src/cpp/frontend/matter/app/sdkconfig.defaults*') }}
restore-keys: |
matter-${{ runner.os }}-idf-v5.5-build-v3-${{ matrix.target }}-
matter-${{ runner.os }}-idf-v5.5-deps-v2-
- name: Build Matter firmware
run: |
mkdir -p .cache/firmware
.github/scripts/build_matter_firmware.sh
env:
ESPECTRE_GIT_VERSION: ${{ needs.prepare.outputs.version }}
MATTER_TARGET: ${{ matrix.target }}
MATTER_OUTPUT: ${{ github.workspace }}/.cache/firmware/espectre-matter-${{ needs.prepare.outputs.artifact_suffix }}-${{ matrix.target }}.bin
MATTER_SDKCONFIG_DEFAULTS: ${{ matrix.sdkconfig_defaults || '' }}
- name: Stage Matter firmware audit input
run: |
mkdir -p .cache/audit-input
cp .cache/firmware/espectre-matter-*-sbom.spdx.json ".cache/audit-input/${{ matrix.chip }}.spdx.json"
- name: Upload Matter firmware audit input
if: success()
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7
with:
overwrite: true
name: audit-firmware-matter-${{ matrix.chip }}
path: .cache/audit-input/${{ matrix.chip }}.spdx.json
retention-days: 1
- name: Upload Matter firmware artifact
if: success() && github.event_name == 'push'
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7
with:
overwrite: true
include-hidden-files: true
name: firmware-matter-${{ matrix.chip }}
path: .cache/firmware/espectre-matter-*
retention-days: 7
build-native:
needs: [prepare, test-site, test-cpp, test-python]
permissions:
contents: read
name: Build Native ${{ matrix.chip }}
runs-on: ubuntu-24.04
timeout-minutes: 90
strategy:
fail-fast: false
matrix:
include:
- chip: ESP32
target: esp32
sdkconfig_defaults: sdkconfig.defaults;sdkconfig.defaults.esp32
- chip: ESP32-C3
target: esp32c3
- chip: ESP32-C5
target: esp32c5
- chip: ESP32-C6
target: esp32c6
- chip: ESP32-S3
target: esp32s3
- chip: ESP32-S2
target: esp32s2
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
persist-credentials: false
fetch-depth: 0
- name: Set up firmware signing
uses: ./.github/actions/setup-firmware-signing
# The cached home contains target-independent Python and component dependencies.
- name: Cache native toolchain
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
with:
path: .cache/build/native-home
key: native-${{ runner.os }}-idf-v5.5-deps-v2-${{ hashFiles('requirements.txt') }}
restore-keys: |
native-${{ runner.os }}-idf-v5.5-deps-v2-
- name: Build native firmware
run: |
mkdir -p .cache/firmware
python .github/scripts/build_signed_firmware.py native ${{ needs.prepare.outputs.sign != 'true' && '--test-key' || '' }}
env:
ESPECTRE_GIT_VERSION: ${{ needs.prepare.outputs.version }}
FIRMWARE_SIGNING_KEY_RSA: ${{ needs.prepare.outputs.sign == 'true' && secrets.FIRMWARE_SIGNING_KEY_RSA || '' }}
FIRMWARE_SIGNING_KEY_ESP32: ${{ needs.prepare.outputs.sign == 'true' && secrets.FIRMWARE_SIGNING_KEY_ESP32 || '' }}
NATIVE_TARGET: ${{ matrix.target }}
NATIVE_OUTPUT: ${{ github.workspace }}/.cache/firmware/espectre-native-${{ needs.prepare.outputs.artifact_suffix }}-${{ matrix.target }}.bin
NATIVE_OTA_OUTPUT: ${{ github.workspace }}/.cache/firmware/espectre-native-${{ needs.prepare.outputs.artifact_suffix }}-${{ matrix.target }}-ota.bin
NATIVE_OTA_CHANNEL: ${{ needs.prepare.outputs.ota_channel }}
NATIVE_SDKCONFIG_DEFAULTS: ${{ matrix.sdkconfig_defaults || '' }}
- name: Upload emulator replay image
if: success() && contains(fromJSON('["esp32c3", "esp32c5", "esp32c6", "esp32s3"]'), matrix.target)
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7
with:
overwrite: true
name: replay-native-${{ matrix.target }}
path: .cache/firmware/espectre-native-${{ needs.prepare.outputs.artifact_suffix }}-${{ matrix.target }}.bin
retention-days: 1
- name: Stage native firmware audit input
run: |
mkdir -p .cache/audit-input
for SBOM in .cache/firmware/espectre-native-*-sbom.spdx.json; do
case "${SBOM}" in *-ota-sbom.spdx.json) continue ;; esac
cp "${SBOM}" ".cache/audit-input/${{ matrix.chip }}.spdx.json"
done
test -f ".cache/audit-input/${{ matrix.chip }}.spdx.json"
- name: Upload native firmware audit input
if: success()
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7
with:
overwrite: true
name: audit-firmware-native-${{ matrix.chip }}
path: .cache/audit-input/${{ matrix.chip }}.spdx.json
retention-days: 1
- name: Upload native firmware artifact
if: success() && github.event_name == 'push'
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7
with:
overwrite: true
include-hidden-files: true
name: firmware-native-${{ matrix.chip }}
path: .cache/firmware/espectre-native-*
retention-days: 7
build-traffic-generator-image:
name: Build Traffic Generator Image
needs: [prepare, test-site, test-cpp, test-python]
runs-on: ubuntu-24.04
timeout-minutes: 15
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
persist-credentials: false
- uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1
- name: Build the image and check its web UI
env:
IMAGE_VERSION: ${{ needs.prepare.outputs.version }}
run: |
# Print the container log and remove it whatever the outcome.
trap 'docker logs traffic-generator || true; docker rm --force traffic-generator > /dev/null 2>&1 || true' EXIT
docker buildx build --load --platform linux/amd64 \
--build-arg VERSION="$IMAGE_VERSION" \
--tag espectre-traffic-generator:ci \
--file tools/traffic_generator_docker/Dockerfile .
docker run --detach --name traffic-generator --publish 127.0.0.1:8099:8099 \
--env ESPECTRE_UI_TOKEN=ci-smoke-test-token espectre-traffic-generator:ci
for _ in $(seq 1 30); do
curl --silent --fail --output /dev/null http://127.0.0.1:8099/ && break
sleep 1
done
sleep 2
test "$(curl --silent --output /dev/null --write-out '%{http_code}' http://127.0.0.1:8099/api/status)" = 401
curl --silent --fail --output /dev/null --cookie-jar cookies.txt \
--header 'Content-Type: application/json' --data '{"token": "ci-smoke-test-token"}' \
http://127.0.0.1:8099/api/login
curl --silent --fail --cookie cookies.txt http://127.0.0.1:8099/api/status \
| python3 -c 'import json, sys; assert json.load(sys.stdin)["generator"]["running"]'
- name: Build the multi-architecture image archive
env:
IMAGE_VERSION: ${{ needs.prepare.outputs.version }}
run: |
mkdir -p .cache/image
# GitHub reads a multi-architecture package's description from index annotations, not labels.
docker buildx build --platform linux/amd64,linux/arm64 \
--build-arg VERSION="$IMAGE_VERSION" \
--annotation "index:org.opencontainers.image.description=Sends external sensing traffic to ESPectre devices, finds them on the network, and switches their traffic source from a web UI. Guide: https://github.com/francescopace/espectre/blob/main/tools/traffic_generator_docker/README.md" \
--annotation "index:org.opencontainers.image.source=https://github.com/francescopace/espectre" \
--annotation "index:org.opencontainers.image.licenses=GPL-3.0-only" \
--annotation "index:org.opencontainers.image.version=$IMAGE_VERSION" \
--output type=oci,dest=.cache/image/traffic-generator-image.tar \
--file tools/traffic_generator_docker/Dockerfile .
- name: Upload the image archive
if: github.event_name == 'push'
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7
with:
overwrite: true
name: traffic-generator-image
path: .cache/image/traffic-generator-image.tar
if-no-files-found: error
retention-days: 7
build-arduino:
needs: [prepare, test-site, test-cpp, test-python]
permissions:
contents: read
name: Build Arduino ${{ matrix.core }} on ${{ matrix.target.chip }}
runs-on: ubuntu-24.04
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
core: ['3.3.12', '4.0.0']
target:
- chip: ESP32
board: esp32
- chip: ESP32-C3
board: esp32c3
- chip: ESP32-C5
board: esp32c5
- chip: ESP32-C6
board: esp32c6
- chip: ESP32-S2
board: esp32s2
- chip: ESP32-S3
board: esp32s3
env:
ARDUINO_CLI_VERSION: 1.5.1
ARDUINO_CLI_SHA256: 28a8e119c498a25607821c36cb2dc49e8463941b261a0d99091baa7bc692dd2b
ARDUINO_ESP32_VERSION: ${{ matrix.core }}
ARDUINO_DIRECTORIES_DATA: ${{ github.workspace }}/.cache/arduino/data
ARDUINO_DIRECTORIES_DOWNLOADS: ${{ github.workspace }}/.cache/arduino/downloads
ARDUINO_DIRECTORIES_USER: ${{ github.workspace }}/.cache/arduino/user
ARDUINO_LIBRARY_ENABLE_UNSAFE_INSTALL: 'true'
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
persist-credentials: false
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7
with:
python-version: '3.14'
cache: 'pip'
cache-dependency-path: requirements.txt
- name: Install packaging dependencies
run: python -m pip install -r requirements.txt
- name: Cache Arduino core
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
with:
path: |
.cache/arduino/data
.cache/arduino/downloads
key: arduino-${{ runner.os }}-esp32-${{ env.ARDUINO_ESP32_VERSION }}
- name: Install Arduino CLI and the ESP32 core
run: |
mkdir -p .cache/arduino/bin
curl -fsSL -o .cache/arduino/cli.tar.gz \
"https://github.com/arduino/arduino-cli/releases/download/v${ARDUINO_CLI_VERSION}/arduino-cli_${ARDUINO_CLI_VERSION}_Linux_64bit.tar.gz"
echo "${ARDUINO_CLI_SHA256} .cache/arduino/cli.tar.gz" | sha256sum --check
tar -xzf .cache/arduino/cli.tar.gz -C .cache/arduino/bin arduino-cli
echo "${{ github.workspace }}/.cache/arduino/bin" >> "$GITHUB_PATH"
.cache/arduino/bin/arduino-cli core install "esp32:esp32@${ARDUINO_ESP32_VERSION}" \
--additional-urls https://espressif.github.io/arduino-esp32/package_esp32_index.json
- name: Build Arduino library
env:
LIBRARY_VERSION: ${{ needs.prepare.outputs.version }}
run: |
python .github/scripts/build_arduino_package.py \
--version "$LIBRARY_VERSION" \
--output-dir .cache/arduino-library
arduino-cli lib install --zip-path .cache/arduino-library/espectre-arduino-*.zip
- name: Compile the MotionDetection example
run: |
arduino-cli compile --warnings default \
--fqbn "esp32:esp32:${{ matrix.target.board }}" \
"${ARDUINO_DIRECTORIES_USER}/libraries/ESPectre/examples/MotionDetection"
- name: Compile the display examples
if: matrix.target.board == 'esp32s3'
run: |
arduino-cli lib install --no-deps \
"Adafruit BusIO@1.17.4" \
"Adafruit GFX Library@1.12.6" \
"Adafruit ST7735 and ST7789 Library@1.11.0"
arduino-cli compile --warnings default \
--fqbn esp32:esp32:adafruit_feather_esp32s3_reversetft \
"${ARDUINO_DIRECTORIES_USER}/libraries/ESPectre/examples/FeatherReverseTFT"
arduino-cli compile --warnings default \
--fqbn esp32:esp32:esp32s3:CDCOnBoot=cdc \
"${ARDUINO_DIRECTORIES_USER}/libraries/ESPectre/examples/WaveshareTouchLCD147"
- name: Upload Arduino library
if: success() && github.event_name == 'push' && matrix.target.board == 'esp32' && matrix.core == '4.0.0'
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7
with:
overwrite: true
name: arduino-library
path: .cache/arduino-library/espectre-arduino-*.zip
retention-days: 7
build-sdk:
name: Build SDK Package
needs: [prepare, test-site, test-cpp, test-python]
runs-on: ubuntu-24.04
timeout-minutes: 15
outputs:
publication: ${{ needs.prepare.outputs.publication }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
persist-credentials: false
fetch-depth: 0
- uses: ./.github/actions/setup-sdk-packaging
- uses: ./.github/actions/setup-doxygen
- name: Build SDK package
env:
SDK_CHANNEL: ${{ needs.prepare.outputs.channel }}
SDK_VERSION: ${{ needs.prepare.outputs.version }}
SDK_RELEASE_TAG: ${{ needs.prepare.outputs.release_tag }}
run: |
mkdir -p .cache/sdk
python .github/scripts/build_sdk_package.py \
--channel "$SDK_CHANNEL" \
--version "$SDK_VERSION" \
--release-tag "$SDK_RELEASE_TAG" \
--output-dir .cache/sdk \
--component-output-dir .cache/registry/espectre \
--commit "${{ github.sha }}"
- name: Upload SDK package artifact
if: github.event_name == 'push'
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7
with:
overwrite: true
include-hidden-files: true
name: sdk-bundle
path: |
.cache/sdk/espectre-sdk-*.tar.gz
.cache/sdk/espectre-sdk-*.zip
.cache/sdk/sdk-manifest-*.json
retention-days: 7
- name: Upload registry component
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7
with:
overwrite: true
name: registry-component
path: |
.cache/registry/espectre-component-*.tgz
.cache/registry/component-inventory.json
if-no-files-found: error
retention-days: 7
audit-esphome:
name: Audit ESPHome firmware dependencies
needs: build-esphome
permissions:
contents: read
security-events: write
runs-on: ubuntu-24.04
timeout-minutes: 20
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7
with:
python-version: '3.14'
cache: 'pip'
cache-dependency-path: requirements.txt
- name: Install audit dependencies
run: python -m pip install -r requirements.txt
- name: Download firmware audit inputs
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8
with:
pattern: audit-firmware-esphome-*
path: .cache/audit-input
merge-multiple: true
- name: Audit ESPHome firmware dependencies
run: |
python .github/scripts/audit_firmware_dependencies.py \
--frontend esphome \
--sbom .cache/audit-input/*.spdx.json \
--expected-target ESP32 \
--expected-target ESP32-S2 \
--expected-target ESP32-S3 \
--expected-target ESP32-C3 \
--expected-target ESP32-C5 \
--expected-target ESP32-C6 \
--output-dir .cache/reports/firmware/esphome
- name: Summarize firmware audit
if: always()
run: |
if [ -f .cache/reports/firmware/esphome/summary.md ]; then
cat .cache/reports/firmware/esphome/summary.md >> "$GITHUB_STEP_SUMMARY"
else
echo 'Firmware dependency audit did not produce a report.' >> "$GITHUB_STEP_SUMMARY"
fi
- name: Upload firmware vulnerability alerts
if: always() && hashFiles('.cache/reports/firmware/esphome/results.sarif') != '' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository)
uses: github/codeql-action/upload-sarif@33d7b85da1a04171e211befe2c739303b9a4c066 # v4.39.3
with:
sarif_file: .cache/reports/firmware/esphome/results.sarif
category: firmware/esphome
audit-matter:
name: Audit Matter firmware dependencies
needs: build-matter
permissions:
contents: read
security-events: write
runs-on: ubuntu-24.04
timeout-minutes: 20
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7
with:
python-version: '3.14'
cache: 'pip'
cache-dependency-path: requirements.txt
- name: Install audit dependencies
run: python -m pip install -r requirements.txt
- name: Download firmware audit inputs
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8
with:
pattern: audit-firmware-matter-*
path: .cache/audit-input
merge-multiple: true
- name: Audit Matter firmware dependencies
run: |
python .github/scripts/audit_firmware_dependencies.py \
--frontend matter \
--sbom .cache/audit-input/*.spdx.json \
--expected-target ESP32 \
--expected-target ESP32-C3 \
--expected-target ESP32-C5 \
--expected-target ESP32-C6 \
--expected-target ESP32-S3 \
--output-dir .cache/reports/firmware/matter
- name: Summarize firmware audit
if: always()
run: |
if [ -f .cache/reports/firmware/matter/summary.md ]; then
cat .cache/reports/firmware/matter/summary.md >> "$GITHUB_STEP_SUMMARY"
else
echo 'Firmware dependency audit did not produce a report.' >> "$GITHUB_STEP_SUMMARY"
fi