|
| 1 | +# SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors |
| 2 | +# SPDX-License-Identifier: MIT |
| 3 | + |
| 4 | +name: Playwright Tests |
| 5 | + |
| 6 | +on: |
| 7 | + pull_request: |
| 8 | + branches: [ master ] |
| 9 | + |
| 10 | +permissions: |
| 11 | + contents: read |
| 12 | + |
| 13 | +jobs: |
| 14 | + playwright-tests: |
| 15 | + timeout-minutes: 60 |
| 16 | + name: Playwright tests ${{ matrix.shardIndex }} / ${{ matrix.shardTotal }} |
| 17 | + runs-on: ubuntu-latest |
| 18 | + strategy: |
| 19 | + fail-fast: false |
| 20 | + matrix: |
| 21 | + shardIndex: [1, 2, 3] |
| 22 | + shardTotal: [3] |
| 23 | + outputs: |
| 24 | + node-version: ${{ steps.versions.outputs.node-version }} |
| 25 | + package-manager-version: ${{ steps.versions.outputs.package-manager-version }} |
| 26 | + |
| 27 | + steps: |
| 28 | + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 29 | + with: |
| 30 | + persist-credentials: false |
| 31 | + submodules: true # for 3rdparty |
| 32 | + |
| 33 | + - name: Read package.json |
| 34 | + uses: nextcloud-libraries/parse-package-engines-action@122ae05d4257008180a514e1ddeb0c1b9d094bdd # v0.1.0 |
| 35 | + id: versions |
| 36 | + |
| 37 | + - name: Set up node |
| 38 | + uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0 |
| 39 | + with: |
| 40 | + node-version: ${{ steps.versions.outputs.node-version }} |
| 41 | + |
| 42 | + - name: Set up npm |
| 43 | + run: npm i -g 'npm@${{ steps.versions.outputs.package-manager-version }}' |
| 44 | + |
| 45 | + - name: Install dependencies and build |
| 46 | + run: | |
| 47 | + npm ci |
| 48 | + npm run build --if-present |
| 49 | +
|
| 50 | + - name: Install Playwright browsers |
| 51 | + run: npx playwright install --with-deps |
| 52 | + |
| 53 | + - name: Run Playwright tests |
| 54 | + run: npm run playwright -- --shard='${{ matrix.shardIndex }}/${{ matrix.shardTotal }}' |
| 55 | + |
| 56 | + - name: Show logs |
| 57 | + if: failure() |
| 58 | + run: | |
| 59 | + for id in $(docker ps -aq); do |
| 60 | + docker container inspect "$id" --format '=== Logs for container {{.Name}} ===' |
| 61 | + docker logs "$id" >> nextcloud.log |
| 62 | + done |
| 63 | + echo '=== Nextcloud server logs ===' |
| 64 | + docker exec nextcloud-e2e-test-server_server cat data/nextcloud.log |
| 65 | +
|
| 66 | + - name: Upload blob report to GitHub Actions Artifacts |
| 67 | + if: ${{ !cancelled() }} |
| 68 | + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 |
| 69 | + with: |
| 70 | + name: blob-report-${{ matrix.shardIndex }} |
| 71 | + path: blob-report |
| 72 | + retention-days: 1 |
| 73 | + |
| 74 | + merge-reports: |
| 75 | + # Merge reports after playwright-tests, even if some shards have failed |
| 76 | + if: ${{ !cancelled() }} |
| 77 | + needs: [playwright-tests] |
| 78 | + |
| 79 | + runs-on: ubuntu-latest |
| 80 | + steps: |
| 81 | + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 82 | + with: |
| 83 | + persist-credentials: false |
| 84 | + |
| 85 | + - uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0 |
| 86 | + with: |
| 87 | + node-version: ${{ needs.playwright-tests.outputs.node-version }} |
| 88 | + |
| 89 | + - name: Set up npm |
| 90 | + run: npm i -g 'npm@${{ needs.playwright-tests.outputs.package-manager-version }}' |
| 91 | + |
| 92 | + - name: Install dependencies |
| 93 | + run: npm ci |
| 94 | + |
| 95 | + - name: Download blob reports from GitHub Actions Artifacts |
| 96 | + uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0 |
| 97 | + with: |
| 98 | + path: all-blob-reports |
| 99 | + pattern: blob-report-* |
| 100 | + merge-multiple: true |
| 101 | + |
| 102 | + - name: Merge into HTML Report |
| 103 | + run: npx playwright merge-reports --config tests/playwright/merge.config.ts --reporter html,github ./all-blob-reports |
| 104 | + |
| 105 | + - name: Upload HTML report |
| 106 | + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 |
| 107 | + with: |
| 108 | + name: html-report--attempt-${{ github.run_attempt }} |
| 109 | + path: playwright-report |
| 110 | + retention-days: 7 |
| 111 | + |
| 112 | + - name: Show the logs |
| 113 | + run: | |
| 114 | + echo 'To view the report:' |
| 115 | + echo ' 1. Extract the folder from the zip file' |
| 116 | + echo ' 2. run "npx playwright show-report name-of-my-extracted-playwright-report"' |
| 117 | +
|
| 118 | + summary: |
| 119 | + permissions: |
| 120 | + contents: none |
| 121 | + runs-on: ubuntu-latest-low |
| 122 | + needs: [playwright-tests] |
| 123 | + |
| 124 | + if: always() |
| 125 | + |
| 126 | + name: playwright-test-summary |
| 127 | + |
| 128 | + steps: |
| 129 | + - name: Summary status |
| 130 | + run: if ${{ needs.playwright-tests.result != 'success' }}; then exit 1; fi |
0 commit comments