ci(wokwi): Add Wokwi emulator to workflow #6799
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Run tests | |
on: | |
pull_request: | |
types: [opened, reopened, synchronize, labeled] | |
schedule: | |
- cron: '0 2 * * *' | |
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: github.repository == 'espressif/arduino-esp32' || contains(github.event.pull_request.labels.*.name, 'run_tests') | |
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 | |
run: | | |
set +e | |
.github/scripts/sketch_utils.sh count tests | |
sketches=$? | |
if [[ $sketches -ge ${{env.MAX_CHUNKS}} ]]; then | |
$sketches=${{env.MAX_CHUNKS}} | |
fi | |
set -e | |
rm sketches.txt | |
CHUNKS=$(jq -c -n '$ARGS.positional' --args `seq 0 1 $((sketches - 1))`) | |
echo "chunks=${CHUNKS}" >>$GITHUB_OUTPUT | |
build: | |
needs: gen_chunks | |
name: ${{matrix.chip}}-Build#${{matrix.chunks}} | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
chip: ['esp32', 'esp32s2', 'esp32s3', 'esp32c3', 'esp32c6', 'esp32h2'] | |
chunks: ${{fromJson(needs.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: Build sketches | |
run: | | |
bash .github/scripts/tests_build.sh -c -t ${{matrix.chip}} -i ${{matrix.chunks}} -m ${{env.MAX_CHUNKS}} | |
- name: Upload ${{matrix.chip}}-${{matrix.chunks}} artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{matrix.chip}}-${{matrix.chunks}}.artifacts | |
path: | | |
~/.arduino/tests/*/build*.tmp/*.bin | |
~/.arduino/tests/*/build*.tmp/*.json | |
if-no-files-found: error | |
wokwi-test: | |
needs: [gen_chunks, build] | |
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: ~/.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: | |
chip: ['esp32', 'esp32s2', 'esp32s3', 'esp32c3', 'esp32c6', 'esp32h2'] | |
chunks: ${{fromJson(needs.gen_chunks.outputs.chunks)}} | |
runs-on: [arduino, "${{matrix.chip}}"] | |
container: | |
image: python:3.10.1-bullseye | |
options: --privileged | |
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 dependencies | |
run: | | |
pip install -U pip | |
pip install -r tests/requirements.txt --extra-index-url https://dl.espressif.com/pypi | |
apt update && apt install -y -qq jq | |
- name: Run Tests | |
run: | | |
bash .github/scripts/tests_run.sh -c -t ${{matrix.chip}} -i ${{matrix.chunks}} -m ${{env.MAX_CHUNKS}} -e | |
- name: Upload test result artifacts | |
uses: actions/upload-artifact@v4 | |
if: always() | |
with: | |
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: hardware-test | |
runs-on: ubuntu-latest | |
steps: | |
- name: Upload | |
uses: actions/upload-artifact@v4 | |
with: | |
name: Event File | |
path: ${{github.event_path}} | |