-
Notifications
You must be signed in to change notification settings - Fork 15
214 lines (180 loc) · 6.64 KB
/
playwright-shard.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
name: Playwright Test
on:
workflow_dispatch:
push:
branches: [main]
pull_request:
branches: [main]
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write
checks: write # for dorny/test-reporter
pull-requests: write # for leaving a comment on PR
env:
NODEJS_VERSION: 20
TESULTS_API_TOKEN: ${{ secrets.TESULTS_API_TOKEN }}
LH_TESULTS_API_TOKEN: ${{ secrets.LH_TESULTS_API_TOKEN }}
jobs:
set_job_params:
name: Set Job Params
runs-on: ubuntu-latest
outputs:
pw-version: ${{ steps.set_version.outputs.PW_VERSION }}
pw-tesults-target-token: ${{ steps.generate-secret.outputs.SECRET_TOKEN }}
steps:
- uses: actions/checkout@v4
- name: Setup NodeJS SDK ${{ env.NODEJS_VERSION }}
uses: actions/setup-node@v4
with:
cache: yarn
cache-dependency-path: yarn.lock
node-version: ${{ env.NODEJS_VERSION }}
# used to create/delete branch target
- name: Set Branch Name Environment Variable
run: |
# Short name for current branch. For PRs, use target branch (base ref)
BRANCH=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}
echo "BRANCH=$BRANCH" >> $GITHUB_ENV
- name: Yarn Install
run: yarn install --mode=skip-build
- name: Create Tesults Target Token
run: node ./.scripts/create-delete-branch-target.js create
- name: Upload Tesults Target Token
uses: actions/upload-artifact@v4
with:
name: tesultsToken
path: tesultsToken.txt
- name: Get Playwright Package Version
id: get-version
uses: beaconbrigade/[email protected]
with:
path: node_modules/playwright
- name: Set Package Version
id: set_version
run: echo "PW_VERSION=${{ steps.get-version.outputs.version }}" >> $GITHUB_OUTPUT
playwright_test:
name: Playwright Test
needs: set_job_params
strategy:
fail-fast: false
matrix:
shardIndex: [1, 2, 3, 4]
shardTotal: [4]
runs-on: ubuntu-latest
container:
image: mcr.microsoft.com/playwright:v${{ needs.set_job_params.outputs.pw-version }}-jammy
steps:
- uses: actions/checkout@v4
- name: Yarn Install
run: yarn install
- name: Download Tesults Target Token Artifact
uses: actions/download-artifact@v4
with:
name: tesultsToken
- name: Set Tesults Target Token Environment Variable
run: echo "PW_TESULTS_TOKEN=$(cat tesultsToken.txt)" >> $GITHUB_ENV
- name: Run Tests
run: yarn test:ci --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }}
env:
HOME: /root # required for playwright to run in container
- name: Upload blob report to GitHub Actions Artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: all-blob-reports-${{ matrix.shardIndex }}
path: blob-report/
retention-days: 10
# uploading to have a backup of the test-results in case reporting fails
- name: Upload test-results to GitHub Actions Artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: test-results-${{ matrix.shardIndex }}
path: test-results/
retention-days: 10
if-no-files-found: warn
reporting:
if: ${{ always() }}
needs: playwright_test
name: Reporting
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup NodeJS SDK ${{ env.NODEJS_VERSION }}
uses: actions/setup-node@v4
with:
cache: yarn
cache-dependency-path: yarn.lock
node-version: ${{ env.NODEJS_VERSION }}
- name: Yarn Install
run: yarn install
- name: Download blob reports from GitHub Actions Artifacts
uses: actions/download-artifact@v4
with:
pattern: all-blob-reports-*
merge-multiple: true
path: all-blob-reports
# xml report use by dorny-test-reporter
- name: Merge into XML Report
run: PLAYWRIGHT_JUNIT_OUTPUT_NAME=junit.xml npx playwright merge-reports --reporter=junit ./all-blob-reports
- name: Test Report
uses: dorny/test-reporter@v1
if: success() || failure()
with:
name: Playwright Test Report
path: "**/junit.xml"
reporter: java-junit
fail-on-error: 'false'
- name: Merge into HTML Report
run: npx playwright merge-reports --reporter html ./all-blob-reports
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Upload HTML report for Pages
uses: actions/upload-pages-artifact@v3
with:
name: github-pages
path: playwright-report
retention-days: 14
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
- name: Message PR of Artifact Published
if: ${{ always() && github.event_name == 'pull_request' }}
uses: thollander/actions-comment-pull-request@main
with:
message: |
[Click here for Github Pages Playwright Report](${{ steps.deployment.outputs.page_url }})
[Click here to see Tesults Dashboard](https://www.tesults.com/results/rsp/view/status/project/48242328-a7eb-4ab4-8065-3a3686634e5c/group/playwright-boilerplate)
comment_tag: playwright_message
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
lighthouse_test:
if: ${{ always() }}
name: Lighthouse
needs: set_job_params
runs-on: ubuntu-latest
container:
image: mcr.microsoft.com/playwright:v${{ needs.set_job_params.outputs.pw-version }}-jammy
steps:
- uses: actions/checkout@v4
- name: Yarn Install
run: yarn install
- name: Run Lighthouse
run: yarn test:lighthouse
env:
HOME: /root # required for playwright to run in container
- name: Upload Lighthouse Report
uses: actions/upload-artifact@v4
with:
name: lighthouse-report
path: tests/lighthouse/reports
retention-days: 10
- name: Message PR of Artifact Published
if: ${{ always() && github.event_name == 'pull_request' }}
uses: thollander/actions-comment-pull-request@main
with:
message: |
[Click here to see Tesults Lighthouse Report](https://www.tesults.com/results/rsp/view/results/target/48242328-a7eb-4ab4-8065-3a3686634e5c-1701748288944)
comment_tag: lighthouse_message
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}