|
| 1 | +name: E2E Tests |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ master, develop ] |
| 6 | + pull_request: |
| 7 | + branches: [ master, develop ] |
| 8 | + |
| 9 | +# One run per PR or branch. A new push cancels the previous run. |
| 10 | +concurrency: |
| 11 | + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} |
| 12 | + cancel-in-progress: true |
| 13 | + |
| 14 | +jobs: |
| 15 | + build: |
| 16 | + runs-on: ubuntu-latest |
| 17 | + steps: |
| 18 | + - uses: actions/checkout@v4 |
| 19 | + - uses: actions/setup-node@v4 |
| 20 | + with: |
| 21 | + node-version: lts/* |
| 22 | + cache: npm |
| 23 | + cache-dependency-path: package-lock.json |
| 24 | + - name: Build Stackable Free Plugin |
| 25 | + run: | |
| 26 | + npm ci --legacy-peer-deps |
| 27 | + npm run build:e2e |
| 28 | + - name: Archive plugin build |
| 29 | + run: tar --exclude=./node_modules --exclude=./.git -czf /tmp/stackable-e2e-build.tar.gz . |
| 30 | + - uses: actions/upload-artifact@v4 |
| 31 | + with: |
| 32 | + name: stackable-e2e-build |
| 33 | + path: /tmp/stackable-e2e-build.tar.gz |
| 34 | + retention-days: 1 |
| 35 | + |
| 36 | + test: |
| 37 | + needs: build |
| 38 | + timeout-minutes: 60 |
| 39 | + runs-on: ubuntu-latest |
| 40 | + strategy: |
| 41 | + fail-fast: false |
| 42 | + matrix: |
| 43 | + include: |
| 44 | + # stackable-playwright-matrix-start |
| 45 | + - php_version: '8.5' |
| 46 | + wp_version: '7.1' |
| 47 | + - php_version: '7.4' |
| 48 | + wp_version: '6.9' |
| 49 | + # stackable-playwright-matrix-end |
| 50 | + name: Free e2e PHP ${{ matrix.php_version }} WP ${{ matrix.wp_version }} |
| 51 | + steps: |
| 52 | + - uses: actions/checkout@v4 |
| 53 | + - uses: actions/setup-node@v4 |
| 54 | + with: |
| 55 | + node-version: lts/* |
| 56 | + cache: npm |
| 57 | + cache-dependency-path: package-lock.json |
| 58 | + - name: Restore plugin build |
| 59 | + uses: actions/download-artifact@v4 |
| 60 | + with: |
| 61 | + name: stackable-e2e-build |
| 62 | + - name: Extract plugin build |
| 63 | + run: tar -xzf stackable-e2e-build.tar.gz |
| 64 | + - name: Install dependencies |
| 65 | + run: npm ci --legacy-peer-deps |
| 66 | + - name: Set the version suffix for the output |
| 67 | + run: echo VERSION_SUFFIX=${GITHUB_REF_NAME//\//-} >> $GITHUB_ENV |
| 68 | + - name: Cache Playwright Browsers |
| 69 | + uses: actions/cache@v4 |
| 70 | + with: |
| 71 | + path: ~/.cache/ms-playwright |
| 72 | + key: ${{ runner.os }}-playwright-${{ hashFiles('package-lock.json') }} |
| 73 | + restore-keys: | |
| 74 | + ${{ runner.os }}-playwright- |
| 75 | + - name: Install Playwright Browsers |
| 76 | + timeout-minutes: 15 |
| 77 | + run: | |
| 78 | + for attempt in 1 2 3; do |
| 79 | + npx playwright install chromium --with-deps && exit 0 |
| 80 | + echo "Playwright install failed on attempt $attempt" |
| 81 | + sleep $((attempt * 30)) |
| 82 | + done |
| 83 | + exit 1 |
| 84 | + - name: Run free Playwright e2e suite |
| 85 | + id: run-playwright-tests |
| 86 | + env: |
| 87 | + WP_PHP_VERSION: ${{ matrix.php_version }} |
| 88 | + WP_VERSION: ${{ matrix.wp_version }} |
| 89 | + run: npm run test:e2e |
| 90 | + - uses: actions/upload-artifact@v4 |
| 91 | + if: ${{ !cancelled() && steps.run-playwright-tests.outcome == 'failure' }} |
| 92 | + id: artifact-upload-step |
| 93 | + with: |
| 94 | + name: playwright-report-php_${{ matrix.php_version }}-wp_${{ matrix.wp_version }}-${{ env.VERSION_SUFFIX }} |
| 95 | + path: playwright-report/ |
| 96 | + overwrite: true |
| 97 | + retention-days: 30 |
| 98 | + - uses: markpatterson27/markdown-to-output@v1 |
| 99 | + id: mto |
| 100 | + if: ${{ !cancelled() && steps.run-playwright-tests.outcome == 'failure' }} |
| 101 | + with: |
| 102 | + filepath: ./playwright-stk/errors.md |
| 103 | + - name: Add test results to summary |
| 104 | + if: ${{ !cancelled() && steps.run-playwright-tests.outcome == 'failure' }} |
| 105 | + run: | |
| 106 | + echo "${{ steps.mto.outputs.body }}" >> $GITHUB_STEP_SUMMARY |
| 107 | + echo "Report: [playwright-report-php_${{ matrix.php_version }}-wp_${{ matrix.wp_version }}-${{ env.VERSION_SUFFIX }}.zip](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts/${{ steps.artifact-upload-step.outputs.artifact-id }})" >> $GITHUB_STEP_SUMMARY |
0 commit comments