Skip to content

Feat/wokwi ci test #9578

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

Closed
wants to merge 17 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
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="tests/$sketchname/$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
79 changes: 69 additions & 10 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 @@ -7,25 +7,30 @@ on:
schedule:
- cron: '0 2 * * *'

push:
branches:
- master

env:
MAX_CHUNKS: 15
WOKWI_TIMEOUT: 120000 # Milliseconds

concurrency:
group: hil-${{github.event.pull_request.number || github.ref}}
cancel-in-progress: true

jobs:
gen_chunks:
if: |
contains(github.event.pull_request.labels.*.name, 'hil_test') ||
(github.event_name == 'schedule' && github.repository == 'espressif/arduino-esp32')
if: github.repository == 'espressif/arduino-esp32'
name: Generate Chunks matrix
runs-on: ubuntu-latest
outputs:
chunks: ${{ steps.gen-chunks.outputs.chunks }}
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }} # Check out the code of the PR

- name: Generate Chunks matrix
id: gen-chunks
Expand All @@ -41,7 +46,7 @@ jobs:
CHUNKS=$(jq -c -n '$ARGS.positional' --args `seq 0 1 $((sketches - 1))`)
echo "chunks=${CHUNKS}" >>$GITHUB_OUTPUT

Build:
build:
needs: gen_chunks
name: ${{matrix.chip}}-Build#${{matrix.chunks}}
runs-on: ubuntu-latest
Expand All @@ -52,6 +57,9 @@ jobs:
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }} # Check out the code of the PR

- name: Build sketches
run: |
bash .github/scripts/tests_build.sh -c -t ${{matrix.chip}} -i ${{matrix.chunks}} -m ${{env.MAX_CHUNKS}}
Expand All @@ -63,9 +71,60 @@ jobs:
~/.arduino/tests/*/build*.tmp/*.bin
~/.arduino/tests/*/build*.tmp/*.json
if-no-files-found: error
Test:
needs: [gen_chunks, Build]
name: ${{matrix.chip}}-Test#${{matrix.chunks}}

wokwi-test:
needs: [gen_chunks, build]
name: ${{matrix.chip}}-Wokwi_Test#${{matrix.chunks}}
if: |
github.event_name == 'schedule' || github.event_name == 'push' || github.event_name == 'pull_request'
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: ~/.arduino/tests/

- 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
git clone https://github.com/P-R-O-C-H-Y/pytest-embedded.git
cd pytest-embedded
git checkout feature/wokwi-scenario-support
pip install -e pytest-embedded-wokwi
cd ..
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: Upload test result artifacts
uses: actions/upload-artifact@v4
if: always()
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 @@ -100,15 +159,15 @@ jobs:
uses: actions/upload-artifact@v4
if: always()
with:
name: test_results-${{matrix.chip}}-${{matrix.chunks}}
name: hw_results-${{matrix.chip}}-${{matrix.chunks}}
path: tests/*/*.xml

event_file:
name: "Event File"
if: |
contains(github.event.pull_request.labels.*.name, 'hil_test') ||
github.event_name == 'schedule'
needs: Test
needs: hardware-test
runs-on: ubuntu-latest
steps:
- name: Upload
Expand Down
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
Empty file added tests/gpio/.skip.hardware
Empty file.
Empty file added tests/gpio/.skip.qemu
Empty file.
28 changes: 28 additions & 0 deletions tests/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/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/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/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/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/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": {}
}
Loading
Loading