From 13584282c47ae88a3916090381db9b3c1eeba72c Mon Sep 17 00:00:00 2001 From: Louis Chmn Date: Fri, 28 Aug 2026 16:28:17 +0200 Subject: [PATCH] feat: Add playwright workflow Signed-off-by: Louis Chmn --- workflow-templates/playwright.properties.json | 10 ++ workflow-templates/playwright.yml | 139 ++++++++++++++++++ 2 files changed, 149 insertions(+) create mode 100644 workflow-templates/playwright.properties.json create mode 100644 workflow-templates/playwright.yml diff --git a/workflow-templates/playwright.properties.json b/workflow-templates/playwright.properties.json new file mode 100644 index 0000000..94ce8f6 --- /dev/null +++ b/workflow-templates/playwright.properties.json @@ -0,0 +1,10 @@ +{ + "name": "Playwright testing", + "description": "Default playwright workflow. It will setup composer if required, setup node, install dependencies, run playwright and upload artifacts. Feel free to adjust the amount of containers depending on how much tests you have.", + "iconName": "playwright", + "filePatterns": [ + "^playwright.config.js$", + "^playwright.config.mjs$", + "^playwright.config.ts$" + ] +} diff --git a/workflow-templates/playwright.yml b/workflow-templates/playwright.yml new file mode 100644 index 0000000..312c611 --- /dev/null +++ b/workflow-templates/playwright.yml @@ -0,0 +1,139 @@ +# This workflow is provided via the organization template repository +# +# https://github.com/nextcloud/.github +# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization +# +# SPDX-FileCopyrightText: 2023-2024 Nextcloud GmbH and Nextcloud contributors +# SPDX-License-Identifier: MIT + +name: Playwright + +on: pull_request + +concurrency: + group: playwright-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +permissions: + contents: read + +env: + APP_NAME: ${{ github.event.repository.name }} + BRANCH: ${{ github.base_ref || github.ref_name }} + +jobs: + playwright: + runs-on: ubuntu-latest + + name: Playwright E2E tests + + steps: + - name: Checkout app + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + + - name: Read package.json node and npm engines version + uses: skjnldsv/read-package-engines-version-actions@06d6baf7d8f41934ab630e97d9e6c0bc9c9ac5e4 # v3 + id: versions + with: + fallbackNode: '^24' + fallbackNpm: '^11' + + - name: Set up node ${{ steps.versions.outputs.nodeVersion }} + uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6.5.0 + with: + node-version: ${{ steps.versions.outputs.nodeVersion }} + + - name: Set up npm ${{ steps.versions.outputs.npmVersion }} + run: npm i -g 'npm@${{ steps.versions.outputs.npmVersion }}' + + - name: Install dependencies + run: npm ci + + - name: Install Playwright browsers + run: npx playwright install chromium --with-deps + + - name: Build app + run: TESTING=true npm run build --if-present + + - name: Run Playwright tests + run: npx playwright test + env: + BRANCH: ${{ env.BRANCH }} + CI: true + + - name: Show Nextcloud logs on failure + if: failure() + run: | + docker exec nextcloud-e2e-test-server_${{ env.APP_NAME }} cat data/nextcloud.log || true + + - name: Upload blob report + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + if: ${{ !cancelled() }} + with: + name: blob-report + path: blob-report/ + retention-days: 1 + + - name: Upload Playwright traces + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + if: failure() + with: + name: playwright-traces + path: test-results/ + retention-days: 7 + + merge-reports: + if: ${{ !cancelled() }} + needs: playwright + runs-on: ubuntu-latest + + steps: + - name: Checkout app + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + + - name: Read package.json node and npm engines version + uses: skjnldsv/read-package-engines-version-actions@06d6baf7d8f41934ab630e97d9e6c0bc9c9ac5e4 # v3 + id: versions + with: + fallbackNode: '^24' + fallbackNpm: '^11' + + - name: Set up node ${{ steps.versions.outputs.nodeVersion }} + uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6.5.0 + with: + node-version: ${{ steps.versions.outputs.nodeVersion }} + + - name: Set up npm ${{ steps.versions.outputs.npmVersion }} + run: npm i -g 'npm@${{ needs.playwright.outputs.npmVersion }}' + + - name: Install dependencies + run: npm ci + + - name: Download blob report + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 + with: + name: blob-report + path: blob-report + + - name: Merge into HTML report + run: npx playwright merge-reports --reporter html ./blob-report + + - name: Upload HTML report + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: html-report--attempt-${{ github.run_attempt }} + path: playwright-report/ + retention-days: 7 + + summary: + runs-on: ubuntu-latest-low + needs: playwright + if: always() + name: playwright-summary + steps: + - name: Summary status + run: if ${{ needs.playwright.result != 'success' && needs.playwright.result != 'skipped' }}; then exit 1; fi