|
| 1 | +name: E2E Tests |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + pull_request: |
| 7 | + |
| 8 | +jobs: |
| 9 | + e2e: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + |
| 12 | + steps: |
| 13 | + - name: ⬇️ Checkout repository |
| 14 | + uses: actions/checkout@v4 |
| 15 | + |
| 16 | + - name: ⚙️ Setup Node.js 20 |
| 17 | + uses: actions/setup-node@v4 |
| 18 | + with: |
| 19 | + node-version: 20 |
| 20 | + cache: yarn |
| 21 | + |
| 22 | + - name: 📦 Install dependencies (Yarn) |
| 23 | + run: yarn install |
| 24 | + |
| 25 | + - name: 💾 Cache Playwright browsers |
| 26 | + uses: actions/cache@v4 |
| 27 | + with: |
| 28 | + path: ~/.cache/ms-playwright |
| 29 | + key: playwright-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} |
| 30 | + restore-keys: | |
| 31 | + playwright-${{ runner.os }}- |
| 32 | +
|
| 33 | + - name: 🌐 Install Playwright browsers |
| 34 | + run: cd e2e && yarn add @playwright/test && npx playwright install --with-deps && cd .. |
| 35 | + |
| 36 | + - name: 🔨 Build Next.js app |
| 37 | + env: |
| 38 | + ZITADEL_URL: ${{ secrets.ZITADEL_URL }} |
| 39 | + ZITADEL_SERVICE_USER_ID: ${{ secrets.ZITADEL_SERVICE_USER_ID }} |
| 40 | + ZITADEL_SERVICE_USER_TOKEN: ${{ secrets.ZITADEL_SERVICE_USER_TOKEN }} |
| 41 | + run: | |
| 42 | + set -e |
| 43 | + echo "Creating .env file..." |
| 44 | + echo "ZITADEL_URL=$ZITADEL_URL" >> .env |
| 45 | + echo "ZITADEL_SERVICE_USER_ID=$ZITADEL_SERVICE_USER_ID" >> .env |
| 46 | + echo "ZITADEL_SERVICE_USER_TOKEN=$ZITADEL_SERVICE_USER_TOKEN" >> .env |
| 47 | + yarn build |
| 48 | + echo "Build completed successfully" |
| 49 | +
|
| 50 | + - name: 🚀 Start app in background on port 3333 |
| 51 | + run: | |
| 52 | + PORT=3333 yarn start & |
| 53 | + echo "Deployment completed successfully" |
| 54 | +
|
| 55 | + - name: ⏳ Wait for app to be ready |
| 56 | + run: npx wait-on http://localhost:3333 |
| 57 | + |
| 58 | + - name: ✅ Run Playwright E2E tests |
| 59 | + run: cd e2e && yarn test && cd .. |
| 60 | + |
| 61 | + - name: 📦 Upload Playwright report |
| 62 | + uses: actions/upload-artifact@v4 |
| 63 | + if: ${{ !cancelled() }} |
| 64 | + with: |
| 65 | + name: playwright-report |
| 66 | + path: playwright-report/ |
| 67 | + retention-days: 30 |
0 commit comments