Live Widget Tests #94
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: Live Widget Tests | |
| on: | |
| workflow_call: | |
| inputs: | |
| target: | |
| required: true | |
| type: string | |
| workflow_dispatch: | |
| inputs: | |
| target: | |
| required: true | |
| type: string | |
| default: preview | |
| schedule: | |
| - cron: '0 6 * * *' | |
| jobs: | |
| live-tests: | |
| name: Live E2E Tests | |
| runs-on: ubuntu-latest | |
| env: | |
| LIVE_TARGET: ${{ github.event_name == 'schedule' && 'production' || inputs.target || 'preview' }} | |
| PLAYWRIGHT_BASE_URL: ${{ (github.event_name == 'schedule' || inputs.target == 'production') && 'https://bugdrop-widget-test.vercel.app' || 'https://bugdrop-widget-test-git-preview-jermwatts-projects.vercel.app' }} | |
| steps: | |
| - uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| - uses: actions/setup-node@v5 | |
| with: | |
| node-version: '22' | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: make install | |
| - name: Install Playwright | |
| run: make install-playwright | |
| - name: Wait for widget deployment | |
| run: | | |
| if [ "$LIVE_TARGET" = "preview" ]; then | |
| WORKER_URL="https://bugdrop-preview.neonwatty.workers.dev/api/health" | |
| else | |
| WORKER_URL="https://bugdrop.neonwatty.workers.dev/api/health" | |
| fi | |
| echo "Polling $WORKER_URL until ready..." | |
| for i in $(seq 1 30); do | |
| if curl -sfo /dev/null "$WORKER_URL"; then | |
| echo "$LIVE_TARGET worker ready after $((i * 10))s" | |
| exit 0 | |
| fi | |
| echo "Attempt $i/30 — not ready, waiting 10s..." | |
| sleep 10 | |
| done | |
| echo "$LIVE_TARGET worker not ready after 300s" | |
| exit 1 | |
| - name: Verify test venue is reachable | |
| run: | | |
| VENUE_URL="${PLAYWRIGHT_BASE_URL}" | |
| echo "Checking test venue at $VENUE_URL..." | |
| BYPASS_ARGS=() | |
| if [ -n "$VERCEL_AUTOMATION_BYPASS_SECRET" ]; then | |
| BYPASS_ARGS=(-H "x-vercel-protection-bypass:${VERCEL_AUTOMATION_BYPASS_SECRET}") | |
| fi | |
| curl -sfo /dev/null "${BYPASS_ARGS[@]}" "$VENUE_URL" || (echo "Test venue unreachable at $VENUE_URL" && exit 1) | |
| echo "Test venue reachable" | |
| env: | |
| VERCEL_AUTOMATION_BYPASS_SECRET: ${{ secrets.VERCEL_AUTOMATION_BYPASS_SECRET }} | |
| - name: Record expected widget asset | |
| run: | | |
| if [ "$LIVE_TARGET" = "preview" ]; then | |
| VERSION=$(git describe --tags --abbrev=0) npm run build:widget | |
| echo "EXPECTED_WIDGET_ORIGIN=https://bugdrop-preview.neonwatty.workers.dev" >> "$GITHUB_ENV" | |
| echo "EXPECTED_WIDGET_SHA256=$(shasum -a 256 public/widget.js | awk '{print $1}')" >> "$GITHUB_ENV" | |
| else | |
| echo "EXPECTED_WIDGET_ORIGIN=https://bugdrop.neonwatty.workers.dev" >> "$GITHUB_ENV" | |
| fi | |
| - name: Wait for expected preview widget asset | |
| if: env.LIVE_TARGET == 'preview' | |
| run: | | |
| WIDGET_URL="https://bugdrop-preview.neonwatty.workers.dev/widget.js" | |
| echo "Waiting for $WIDGET_URL to serve $EXPECTED_WIDGET_SHA256..." | |
| for i in $(seq 1 30); do | |
| ACTUAL_SHA="$(curl -sSf "$WIDGET_URL" | shasum -a 256 | awk '{print $1}')" | |
| if [ "$ACTUAL_SHA" = "$EXPECTED_WIDGET_SHA256" ]; then | |
| echo "Preview widget asset matched after $((i * 5))s" | |
| exit 0 | |
| fi | |
| echo "Attempt $i/30 served $ACTUAL_SHA; waiting 5s..." | |
| sleep 5 | |
| done | |
| echo "Preview widget did not serve expected asset $EXPECTED_WIDGET_SHA256" | |
| exit 1 | |
| - name: Run live E2E tests | |
| run: npx playwright test --project=chromium-live --workers=1 | |
| env: | |
| VERCEL_AUTOMATION_BYPASS_SECRET: ${{ secrets.VERCEL_AUTOMATION_BYPASS_SECRET }} | |
| - name: Upload test report | |
| uses: actions/upload-artifact@v5 | |
| if: failure() | |
| with: | |
| name: playwright-live-report | |
| path: playwright-report/ | |
| retention-days: 7 |