|
| 1 | +# This workflow is provided via the organization template repository |
| 2 | +# |
| 3 | +# https://github.com/nextcloud/.github |
| 4 | +# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization |
| 5 | +# |
| 6 | +# SPDX-FileCopyrightText: 2023-2024 Nextcloud GmbH and Nextcloud contributors |
| 7 | +# SPDX-License-Identifier: MIT |
| 8 | + |
| 9 | +name: Playwright |
| 10 | + |
| 11 | +on: pull_request |
| 12 | + |
| 13 | +concurrency: |
| 14 | + group: playwright-${{ github.head_ref || github.run_id }} |
| 15 | + cancel-in-progress: true |
| 16 | + |
| 17 | +permissions: |
| 18 | + contents: read |
| 19 | + |
| 20 | +env: |
| 21 | + APP_NAME: ${{ github.event.repository.name }} |
| 22 | + BRANCH: ${{ github.base_ref || github.ref_name }} |
| 23 | + |
| 24 | +jobs: |
| 25 | + playwright: |
| 26 | + runs-on: ubuntu-latest |
| 27 | + |
| 28 | + name: Playwright E2E tests |
| 29 | + |
| 30 | + steps: |
| 31 | + - name: Checkout app |
| 32 | + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 33 | + with: |
| 34 | + persist-credentials: false |
| 35 | + |
| 36 | + - name: Read package.json node and npm engines version |
| 37 | + uses: skjnldsv/read-package-engines-version-actions@06d6baf7d8f41934ab630e97d9e6c0bc9c9ac5e4 # v3 |
| 38 | + id: versions |
| 39 | + with: |
| 40 | + fallbackNode: '^24' |
| 41 | + fallbackNpm: '^11' |
| 42 | + |
| 43 | + - name: Set up node ${{ steps.versions.outputs.nodeVersion }} |
| 44 | + uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6.5.0 |
| 45 | + with: |
| 46 | + node-version: ${{ steps.versions.outputs.nodeVersion }} |
| 47 | + |
| 48 | + - name: Set up npm ${{ steps.versions.outputs.npmVersion }} |
| 49 | + run: npm i -g 'npm@${{ steps.versions.outputs.npmVersion }}' |
| 50 | + |
| 51 | + - name: Install dependencies |
| 52 | + run: npm ci |
| 53 | + |
| 54 | + - name: Install Playwright browsers |
| 55 | + run: npx playwright install chromium --with-deps |
| 56 | + |
| 57 | + - name: Build app |
| 58 | + run: TESTING=true npm run build --if-present |
| 59 | + |
| 60 | + - name: Run Playwright tests |
| 61 | + run: npx playwright test |
| 62 | + env: |
| 63 | + BRANCH: ${{ env.BRANCH }} |
| 64 | + CI: true |
| 65 | + |
| 66 | + - name: Show Nextcloud logs on failure |
| 67 | + if: failure() |
| 68 | + run: | |
| 69 | + docker exec nextcloud-e2e-test-server_${{ env.APP_NAME }} cat data/nextcloud.log || true |
| 70 | +
|
| 71 | + - name: Upload blob report |
| 72 | + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 |
| 73 | + if: ${{ !cancelled() }} |
| 74 | + with: |
| 75 | + name: blob-report |
| 76 | + path: blob-report/ |
| 77 | + retention-days: 1 |
| 78 | + |
| 79 | + - name: Upload Playwright traces |
| 80 | + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 |
| 81 | + if: failure() |
| 82 | + with: |
| 83 | + name: playwright-traces |
| 84 | + path: test-results/ |
| 85 | + retention-days: 7 |
| 86 | + |
| 87 | + merge-reports: |
| 88 | + if: ${{ !cancelled() }} |
| 89 | + needs: playwright |
| 90 | + runs-on: ubuntu-latest |
| 91 | + |
| 92 | + steps: |
| 93 | + - name: Checkout app |
| 94 | + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 95 | + with: |
| 96 | + persist-credentials: false |
| 97 | + |
| 98 | + - name: Read package.json node and npm engines version |
| 99 | + uses: skjnldsv/read-package-engines-version-actions@06d6baf7d8f41934ab630e97d9e6c0bc9c9ac5e4 # v3 |
| 100 | + id: versions |
| 101 | + with: |
| 102 | + fallbackNode: '^24' |
| 103 | + fallbackNpm: '^11' |
| 104 | + |
| 105 | + - name: Set up node ${{ steps.versions.outputs.nodeVersion }} |
| 106 | + uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6.5.0 |
| 107 | + with: |
| 108 | + node-version: ${{ steps.versions.outputs.nodeVersion }} |
| 109 | + |
| 110 | + - name: Set up npm ${{ steps.versions.outputs.npmVersion }} |
| 111 | + run: npm i -g 'npm@${{ needs.playwright.outputs.npmVersion }}' |
| 112 | + |
| 113 | + - name: Install dependencies |
| 114 | + run: npm ci |
| 115 | + |
| 116 | + - name: Download blob report |
| 117 | + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 |
| 118 | + with: |
| 119 | + name: blob-report |
| 120 | + path: blob-report |
| 121 | + |
| 122 | + - name: Merge into HTML report |
| 123 | + run: npx playwright merge-reports --reporter html ./blob-report |
| 124 | + |
| 125 | + - name: Upload HTML report |
| 126 | + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 |
| 127 | + with: |
| 128 | + name: html-report--attempt-${{ github.run_attempt }} |
| 129 | + path: playwright-report/ |
| 130 | + retention-days: 7 |
| 131 | + |
| 132 | + summary: |
| 133 | + runs-on: ubuntu-latest-low |
| 134 | + needs: playwright |
| 135 | + if: always() |
| 136 | + name: playwright-summary |
| 137 | + steps: |
| 138 | + - name: Summary status |
| 139 | + run: if ${{ needs.playwright.result != 'success' && needs.playwright.result != 'skipped' }}; then exit 1; fi |
0 commit comments