Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci(wokwi): Add Wokwi emulator to workflow #9540

Merged
merged 27 commits into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
759974e
ci(wokwi): Add wokwi emulator to CI
lucasssvaz Apr 19, 2024
1695e79
feat(wokwi): Support scenario
P-R-O-C-H-Y Apr 29, 2024
296a9a4
feat(wokwi): Add simple CI test for push button
P-R-O-C-H-Y Apr 29, 2024
0107545
sudo apt command
P-R-O-C-H-Y Apr 29, 2024
831eab6
sudo both apt commands
P-R-O-C-H-Y Apr 29, 2024
c4d3ad7
Add missing test.py file
P-R-O-C-H-Y Apr 29, 2024
d40d17e
Test pytest path changes
P-R-O-C-H-Y Apr 30, 2024
d3d807c
empty push
P-R-O-C-H-Y Apr 30, 2024
f723247
move wokwi cli token variable
P-R-O-C-H-Y Apr 30, 2024
bddf692
move token back to wokwi job
P-R-O-C-H-Y Apr 30, 2024
fe20ae0
Update hil.yml
P-R-O-C-H-Y Apr 30, 2024
685383b
Update hil.yml
P-R-O-C-H-Y Apr 30, 2024
b1cd645
revert run on pr
P-R-O-C-H-Y Apr 30, 2024
9df5f5f
run on PR target
P-R-O-C-H-Y Apr 30, 2024
ca03917
run only on master
P-R-O-C-H-Y Apr 30, 2024
140cb2f
Merge branch 'master' into ci/wokwi
P-R-O-C-H-Y May 7, 2024
01752c6
ci(wokwi): Support wokwi
P-R-O-C-H-Y May 7, 2024
cad222f
Merge branch 'master' into ci/wokwi
P-R-O-C-H-Y May 7, 2024
186e17e
ci(wokwi): Skip unsupported and performance test
P-R-O-C-H-Y May 7, 2024
b1c714d
ci(wokwi): run wokwi tests without label
P-R-O-C-H-Y May 7, 2024
bc085e5
debug: run build on windows
P-R-O-C-H-Y May 7, 2024
99af207
RUN WIFI WITH PSRAM ON-OFF
P-R-O-C-H-Y May 7, 2024
9ccead0
fix psram for S3
P-R-O-C-H-Y May 7, 2024
71fe262
Revert "debug: run build on windows"
P-R-O-C-H-Y May 7, 2024
9cdd132
ci(wokwi): Run workflow only if build was sucessful
P-R-O-C-H-Y May 7, 2024
6f4880c
ci(pre-commit): Apply automatic fixes
pre-commit-ci-lite[bot] May 7, 2024
ba3a549
ci(wokwi): Add generated files to gitignore
lucasssvaz May 7, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 22 additions & 1 deletion .github/scripts/tests_run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ function run_test() {
local sketchdir=$(dirname $sketch)
local sketchname=$(basename $sketchdir)

if [[ -f "$sketchdir/.skip.$platform" ]]; then
echo "Skipping $sketchname test in $target"
exit 0
fi

if [ $options -eq 0 ] && [ -f $sketchdir/cfg.json ]; then
len=`jq -r --arg chip $target '.targets[] | select(.name==$chip) | .fqbn | length' $sketchdir/cfg.json`
else
Expand All @@ -33,7 +38,16 @@ function run_test() {
report_file="$sketchdir/$sketchname$i.xml"
fi

pytest tests --build-dir $build_dir -k test_$sketchname --junit-xml=$report_file
if [ $platform == "wokwi" ]; then
extra_args="--target $target --embedded-services arduino,wokwi --wokwi-timeout=$wokwi_timeout"
if [[ -f "$sketchdir/scenario.yaml" ]]; then
extra_args+=" --wokwi-scenario $sketchdir/scenario.yaml"
fi
else
extra_args="--embedded-services esp,arduino"
fi

pytest tests --build-dir $build_dir -k test_$sketchname --junit-xml=$report_file $extra_args
result=$?
if [ $result -ne 0 ]; then
return $result
Expand All @@ -44,6 +58,8 @@ function run_test() {
SCRIPTS_DIR="./.github/scripts"
COUNT_SKETCHES="${SCRIPTS_DIR}/sketch_utils.sh count"

platform="hardware"
wokwi_timeout=60000
chunk_run=0
options=0
erase=0
Expand All @@ -53,6 +69,11 @@ while [ ! -z "$1" ]; do
-c )
chunk_run=1
;;
-w )
shift
wokwi_timeout=$1
platform="wokwi"
;;
-o )
options=1
;;
Expand Down
74 changes: 65 additions & 9 deletions .github/workflows/hil.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Run tests in hardware
name: Run tests

on:
pull_request:
Expand All @@ -9,6 +9,8 @@ on:

env:
MAX_CHUNKS: 15
WOKWI_TIMEOUT: 120000 # Milliseconds
WOKWI_CLI_TOKEN: ${{ secrets.WOKWI_CLI_TOKEN }}

concurrency:
group: hil-${{github.event.pull_request.number || github.ref}}
Expand All @@ -17,8 +19,7 @@ concurrency:
jobs:
gen_chunks:
if: |
contains(github.event.pull_request.labels.*.name, 'hil_test') ||
contains(github.event.pull_request.labels.*.name, 'perf_test') ||
github.event_name == 'pull_request' ||
(github.event_name == 'schedule' && github.repository == 'espressif/arduino-esp32')
name: Generate Chunks matrix
runs-on: ubuntu-latest
Expand Down Expand Up @@ -58,7 +59,7 @@ jobs:
echo "test_folder=${test_folder}" >> $GITHUB_OUTPUT
echo "test_type=${test_type}" >> $GITHUB_OUTPUT

Build:
build:
needs: gen_chunks
name: ${{matrix.chip}}-Build#${{matrix.chunks}}
runs-on: ubuntu-latest
Expand All @@ -82,11 +83,65 @@ jobs:
path: |
~/.build_skipped
~/.arduino/tests/**/build*.tmp/*.bin
~/.arduino/tests/**/build*.tmp/*.elf
~/.arduino/tests/**/build*.tmp/*.json

Test:
needs: [gen_chunks, Build]
name: ${{matrix.chip}}-Test#${{matrix.chunks}}
wokwi-test:
needs: [gen_chunks, build]
if: github.event_name == 'schedule'
name: ${{matrix.chip}}-Wokwi_Test#${{matrix.chunks}}
strategy:
fail-fast: false
matrix:
chip: ['esp32', 'esp32s2', 'esp32s3', 'esp32c3', 'esp32c6', 'esp32h2']
chunks: ${{fromJson(needs.gen_chunks.outputs.chunks)}}
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Download ${{matrix.chip}}-${{matrix.chunks}} artifacts
uses: actions/download-artifact@v4
with:
name: ${{matrix.chip}}-${{matrix.chunks}}.artifacts
path: ~/

- name: Install Wokwi CLI
run: curl -L https://wokwi.com/ci/install.sh | sh

- name: Install dependencies
run: |
pip install -U pip
pip install -r tests/requirements.txt --extra-index-url https://dl.espressif.com/pypi
sudo apt update && sudo apt install -y -qq jq

- name: Run Tests
env:
WOKWI_CLI_TOKEN: ${{ secrets.WOKWI_CLI_TOKEN }}
run: |
bash .github/scripts/tests_run.sh -c -t ${{matrix.chip}} -i ${{matrix.chunks}} -m ${{env.MAX_CHUNKS}} -w ${{env.WOKWI_TIMEOUT}}

- name: Check if tests were skipped
id: check-test-skipped
run: |
if [ -f ~/.test_skipped ]; then
echo "skipped=true" >> $GITHUB_OUTPUT
else
echo "skipped=false" >> $GITHUB_OUTPUT
fi

- name: Upload test result artifacts
uses: actions/upload-artifact@v4
if: ${{ always() && steps.check-test-skipped.outputs.skipped == 'false' }}
with:
name: wokwi_results-${{matrix.chip}}-${{matrix.chunks}}
path: tests/**/*.xml

hardware-test:
needs: [gen_chunks, build]
name: ${{matrix.chip}}-Hardware_Test#${{matrix.chunks}}
if: |
contains(github.event.pull_request.labels.*.name, 'hil_test') || github.event_name == 'schedule'
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -130,7 +185,7 @@ jobs:
uses: actions/upload-artifact@v4
if: ${{ always() && steps.check-test-skipped.outputs.skipped == 'false' }}
with:
name: test_results-${{matrix.chip}}-${{matrix.chunks}}
name: hw_results-${{matrix.chip}}-${{matrix.chunks}}
if-no-files-found: error
path: |
tests/**/*.xml
Expand All @@ -142,11 +197,12 @@ jobs:
contains(github.event.pull_request.labels.*.name, 'hil_test') ||
contains(github.event.pull_request.labels.*.name, 'perf_test') ||
github.event_name == 'schedule'
needs: Test
needs: hardware-test
runs-on: ubuntu-latest
steps:
- name: Upload
uses: actions/upload-artifact@v4
with:
name: Event File
path: ${{github.event_path}}

2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Unit Test Results

on:
workflow_run:
workflows: [Run tests in hardware]
workflows: [Run tests]
branches-ignore: [master]

types:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/wokwi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ concurrency:

jobs:
gen_chunks:
if: github.event.workflow_run.event == 'pull_request'
if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success'
name: Generate Chunks matrix
runs-on: ubuntu-latest
outputs:
Expand Down
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
2 changes: 1 addition & 1 deletion tests/pytest.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[pytest]
addopts = --embedded-services esp,arduino
addopts = --embedded-services esp,arduino,wokwi

# log related
log_cli = True
Expand Down
5 changes: 3 additions & 2 deletions tests/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
cryptography>=2.1.4
--only-binary cryptography
pytest-cov
pytest-embedded-serial-esp>=1.10.0
pytest-embedded-arduino>=1.10.0
pytest-embedded-serial-esp>=1.10.2
pytest-embedded-arduino>=1.10.2
pytest-embedded-wokwi>=1.10.2
Empty file.
Empty file.
28 changes: 28 additions & 0 deletions tests/validation/gpio/esp32.diagram.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"version": 1,
"author": "P-R-O-C-H-Y",
"editor": "wokwi",
"parts": [
{
"type": "board-esp32-devkit-c-v4",
"id": "esp32",
"top": -57.6,
"left": -177.56,
"attrs": {}
},
{
"type": "wokwi-pushbutton",
"id": "btn1",
"top": -13,
"left": -19.2,
"attrs": { "color": "green" }
}
],
"connections": [
[ "esp32:RX", "$serialMonitor:TX", "", [] ],
[ "esp32:TX", "$serialMonitor:RX", "", [] ],
[ "btn1:1.l", "esp32:0", "blue", [ "h-19.2", "v48", "h-38.4" ] ],
[ "btn1:2.r", "esp32:GND.1", "black", [ "h19.4", "v173", "h-269.2", "v-98.23" ] ]
],
"dependencies": {}
}
28 changes: 28 additions & 0 deletions tests/validation/gpio/esp32c3.diagram.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"version": 1,
"author": "P-R-O-C-H-Y",
"editor": "wokwi",
"parts": [
{
"type": "board-esp32-c3-devkitm-1",
"id": "esp32",
"top": -57.6,
"left": -177.56,
"attrs": {}
},
{
"type": "wokwi-pushbutton",
"id": "btn1",
"top": -22.6,
"left": -19.2,
"attrs": { "color": "green" }
}
],
"connections": [
[ "esp32:RX", "$serialMonitor:TX", "", [] ],
[ "esp32:TX", "$serialMonitor:RX", "", [] ],
[ "btn1:1.l", "esp32:0", "blue", [ "h-28.8", "v144", "h-144", "v-95.7" ] ],
[ "btn1:2.r", "esp32:GND.1", "black", [ "h19.4", "v173", "h-269.2", "v-98.23" ] ]
],
"dependencies": {}
}
28 changes: 28 additions & 0 deletions tests/validation/gpio/esp32c6.diagram.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"version": 1,
"author": "P-R-O-C-H-Y",
"editor": "wokwi",
"parts": [
{
"type": "board-esp32-c6-devkitc-1",
"id": "esp32",
"top": -57.6,
"left": -177.56,
"attrs": {}
},
{
"type": "wokwi-pushbutton",
"id": "btn1",
"top": -22.6,
"left": -19.2,
"attrs": { "color": "green" }
}
],
"connections": [
[ "esp32:RX", "$serialMonitor:TX", "", [] ],
[ "esp32:TX", "$serialMonitor:RX", "", [] ],
[ "btn1:1.l", "esp32:0", "blue", [ "h-19.2", "v-96", "h-163.2", "v93.77" ] ],
[ "btn1:2.r", "esp32:GND.1", "black", [ "h19.4", "v173", "h-269.2", "v-98.23" ] ]
],
"dependencies": {}
}
28 changes: 28 additions & 0 deletions tests/validation/gpio/esp32h2.diagram.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"version": 1,
"author": "P-R-O-C-H-Y",
"editor": "wokwi",
"parts": [
{
"type": "board-esp32-h2-devkitm-1",
"id": "esp32",
"top": -57.6,
"left": -177.56,
"attrs": {}
},
{
"type": "wokwi-pushbutton",
"id": "btn1",
"top": -22.6,
"left": -19.2,
"attrs": { "color": "green" }
}
],
"connections": [
[ "esp32:RX", "$serialMonitor:TX", "", [] ],
[ "esp32:TX", "$serialMonitor:RX", "", [] ],
[ "btn1:1.l", "esp32:0", "blue", [ "h-19.2", "v-96", "h-163.2", "v93.77" ] ],
[ "btn1:2.r", "esp32:GND.1", "black", [ "h19.4", "v173", "h-269.2", "v-98.23" ] ]
],
"dependencies": {}
}
28 changes: 28 additions & 0 deletions tests/validation/gpio/esp32s2.diagram.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"version": 1,
"author": "P-R-O-C-H-Y",
"editor": "wokwi",
"parts": [
{
"type": "board-esp32-s2-devkitm-1",
"id": "esp32",
"top": -57.6,
"left": -177.56,
"attrs": {}
},
{
"type": "wokwi-pushbutton",
"id": "btn1",
"top": -22.6,
"left": -19.2,
"attrs": { "color": "green" }
}
],
"connections": [
[ "esp32:RX", "$serialMonitor:TX", "", [] ],
[ "esp32:TX", "$serialMonitor:RX", "", [] ],
[ "btn1:1.l", "esp32:0", "blue", [ "h-28.8", "v-57.6", "h-144", "v42.71" ] ],
[ "btn1:2.r", "esp32:GND.1", "black", [ "h19.4", "v173", "h-269.2", "v-98.23" ] ]
],
"dependencies": {}
}
28 changes: 28 additions & 0 deletions tests/validation/gpio/esp32s3.diagram.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"version": 1,
"author": "P-R-O-C-H-Y",
"editor": "wokwi",
"parts": [
{
"type": "board-esp32-s3-devkitc-1",
"id": "esp32",
"top": -57.6,
"left": -177.56,
"attrs": {}
},
{
"type": "wokwi-pushbutton",
"id": "btn1",
"top": -22.6,
"left": -19.2,
"attrs": { "color": "green" }
}
],
"connections": [
[ "esp32:RX", "$serialMonitor:TX", "", [] ],
[ "esp32:TX", "$serialMonitor:RX", "", [] ],
[ "btn1:1.l", "esp32:0", "blue", [ "h-38.4", "v105.78" ] ],
[ "btn1:2.r", "esp32:GND.1", "black", [ "h19.4", "v221", "h-269.2", "v-57.42" ] ]
],
"dependencies": {}
}