|
| 1 | +# SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors |
| 2 | +# SPDX-License-Identifier: MIT |
| 3 | + |
| 4 | +name: Playwright |
| 5 | + |
| 6 | +on: pull_request |
| 7 | + |
| 8 | +concurrency: |
| 9 | + group: playwright-${{ github.head_ref || github.run_id }} |
| 10 | + cancel-in-progress: true |
| 11 | + |
| 12 | +permissions: |
| 13 | + contents: read |
| 14 | + |
| 15 | +env: |
| 16 | + APP_NAME: ${{ github.event.repository.name }} |
| 17 | + BRANCH: ${{ github.base_ref || github.ref_name }} |
| 18 | + |
| 19 | +jobs: |
| 20 | + playwright: |
| 21 | + runs-on: ubuntu-latest |
| 22 | + |
| 23 | + name: Playwright E2E tests |
| 24 | + |
| 25 | + steps: |
| 26 | + - name: Disabled on forks |
| 27 | + if: ${{ github.event.pull_request.head.repo.full_name != github.repository }} |
| 28 | + run: | |
| 29 | + echo 'Can not run Playwright on forks' |
| 30 | + exit 1 |
| 31 | +
|
| 32 | + - name: Checkout app |
| 33 | + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 34 | + with: |
| 35 | + persist-credentials: false |
| 36 | + |
| 37 | + - name: Check composer.json |
| 38 | + id: check_composer |
| 39 | + uses: andstor/file-existence-action@558493d6c74bf472d87c84eab196434afc2fa029 # v3.1.0 |
| 40 | + with: |
| 41 | + files: 'composer.json' |
| 42 | + |
| 43 | + - name: Install composer dependencies |
| 44 | + if: steps.check_composer.outputs.files_exists == 'true' |
| 45 | + run: composer install --no-dev |
| 46 | + |
| 47 | + - name: Read package.json node and npm engines version |
| 48 | + uses: skjnldsv/read-package-engines-version-actions@06d6baf7d8f41934ab630e97d9e6c0bc9c9ac5e4 # v3 |
| 49 | + id: versions |
| 50 | + with: |
| 51 | + fallbackNode: '^24' |
| 52 | + fallbackNpm: '^11' |
| 53 | + |
| 54 | + - name: Set up node ${{ steps.versions.outputs.nodeVersion }} |
| 55 | + uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 |
| 56 | + with: |
| 57 | + node-version: ${{ steps.versions.outputs.nodeVersion }} |
| 58 | + |
| 59 | + - name: Set up npm ${{ steps.versions.outputs.npmVersion }} |
| 60 | + run: npm i -g 'npm@${{ steps.versions.outputs.npmVersion }}' |
| 61 | + |
| 62 | + - name: Install dependencies & build app |
| 63 | + run: | |
| 64 | + npm ci |
| 65 | + TESTING=true npm run build --if-present |
| 66 | +
|
| 67 | + - name: Install Playwright browsers |
| 68 | + run: npx playwright install chromium --with-deps |
| 69 | + |
| 70 | + - name: Run Playwright tests |
| 71 | + run: npx playwright test |
| 72 | + env: |
| 73 | + BRANCH: ${{ env.BRANCH }} |
| 74 | + CI: true |
| 75 | + |
| 76 | + - name: Show Nextcloud logs on failure |
| 77 | + if: failure() |
| 78 | + run: | |
| 79 | + docker exec nextcloud-e2e-test-server_${{ env.APP_NAME }} cat data/nextcloud.log || true |
| 80 | +
|
| 81 | + - name: Upload Playwright report |
| 82 | + uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 |
| 83 | + if: ${{ !cancelled() }} |
| 84 | + with: |
| 85 | + name: playwright-report |
| 86 | + path: playwright-report/ |
| 87 | + retention-days: 7 |
| 88 | + if-no-files-found: ignore |
| 89 | + |
| 90 | + - name: Upload Playwright traces |
| 91 | + uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 |
| 92 | + if: failure() |
| 93 | + with: |
| 94 | + name: playwright-traces |
| 95 | + path: test-results/ |
| 96 | + retention-days: 7 |
| 97 | + if-no-files-found: ignore |
| 98 | + |
| 99 | + summary: |
| 100 | + runs-on: ubuntu-latest-low |
| 101 | + needs: playwright |
| 102 | + if: always() |
| 103 | + name: playwright-summary |
| 104 | + steps: |
| 105 | + - name: Summary status |
| 106 | + run: if ${{ needs.playwright.result != 'success' && needs.playwright.result != 'skipped' }}; then exit 1; fi |
0 commit comments