Add Wokwi ESP32 simulator CI workflow with Playwright web interface testing, boot validation scenarios, and complete flash image support #6
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: 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 | |
| # Create log directory | |
| mkdir -p logs | |
| # Start simulator in background with a 180 second timeout | |
| WOKWI_TIMEOUT=180 ./run-simulator.sh > logs/wokwi.log 2>&1 & | |
| WOKWI_PID=$! | |
| echo "WOKWI_PID=$WOKWI_PID" >> $GITHUB_ENV | |
| echo "Started Wokwi simulator with PID $WOKWI_PID" | |
| # Wait for simulator to start and web server to be ready | |
| echo "Waiting for WLED web server to be ready..." | |
| max_wait=120 | |
| elapsed=0 | |
| while [ $elapsed -lt $max_wait ]; do | |
| if curl -s -f http://localhost:8080 > /dev/null 2>&1; then | |
| echo "Web server is ready after $elapsed seconds!" | |
| break | |
| fi | |
| if ! kill -0 $WOKWI_PID 2>/dev/null; then | |
| echo "Error: Wokwi simulator process died" | |
| echo "Last 50 lines of Wokwi log:" | |
| tail -50 logs/wokwi.log || true | |
| exit 1 | |
| fi | |
| echo "Still waiting... ($elapsed seconds)" | |
| sleep 5 | |
| elapsed=$((elapsed + 5)) | |
| done | |
| if [ $elapsed -ge $max_wait ]; then | |
| echo "Error: Web server did not start within $max_wait seconds" | |
| echo "Last 50 lines of Wokwi log:" | |
| tail -50 logs/wokwi.log || true | |
| kill $WOKWI_PID || true | |
| exit 1 | |
| fi | |
| echo "WLED is ready for testing!" | |
| - 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/wokwi/logs/ | |
| test-results/ | |
| playwright-report/ | |
| retention-days: 7 |