|
| 1 | +name: "CI" |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - main |
| 8 | + - 'releases/*' |
| 9 | + workflow_dispatch: |
| 10 | + schedule: |
| 11 | + - cron: '40 0 * * *' # Runs daily at 00:40 UTC |
| 12 | + |
| 13 | +jobs: |
| 14 | + test-linux: |
| 15 | + name: Playwright@${{ matrix.playwright }} on ${{ matrix.os }} (headless=${{ matrix.headless }}) |
| 16 | + runs-on: ubuntu-20.04 # Specify the Ubuntu version you prefer |
| 17 | + |
| 18 | + strategy: |
| 19 | + fail-fast: false |
| 20 | + matrix: |
| 21 | + playwright: [1.8.0, 1.12.0, 1.18.0, next, beta] |
| 22 | + headless: [true, false] |
| 23 | + exclude: |
| 24 | + # Add any exclusions if certain Playwright versions are incompatible |
| 25 | + # For example, if headful mode isn't supported in older versions: |
| 26 | + - playwright: 1.8.0 |
| 27 | + headless: false |
| 28 | + - playwright: 1.12.0 |
| 29 | + headless: false |
| 30 | + |
| 31 | + steps: |
| 32 | + # 1. Checkout the repository |
| 33 | + - uses: actions/checkout@v3 |
| 34 | + |
| 35 | + # 2. Setup Node.js |
| 36 | + - name: Setup Node.js |
| 37 | + uses: actions/setup-node@v3 |
| 38 | + with: |
| 39 | + node-version: 18 # Ensure this matches your project's Node.js version |
| 40 | + |
| 41 | + # 3. Setup pnpm |
| 42 | + - name: Setup pnpm |
| 43 | + uses: pnpm/action-setup@v2 |
| 44 | + with: |
| 45 | + version: 7.x # Specify the pnpm version you want to use |
| 46 | + |
| 47 | + # 4. Cache pnpm dependencies |
| 48 | + - name: Cache pnpm dependencies |
| 49 | + uses: actions/cache@v3 |
| 50 | + with: |
| 51 | + path: ~/.pnpm-store |
| 52 | + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} |
| 53 | + restore-keys: | |
| 54 | + ${{ runner.os }}-pnpm-store- |
| 55 | +
|
| 56 | + # 5. Install dependencies |
| 57 | + - name: Install dependencies |
| 58 | + run: pnpm install |
| 59 | + |
| 60 | + # 6. Build the idb-cache-app |
| 61 | + - name: Build idb-cache-app |
| 62 | + run: pnpm --filter idb-cache-app build |
| 63 | + |
| 64 | + # 7. Serve the idb-cache-app |
| 65 | + - name: Serve idb-cache-app |
| 66 | + run: pnpm --filter idb-cache-app preview -- --port 3000 & |
| 67 | + # The '&' runs the serve command in the background |
| 68 | + |
| 69 | + # 8. Wait for the server to be ready |
| 70 | + - name: Wait for idb-cache-app to be ready |
| 71 | + run: | |
| 72 | + for i in {1..60}; do |
| 73 | + if curl -s http://localhost:3000 > /dev/null; then |
| 74 | + echo "Server is ready!" |
| 75 | + break |
| 76 | + fi |
| 77 | + echo "Waiting for server to be ready... ($i/60)" |
| 78 | + sleep 1 |
| 79 | + done |
| 80 | +
|
| 81 | + # 9. Install Playwright with the specified version |
| 82 | + - name: Install Playwright |
| 83 | + run: | |
| 84 | + pnpm add -D playwright@${{ matrix.playwright }} |
| 85 | + npx playwright install |
| 86 | +
|
| 87 | + # 10. Run Playwright tests in headless mode |
| 88 | + - name: Run Playwright tests (Headless) |
| 89 | + if: ${{ matrix.headless == true }} |
| 90 | + run: npx playwright test |
| 91 | + |
| 92 | + # 11. Run Playwright tests in headful mode on Linux |
| 93 | + - name: Run Playwright tests (Headful) |
| 94 | + if: ${{ matrix.headless == false }} |
| 95 | + run: | |
| 96 | + export HEADFUL=true |
| 97 | + xvfb-run --auto-servernum -- npx playwright test |
0 commit comments