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