Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions workflow-templates/playwright.properties.json
Original file line number Diff line number Diff line change
@@ -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$"
]
}
139 changes: 139 additions & 0 deletions workflow-templates/playwright.yml
Original file line number Diff line number Diff line change
@@ -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
Loading