Skip to content

Commit 426cbeb

Browse files
authored
Merge pull request #60194 from nextcloud/ci/playwright
test: add playwright pipeline and start migrating Cypress to Playwright
2 parents 6c9c739 + a21c2fd commit 426cbeb

52 files changed

Lines changed: 2627 additions & 2626 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/cypress.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,10 @@ jobs:
105105
matrix:
106106
# Run multiple copies of the current job in parallel
107107
# Please increase the number or runners as your tests suite grows (0 based index for e2e tests)
108-
containers: ['setup', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
108+
containers: ['setup', '0', '1', '2', '3', '4', '5', '6', '7', '8']
109109
# Hack as strategy.job-total includes the "setup" and GitHub does not allow math expressions
110110
# Always align this number with the total of e2e runners (max. index + 1)
111-
total-containers: [10]
111+
total-containers: [9]
112112

113113
services:
114114
mysql:

.github/workflows/playwright.yml

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
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

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,9 @@ Vagrantfile
145145

146146
# Tests - auto-generated files
147147
/data-autotest
148+
/playwright-report
148149
/results.sarif
150+
/test-results
149151
/tests/.phpunit.cache
150152
/tests/.phpunit.result.cache
151153
/tests/coverage*

build/files-checker.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
'openapi.json',
7575
'package-lock.json',
7676
'package.json',
77+
'playwright.config.ts',
7778
'psalm-ncu.xml',
7879
'psalm-ocp.xml',
7980
'psalm-strict.xml',

0 commit comments

Comments
 (0)