Skip to content

Commit 789b1a8

Browse files
lucasssvazP-R-O-C-H-Ypre-commit-ci-lite[bot]
authored
ci(wokwi): Add Wokwi emulator to workflow (espressif#9540)
* ci(wokwi): Add wokwi emulator to CI * feat(wokwi): Support scenario * feat(wokwi): Add simple CI test for push button * sudo apt command * sudo both apt commands * Add missing test.py file * Test pytest path changes * empty push * move wokwi cli token variable * move token back to wokwi job * Update hil.yml * Update hil.yml * revert run on pr * run on PR target * run only on master * ci(wokwi): Support wokwi * ci(wokwi): Skip unsupported and performance test * ci(wokwi): run wokwi tests without label * debug: run build on windows * RUN WIFI WITH PSRAM ON-OFF * fix psram for S3 * Revert "debug: run build on windows" This reverts commit bc085e5. * ci(wokwi): Run workflow only if build was sucessful * ci(pre-commit): Apply automatic fixes * ci(wokwi): Add generated files to gitignore --------- Co-authored-by: Jan Prochazka <[email protected]> Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
1 parent b59a368 commit 789b1a8

33 files changed

+510
-18
lines changed

.github/scripts/tests_run.sh

+22-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ function run_test() {
88
local sketchdir=$(dirname $sketch)
99
local sketchname=$(basename $sketchdir)
1010

11+
if [[ -f "$sketchdir/.skip.$platform" ]]; then
12+
echo "Skipping $sketchname test in $target"
13+
exit 0
14+
fi
15+
1116
if [ $options -eq 0 ] && [ -f $sketchdir/cfg.json ]; then
1217
len=`jq -r --arg chip $target '.targets[] | select(.name==$chip) | .fqbn | length' $sketchdir/cfg.json`
1318
else
@@ -33,7 +38,16 @@ function run_test() {
3338
report_file="$sketchdir/$sketchname$i.xml"
3439
fi
3540

36-
pytest tests --build-dir $build_dir -k test_$sketchname --junit-xml=$report_file
41+
if [ $platform == "wokwi" ]; then
42+
extra_args="--target $target --embedded-services arduino,wokwi --wokwi-timeout=$wokwi_timeout"
43+
if [[ -f "$sketchdir/scenario.yaml" ]]; then
44+
extra_args+=" --wokwi-scenario $sketchdir/scenario.yaml"
45+
fi
46+
else
47+
extra_args="--embedded-services esp,arduino"
48+
fi
49+
50+
pytest tests --build-dir $build_dir -k test_$sketchname --junit-xml=$report_file $extra_args
3751
result=$?
3852
if [ $result -ne 0 ]; then
3953
return $result
@@ -44,6 +58,8 @@ function run_test() {
4458
SCRIPTS_DIR="./.github/scripts"
4559
COUNT_SKETCHES="${SCRIPTS_DIR}/sketch_utils.sh count"
4660

61+
platform="hardware"
62+
wokwi_timeout=60000
4763
chunk_run=0
4864
options=0
4965
erase=0
@@ -53,6 +69,11 @@ while [ ! -z "$1" ]; do
5369
-c )
5470
chunk_run=1
5571
;;
72+
-w )
73+
shift
74+
wokwi_timeout=$1
75+
platform="wokwi"
76+
;;
5677
-o )
5778
options=1
5879
;;

.github/workflows/hil.yml

+65-9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Run tests in hardware
1+
name: Run tests
22

33
on:
44
pull_request:
@@ -9,6 +9,8 @@ on:
99

1010
env:
1111
MAX_CHUNKS: 15
12+
WOKWI_TIMEOUT: 120000 # Milliseconds
13+
WOKWI_CLI_TOKEN: ${{ secrets.WOKWI_CLI_TOKEN }}
1214

1315
concurrency:
1416
group: hil-${{github.event.pull_request.number || github.ref}}
@@ -17,8 +19,7 @@ concurrency:
1719
jobs:
1820
gen_chunks:
1921
if: |
20-
contains(github.event.pull_request.labels.*.name, 'hil_test') ||
21-
contains(github.event.pull_request.labels.*.name, 'perf_test') ||
22+
github.event_name == 'pull_request' ||
2223
(github.event_name == 'schedule' && github.repository == 'espressif/arduino-esp32')
2324
name: Generate Chunks matrix
2425
runs-on: ubuntu-latest
@@ -58,7 +59,7 @@ jobs:
5859
echo "test_folder=${test_folder}" >> $GITHUB_OUTPUT
5960
echo "test_type=${test_type}" >> $GITHUB_OUTPUT
6061
61-
Build:
62+
build:
6263
needs: gen_chunks
6364
name: ${{matrix.chip}}-Build#${{matrix.chunks}}
6465
runs-on: ubuntu-latest
@@ -82,11 +83,65 @@ jobs:
8283
path: |
8384
~/.build_skipped
8485
~/.arduino/tests/**/build*.tmp/*.bin
86+
~/.arduino/tests/**/build*.tmp/*.elf
8587
~/.arduino/tests/**/build*.tmp/*.json
8688
87-
Test:
88-
needs: [gen_chunks, Build]
89-
name: ${{matrix.chip}}-Test#${{matrix.chunks}}
89+
wokwi-test:
90+
needs: [gen_chunks, build]
91+
if: github.event_name == 'schedule'
92+
name: ${{matrix.chip}}-Wokwi_Test#${{matrix.chunks}}
93+
strategy:
94+
fail-fast: false
95+
matrix:
96+
chip: ['esp32', 'esp32s2', 'esp32s3', 'esp32c3', 'esp32c6', 'esp32h2']
97+
chunks: ${{fromJson(needs.gen_chunks.outputs.chunks)}}
98+
runs-on: ubuntu-latest
99+
steps:
100+
- name: Checkout repository
101+
uses: actions/checkout@v4
102+
103+
- name: Download ${{matrix.chip}}-${{matrix.chunks}} artifacts
104+
uses: actions/download-artifact@v4
105+
with:
106+
name: ${{matrix.chip}}-${{matrix.chunks}}.artifacts
107+
path: ~/
108+
109+
- name: Install Wokwi CLI
110+
run: curl -L https://wokwi.com/ci/install.sh | sh
111+
112+
- name: Install dependencies
113+
run: |
114+
pip install -U pip
115+
pip install -r tests/requirements.txt --extra-index-url https://dl.espressif.com/pypi
116+
sudo apt update && sudo apt install -y -qq jq
117+
118+
- name: Run Tests
119+
env:
120+
WOKWI_CLI_TOKEN: ${{ secrets.WOKWI_CLI_TOKEN }}
121+
run: |
122+
bash .github/scripts/tests_run.sh -c -t ${{matrix.chip}} -i ${{matrix.chunks}} -m ${{env.MAX_CHUNKS}} -w ${{env.WOKWI_TIMEOUT}}
123+
124+
- name: Check if tests were skipped
125+
id: check-test-skipped
126+
run: |
127+
if [ -f ~/.test_skipped ]; then
128+
echo "skipped=true" >> $GITHUB_OUTPUT
129+
else
130+
echo "skipped=false" >> $GITHUB_OUTPUT
131+
fi
132+
133+
- name: Upload test result artifacts
134+
uses: actions/upload-artifact@v4
135+
if: ${{ always() && steps.check-test-skipped.outputs.skipped == 'false' }}
136+
with:
137+
name: wokwi_results-${{matrix.chip}}-${{matrix.chunks}}
138+
path: tests/**/*.xml
139+
140+
hardware-test:
141+
needs: [gen_chunks, build]
142+
name: ${{matrix.chip}}-Hardware_Test#${{matrix.chunks}}
143+
if: |
144+
contains(github.event.pull_request.labels.*.name, 'hil_test') || github.event_name == 'schedule'
90145
strategy:
91146
fail-fast: false
92147
matrix:
@@ -130,7 +185,7 @@ jobs:
130185
uses: actions/upload-artifact@v4
131186
if: ${{ always() && steps.check-test-skipped.outputs.skipped == 'false' }}
132187
with:
133-
name: test_results-${{matrix.chip}}-${{matrix.chunks}}
188+
name: hw_results-${{matrix.chip}}-${{matrix.chunks}}
134189
if-no-files-found: error
135190
path: |
136191
tests/**/*.xml
@@ -142,11 +197,12 @@ jobs:
142197
contains(github.event.pull_request.labels.*.name, 'hil_test') ||
143198
contains(github.event.pull_request.labels.*.name, 'perf_test') ||
144199
github.event_name == 'schedule'
145-
needs: Test
200+
needs: hardware-test
146201
runs-on: ubuntu-latest
147202
steps:
148203
- name: Upload
149204
uses: actions/upload-artifact@v4
150205
with:
151206
name: Event File
152207
path: ${{github.event_path}}
208+

.github/workflows/publish.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Unit Test Results
22

33
on:
44
workflow_run:
5-
workflows: [Run tests in hardware]
5+
workflows: [Run tests]
66
branches-ignore: [master]
77

88
types:

.github/workflows/wokwi.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ concurrency:
2121

2222
jobs:
2323
gen_chunks:
24-
if: github.event.workflow_run.event == 'pull_request'
24+
if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success'
2525
name: Generate Chunks matrix
2626
runs-on: ubuntu-latest
2727
outputs:

tests/.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@ build*/
22
__pycache__/
33
*.xml
44
result_*.json
5+
diagram.json
6+
wokwi.toml

tests/performance/coremark/.skip.wokwi

Whitespace-only changes.

tests/performance/fibonacci/.skip.wokwi

Whitespace-only changes.

tests/performance/psramspeed/.skip.wokwi

Whitespace-only changes.

tests/performance/ramspeed/.skip.wokwi

Whitespace-only changes.

tests/performance/superpi/.skip.wokwi

Whitespace-only changes.

tests/pytest.ini

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[pytest]
2-
addopts = --embedded-services esp,arduino
2+
addopts = --embedded-services esp,arduino,wokwi
33

44
# log related
55
log_cli = True

tests/requirements.txt

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
cryptography>=2.1.4
22
--only-binary cryptography
33
pytest-cov
4-
pytest-embedded-serial-esp>=1.10.0
5-
pytest-embedded-arduino>=1.10.0
4+
pytest-embedded-serial-esp>=1.10.2
5+
pytest-embedded-arduino>=1.10.2
6+
pytest-embedded-wokwi>=1.10.2

tests/validation/gpio/.skip.hardware

Whitespace-only changes.

tests/validation/gpio/.skip.qemu

Whitespace-only changes.
+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"version": 1,
3+
"author": "P-R-O-C-H-Y",
4+
"editor": "wokwi",
5+
"parts": [
6+
{
7+
"type": "board-esp32-devkit-c-v4",
8+
"id": "esp32",
9+
"top": -57.6,
10+
"left": -177.56,
11+
"attrs": {}
12+
},
13+
{
14+
"type": "wokwi-pushbutton",
15+
"id": "btn1",
16+
"top": -13,
17+
"left": -19.2,
18+
"attrs": { "color": "green" }
19+
}
20+
],
21+
"connections": [
22+
[ "esp32:RX", "$serialMonitor:TX", "", [] ],
23+
[ "esp32:TX", "$serialMonitor:RX", "", [] ],
24+
[ "btn1:1.l", "esp32:0", "blue", [ "h-19.2", "v48", "h-38.4" ] ],
25+
[ "btn1:2.r", "esp32:GND.1", "black", [ "h19.4", "v173", "h-269.2", "v-98.23" ] ]
26+
],
27+
"dependencies": {}
28+
}
+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"version": 1,
3+
"author": "P-R-O-C-H-Y",
4+
"editor": "wokwi",
5+
"parts": [
6+
{
7+
"type": "board-esp32-c3-devkitm-1",
8+
"id": "esp32",
9+
"top": -57.6,
10+
"left": -177.56,
11+
"attrs": {}
12+
},
13+
{
14+
"type": "wokwi-pushbutton",
15+
"id": "btn1",
16+
"top": -22.6,
17+
"left": -19.2,
18+
"attrs": { "color": "green" }
19+
}
20+
],
21+
"connections": [
22+
[ "esp32:RX", "$serialMonitor:TX", "", [] ],
23+
[ "esp32:TX", "$serialMonitor:RX", "", [] ],
24+
[ "btn1:1.l", "esp32:0", "blue", [ "h-28.8", "v144", "h-144", "v-95.7" ] ],
25+
[ "btn1:2.r", "esp32:GND.1", "black", [ "h19.4", "v173", "h-269.2", "v-98.23" ] ]
26+
],
27+
"dependencies": {}
28+
}
+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"version": 1,
3+
"author": "P-R-O-C-H-Y",
4+
"editor": "wokwi",
5+
"parts": [
6+
{
7+
"type": "board-esp32-c6-devkitc-1",
8+
"id": "esp32",
9+
"top": -57.6,
10+
"left": -177.56,
11+
"attrs": {}
12+
},
13+
{
14+
"type": "wokwi-pushbutton",
15+
"id": "btn1",
16+
"top": -22.6,
17+
"left": -19.2,
18+
"attrs": { "color": "green" }
19+
}
20+
],
21+
"connections": [
22+
[ "esp32:RX", "$serialMonitor:TX", "", [] ],
23+
[ "esp32:TX", "$serialMonitor:RX", "", [] ],
24+
[ "btn1:1.l", "esp32:0", "blue", [ "h-19.2", "v-96", "h-163.2", "v93.77" ] ],
25+
[ "btn1:2.r", "esp32:GND.1", "black", [ "h19.4", "v173", "h-269.2", "v-98.23" ] ]
26+
],
27+
"dependencies": {}
28+
}
+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"version": 1,
3+
"author": "P-R-O-C-H-Y",
4+
"editor": "wokwi",
5+
"parts": [
6+
{
7+
"type": "board-esp32-h2-devkitm-1",
8+
"id": "esp32",
9+
"top": -57.6,
10+
"left": -177.56,
11+
"attrs": {}
12+
},
13+
{
14+
"type": "wokwi-pushbutton",
15+
"id": "btn1",
16+
"top": -22.6,
17+
"left": -19.2,
18+
"attrs": { "color": "green" }
19+
}
20+
],
21+
"connections": [
22+
[ "esp32:RX", "$serialMonitor:TX", "", [] ],
23+
[ "esp32:TX", "$serialMonitor:RX", "", [] ],
24+
[ "btn1:1.l", "esp32:0", "blue", [ "h-19.2", "v-96", "h-163.2", "v93.77" ] ],
25+
[ "btn1:2.r", "esp32:GND.1", "black", [ "h19.4", "v173", "h-269.2", "v-98.23" ] ]
26+
],
27+
"dependencies": {}
28+
}
+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"version": 1,
3+
"author": "P-R-O-C-H-Y",
4+
"editor": "wokwi",
5+
"parts": [
6+
{
7+
"type": "board-esp32-s2-devkitm-1",
8+
"id": "esp32",
9+
"top": -57.6,
10+
"left": -177.56,
11+
"attrs": {}
12+
},
13+
{
14+
"type": "wokwi-pushbutton",
15+
"id": "btn1",
16+
"top": -22.6,
17+
"left": -19.2,
18+
"attrs": { "color": "green" }
19+
}
20+
],
21+
"connections": [
22+
[ "esp32:RX", "$serialMonitor:TX", "", [] ],
23+
[ "esp32:TX", "$serialMonitor:RX", "", [] ],
24+
[ "btn1:1.l", "esp32:0", "blue", [ "h-28.8", "v-57.6", "h-144", "v42.71" ] ],
25+
[ "btn1:2.r", "esp32:GND.1", "black", [ "h19.4", "v173", "h-269.2", "v-98.23" ] ]
26+
],
27+
"dependencies": {}
28+
}
+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"version": 1,
3+
"author": "P-R-O-C-H-Y",
4+
"editor": "wokwi",
5+
"parts": [
6+
{
7+
"type": "board-esp32-s3-devkitc-1",
8+
"id": "esp32",
9+
"top": -57.6,
10+
"left": -177.56,
11+
"attrs": {}
12+
},
13+
{
14+
"type": "wokwi-pushbutton",
15+
"id": "btn1",
16+
"top": -22.6,
17+
"left": -19.2,
18+
"attrs": { "color": "green" }
19+
}
20+
],
21+
"connections": [
22+
[ "esp32:RX", "$serialMonitor:TX", "", [] ],
23+
[ "esp32:TX", "$serialMonitor:RX", "", [] ],
24+
[ "btn1:1.l", "esp32:0", "blue", [ "h-38.4", "v105.78" ] ],
25+
[ "btn1:2.r", "esp32:GND.1", "black", [ "h19.4", "v221", "h-269.2", "v-57.42" ] ]
26+
],
27+
"dependencies": {}
28+
}

0 commit comments

Comments
 (0)