|
| 1 | +name: QEMU E2E Testing |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: [ mdev, main ] |
| 6 | + push: |
| 7 | + branches: [ mdev, main ] |
| 8 | + workflow_dispatch: |
| 9 | + |
| 10 | +jobs: |
| 11 | + # Job 1: Build firmware for QEMU testing |
| 12 | + build-firmware: |
| 13 | + name: Build ESP32 Firmware for QEMU |
| 14 | + runs-on: ubuntu-22.04 |
| 15 | + steps: |
| 16 | + - uses: actions/checkout@v4 |
| 17 | + |
| 18 | + - name: Cache pip |
| 19 | + uses: actions/cache@v4 |
| 20 | + with: |
| 21 | + path: ~/.cache/pip |
| 22 | + key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} |
| 23 | + restore-keys: | |
| 24 | + ${{ runner.os }}-pip- |
| 25 | + |
| 26 | + - name: Cache PlatformIO |
| 27 | + uses: actions/cache@v4 |
| 28 | + with: |
| 29 | + path: ~/.platformio |
| 30 | + key: ${{ runner.os }}-pio-esp32dev-${{ hashFiles('**/platformio.ini') }} |
| 31 | + restore-keys: | |
| 32 | + ${{ runner.os }}-pio-esp32dev- |
| 33 | + |
| 34 | + - name: Set up Python |
| 35 | + uses: actions/setup-python@v5 |
| 36 | + with: |
| 37 | + python-version: '3.9' |
| 38 | + |
| 39 | + - name: Set up Node.js |
| 40 | + uses: actions/setup-node@v4 |
| 41 | + with: |
| 42 | + node-version: '20' |
| 43 | + cache: 'npm' |
| 44 | + |
| 45 | + - name: Install PlatformIO |
| 46 | + run: pip install -r requirements.txt |
| 47 | + |
| 48 | + - name: Install Node.js dependencies |
| 49 | + run: npm ci |
| 50 | + |
| 51 | + - name: Build Web UI |
| 52 | + run: npm run build |
| 53 | + |
| 54 | + - name: Build ESP32 firmware |
| 55 | + run: pio run -e esp32dev |
| 56 | + |
| 57 | + - name: Upload firmware artifacts |
| 58 | + uses: actions/upload-artifact@v4 |
| 59 | + with: |
| 60 | + name: esp32-firmware |
| 61 | + path: .pio/build/esp32dev/ |
| 62 | + retention-days: 1 |
| 63 | + |
| 64 | + # Job 2: Test with QEMU |
| 65 | + test-qemu: |
| 66 | + name: QEMU E2E Tests |
| 67 | + runs-on: ubuntu-22.04 |
| 68 | + needs: build-firmware |
| 69 | + timeout-minutes: 45 |
| 70 | + steps: |
| 71 | + - uses: actions/checkout@v4 |
| 72 | + |
| 73 | + - name: Set up Node.js |
| 74 | + uses: actions/setup-node@v4 |
| 75 | + with: |
| 76 | + node-version: '20' |
| 77 | + cache: 'npm' |
| 78 | + |
| 79 | + - name: Download firmware artifacts |
| 80 | + uses: actions/download-artifact@v4 |
| 81 | + with: |
| 82 | + name: esp32-firmware |
| 83 | + path: .pio/build/esp32dev/ |
| 84 | + |
| 85 | + - name: Install Node.js dependencies |
| 86 | + run: npm ci |
| 87 | + |
| 88 | + - name: Install Playwright Browsers |
| 89 | + run: npx playwright install --with-deps chromium |
| 90 | + |
| 91 | + - name: Setup QEMU ESP32 |
| 92 | + run: | |
| 93 | + bash .github/scripts/setup-qemu.sh |
| 94 | + |
| 95 | + - name: Start QEMU with WLED firmware in background |
| 96 | + run: | |
| 97 | + chmod +x .github/scripts/run-qemu.sh |
| 98 | + bash .github/scripts/run-qemu.sh .pio/build/esp32dev qemu-esp32 80 > qemu-output.log 2>&1 & |
| 99 | + echo "Waiting for QEMU to start and WLED to boot..." |
| 100 | + sleep 45 |
| 101 | + |
| 102 | + - name: Check QEMU status |
| 103 | + run: | |
| 104 | + if [ -f qemu.pid ]; then |
| 105 | + QEMU_PID=$(cat qemu.pid) |
| 106 | + if kill -0 $QEMU_PID 2>/dev/null; then |
| 107 | + echo "QEMU is running (PID: $QEMU_PID)" |
| 108 | + else |
| 109 | + echo "QEMU process not running" |
| 110 | + cat qemu-output.log || true |
| 111 | + exit 1 |
| 112 | + fi |
| 113 | + else |
| 114 | + echo "qemu.pid not found" |
| 115 | + cat qemu-output.log || true |
| 116 | + exit 1 |
| 117 | + fi |
| 118 | + |
| 119 | + - name: Test HTTP endpoint |
| 120 | + run: | |
| 121 | + echo "Testing if HTTP server is responding..." |
| 122 | + for i in {1..30}; do |
| 123 | + if curl -f -m 5 http://localhost/ > /dev/null 2>&1; then |
| 124 | + echo "HTTP server is responding!" |
| 125 | + exit 0 |
| 126 | + fi |
| 127 | + echo "Attempt $i failed, waiting..." |
| 128 | + sleep 2 |
| 129 | + done |
| 130 | + echo "HTTP server not responding after 60 seconds" |
| 131 | + cat qemu-output.log || true |
| 132 | + exit 1 |
| 133 | + |
| 134 | + - name: Run Playwright tests against QEMU |
| 135 | + env: |
| 136 | + WLED_BASE_URL: http://localhost |
| 137 | + run: npm run test:e2e |
| 138 | + continue-on-error: true |
| 139 | + |
| 140 | + - name: Upload QEMU logs |
| 141 | + uses: actions/upload-artifact@v4 |
| 142 | + if: always() |
| 143 | + with: |
| 144 | + name: qemu-logs |
| 145 | + path: qemu-output.log |
| 146 | + retention-days: 7 |
| 147 | + |
| 148 | + - name: Upload Playwright report |
| 149 | + uses: actions/upload-artifact@v4 |
| 150 | + if: always() |
| 151 | + with: |
| 152 | + name: playwright-report-qemu |
| 153 | + path: playwright-report/ |
| 154 | + retention-days: 7 |
| 155 | + |
| 156 | + - name: Stop QEMU |
| 157 | + if: always() |
| 158 | + run: | |
| 159 | + if [ -f qemu.pid ]; then |
| 160 | + QEMU_PID=$(cat qemu.pid) |
| 161 | + echo "Stopping QEMU (PID: $QEMU_PID)" |
| 162 | + kill $QEMU_PID || true |
| 163 | + sleep 2 |
| 164 | + kill -9 $QEMU_PID 2>/dev/null || true |
| 165 | + fi |
0 commit comments