forked from FooSoft/yomichan
-
Notifications
You must be signed in to change notification settings - Fork 112
199 lines (169 loc) · 6.52 KB
/
playwright.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
name: Playwright Tests
on:
push:
branches: [master]
pull_request:
permissions:
contents: read
jobs:
playwright-tests:
timeout-minutes: 60
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
shardIndex: [1, 2, 3, 4, 5]
shardTotal: [5]
steps:
- name: Remove all fonts
run: rm -rf /usr/share/fonts
- uses: actions/checkout@v4
- name: Install CJK fonts
uses: awalsh128/cache-apt-pkgs-action@a6c3917cc929dd0345bfb2d3feaf9101823370ad # v1.4.2
with:
packages: fonts-ipafont-mincho
execute_install_scripts: true
- uses: ./.github/actions/setup
- name: Build
run: npm run build
- name: Cache playwright browsers
id: cache-playwright
uses: actions/cache@v4
with:
path: |
~/.cache/ms-playwright
key: cache-playwright-${{ hashFiles('package-lock.json') }} # playwright version is included in package-lock, so this serves as a reasonable cache key
- if: ${{ steps.cache-playwright.outputs.cache-hit != 'true' }}
name: Install Playwright Browsers
run: npx playwright install chromium
- name: Grab latest dictionaries from dictionaries branch
uses: actions/checkout@v4
with:
repository: yomidevs/yomitan # so that this works on forks
ref: dictionaries
path: dictionaries
### [PR] master-screenshots
- name: "[PR] Grab latest screenshots from master branch"
uses: dawidd6/action-download-artifact@80620a5d27ce0ae443b965134db88467fc607b43 # pin@v2
continue-on-error: true
id: master-screenshots
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
repo: yomidevs/yomitan # so that this works on forks
name: playwright-screenshots
branch: master
workflow: playwright.yml
workflow_conclusion: success
path: test/playwright/__screenshots__/
if: github.event_name == 'pull_request'
- name: "[PR] Store steps.master-screenshots.outcome in a file"
run: echo ${{ steps.master-screenshots.outcome }} > ./master-screenshots-outcome
if: github.event_name == 'pull_request'
- name: "[PR] Upload master-screenshots-outcome"
uses: actions/upload-artifact@v4
with:
name: master-screenshots-outcome-${{ matrix.shardIndex }}
path: master-screenshots-outcome
if: github.event_name == 'pull_request'
### actual tests
- name: "[PR] Run tests & compare against master"
id: playwright
run: |
npx playwright test --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }} 2>&1 | tee ./playwright-output || true
continue-on-error: true
if: github.event_name == 'pull_request' && steps.master-screenshots.outcome != 'failure'
- name: "[Push] Run tests & save screenshots"
id: playwright-master
run: npx playwright test --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }} -u 2>&1 | tee ./playwright-output
if: github.event_name == 'push'
- uses: actions/upload-artifact@v4
with:
name: playwright-screenshots-${{ matrix.shardIndex }}
path: test/playwright/__screenshots__/
retention-days: 1
- name: Upload blob report to GitHub Actions Artifacts
if: ${{ !cancelled() }}
uses: actions/upload-artifact@v4
with:
name: blob-report-${{ matrix.shardIndex }}
path: blob-report
retention-days: 1
- uses: actions/upload-artifact@v4
with:
name: playwright-output-${{ matrix.shardIndex }}
path: playwright-output
retention-days: 1
playwright:
timeout-minutes: 60
runs-on: ubuntu-latest
# Merge reports after playwright-tests, even if some shards have failed
if: ${{ !cancelled() }}
needs: [playwright-tests]
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup
### playwright-report
- name: Download blob reports from GitHub Actions Artifacts
uses: actions/download-artifact@v4
with:
path: all-blob-reports
pattern: blob-report-*
merge-multiple: true
- name: Merge into HTML Report
run: npx playwright merge-reports --reporter html ./all-blob-reports
- name: Merge into JSON Report
run: npx playwright merge-reports --reporter json ./all-blob-reports > playwright-results.json
- uses: actions/upload-artifact@v4
with:
name: playwright-report
path: playwright-report/
- uses: actions/upload-artifact@v4
with:
name: playwright-results-json
path: playwright-results.json
### playwright-screenshots
- name: Download & merge screenshots from GitHub Actions Artifacts
uses: actions/download-artifact@v4
with:
path: test/playwright/__screenshots__
pattern: playwright-screenshots-*
merge-multiple: true
- uses: actions/upload-artifact@v4
with:
name: playwright-screenshots
path: test/playwright/__screenshots__/
### [PR] master-screenshots-outcome
- name: '[PR] Download master-screenshots-outcome files'
uses: actions/download-artifact@v4
with:
path: master-screenshots-outcomes
pattern: master-screenshots-outcome-*
merge-multiple: true
if: github.event_name == 'pull_request'
- name: '[PR] Calculate if any shard failed to download master screenshots'
run: |
if grep -q "failure" master-screenshots-outcomes/*; then
echo "failure" > master-screenshots-outcome
else
echo "success" > master-screenshots-outcome
fi
if: github.event_name == 'pull_request'
- name: '[PR] Upload master-screenshots-outcome'
uses: actions/upload-artifact@v4
with:
name: master-screenshots-outcome
path: master-screenshots-outcome
if: github.event_name == 'pull_request'
### playwright-output
- name: Download playwright-output files
uses: actions/download-artifact@v4
with:
path: playwright-outputs
pattern: playwright-output-*
merge-multiple: true
- name: Merge playwright output files
run: cat playwright-outputs/* > playwright-output
- uses: actions/upload-artifact@v4
with:
name: playwright-output
path: playwright-output