Skip to content

Add Wokwi ESP32 simulation testing with Playwright #1

Add Wokwi ESP32 simulation testing with Playwright

Add Wokwi ESP32 simulation testing with Playwright #1

Workflow file for this run

name: Wokwi ESP32 Simulation Test
on:
push:
branches: [ "mdev", "copilot/**" ]
pull_request:
branches: [ "mdev" ]
workflow_dispatch:
jobs:
wokwi-test:
name: Test WLED with Wokwi Simulator
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Cache pip
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Cache PlatformIO
uses: actions/cache@v4
with:
path: ~/.platformio
key: ${{ runner.os }}-pio-esp32dev_compat
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.9'
- name: Install PlatformIO
run: pip install -r requirements.txt
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install Node.js dependencies
run: npm ci
- name: Build web UI
run: npm run build
- name: Build firmware for ESP32
env:
WLED_RELEASE: True
run: pio run -e esp32dev_compat
- name: Install Wokwi CLI
run: curl -L https://wokwi.com/ci/install.sh | sh
- name: Prepare firmware for Wokwi
run: ./test/wokwi/prepare-firmware.sh esp32dev_compat
- name: Install Playwright browsers
run: npx playwright install --with-deps chromium
- name: Start Wokwi simulator in background
run: |
cd test/wokwi
# Start simulator in background
./run-simulator.sh &
WOKWI_PID=$!
echo "WOKWI_PID=$WOKWI_PID" >> $GITHUB_ENV
# Wait for simulator to start and web server to be ready
echo "Waiting for WLED web server to be ready..."
timeout=60
elapsed=0
while [ $elapsed -lt $timeout ]; do
if curl -s http://localhost:8080 > /dev/null 2>&1; then
echo "Web server is ready!"
break
fi
echo "Waiting... ($elapsed seconds)"
sleep 2
elapsed=$((elapsed + 2))
done
if [ $elapsed -ge $timeout ]; then
echo "Error: Web server did not start within $timeout seconds"
exit 1
fi
- name: Run Playwright tests
run: npm run test:wokwi
env:
CI: true
- name: Upload Playwright report
uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-report
path: playwright-report/
retention-days: 7
- name: Stop Wokwi simulator
if: always()
run: |
if [ ! -z "$WOKWI_PID" ]; then
kill $WOKWI_PID || true
fi
- name: Upload test results
uses: actions/upload-artifact@v4
if: always()
with:
name: wokwi-test-results
path: |
test-results/
playwright-report/
retention-days: 7