-
Notifications
You must be signed in to change notification settings - Fork 2
301 lines (269 loc) · 9.92 KB
/
Copy pathtest.yml
File metadata and controls
301 lines (269 loc) · 9.92 KB
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
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
# # .github/workflows/playwright-daily.yml
# # Runs Playwright test shards every day at **11 : 42 AM IST** (06 : 12 UTC)
# # plus anytime you trigger it manually from the Actions tab.
# name: Run Playwright tests
# on:
# push: # runs on every push
# pull_request: # runs on new PRs or PR updates
# schedule:
# - cron: '30 3 * * 1-5'
# workflow_dispatch:
# jobs:
# run-tests:
# name: Run shard ${{ matrix.shardIndex }}/5
# runs-on: ubuntu-latest
# strategy:
# fail-fast: false
# matrix:
# shardIndex: [1,2,3,4,5]
# shardTotal: [5]
# steps:
# - uses: actions/checkout@v4
# - name: Setup Node.js 18.x
# uses: actions/setup-node@v3
# with:
# node-version: '18'
# - name: Create .env file
# run: |
# echo "USERNAME=${{ secrets.USERNAME }}" >> .env
# echo "PASSWORD=${{ secrets.PASSWORD }}" >> .env
# echo "NEW_PASSWORD=${{ secrets.NEW_PASSWORD }}" >> .env
# echo "FIRST_NAME=${{ secrets.FIRST_NAME }}" >> .env
# echo "STREET_NAME=${{ secrets.STREET_NAME }}" >> .env
# echo "CITY=${{ secrets.CITY }}" >> .env
# echo "STATE=${{ secrets.STATE }}" >> .env
# echo "COUNTRY=${{ secrets.COUNTRY }}" >> .env
# echo "ZIP_CODE=${{ secrets.ZIP_CODE }}" >> .env
# - name: Cache npm dependencies
# uses: actions/cache@v3
# with:
# path: ~/.npm
# key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
# restore-keys: |
# ${{ runner.os }}-node-
# - name: Install deps + browsers
# run: |
# npm ci
# npx playwright install --with-deps chromium firefox webkit
# - name: List Playwright projects (debug)
# run: npx playwright list --projects | cat
# - name: Run Playwright (rerun failed tests if applicable)
# env:
# TESTDINO_TOKEN: ${{ secrets.TESTDINO_TOKEN }}
# SHARD_INDEX: ${{ matrix.shardIndex }}
# SHARD_TOTAL: ${{ matrix.shardTotal }}
# run: |
# echo "GitHub run attempt: ${{ github.run_attempt }}"
# if [[ "${{ github.run_attempt }}" -gt 1 ]]; then
# echo "Detected re-run. Checking failed test metadata from TestDino."
# npx tdpw last-failed \
# --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }} \
# > last-failed-flags.txt
# EXTRA_PW_FLAGS="$(cat last-failed-flags.txt)"
# if [[ -n "$EXTRA_PW_FLAGS" ]]; then
# echo "Running only failed tests for this shard:"
# echo "$EXTRA_PW_FLAGS"
# mkdir -p ./playwright-report
# eval "npx playwright test $EXTRA_PW_FLAGS"
# exit 0
# fi
# echo "No failed test metadata found. Falling back to full shard."
# fi
# mkdir -p ./playwright-report
# npx playwright test \
# --grep="@chromium|@firefox|@webkit|@android|@ios|@api" \
# --reporter=blob \
# --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }}
# - name: Upload blob report
# if: ${{ !cancelled() }}
# uses: actions/upload-artifact@v4
# with:
# name: blob-report-${{ matrix.shardIndex }}
# path: ./blob-report
# retention-days: 1
# - name: Cache tdpw last failed metadata
# if: always()
# env:
# TESTDINO_TOKEN: ${{ secrets.TESTDINO_TOKEN }}
# SHARD_INDEX: ${{ matrix.shardIndex }}
# SHARD_TOTAL: ${{ matrix.shardTotal }}
# run: |
# npx tdpw cache --verbose
# merge-reports:
# name: Merge Reports
# needs: run-tests
# if: always() # run even if some shards fail
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - name: Setup Node.js 18.x
# uses: actions/setup-node@v3
# with:
# node-version: '18'
# - name: Cache npm dependencies
# uses: actions/cache@v3
# with:
# path: ~/.npm
# key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
# restore-keys: |
# ${{ runner.os }}-node-
# - name: Install deps + browsers
# run: |
# npm ci
# npx playwright install --with-deps
# - name: Download all blob reports
# uses: actions/download-artifact@v4
# with:
# path: ./all-blob-reports
# pattern: blob-report-*
# merge-multiple: true
# - name: Merge HTML & JSON reports
# run: npx playwright merge-reports --reporter=html ./all-blob-reports
# - name: Upload combined report
# uses: actions/upload-artifact@v4
# with:
# name: Playwright Test Report
# path: ./playwright-report
# retention-days: 14
# - name: Send TestDino report
# run: |
# npx --yes tdpw ./playwright-report \
# --token="${{ secrets.TESTDINO_TOKEN }}" \
# --upload-html \
# --verbose
name: Run Playwright tests
on:
push:
pull_request:
schedule:
- cron: '30 3 * * 1-5' # 11:00 AM IST
workflow_dispatch:
jobs:
run-tests:
name: Run Playwright tests ${{ matrix.shardIndex }}/3
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
shardIndex: [1, 2, 3]
shardTotal: [3]
steps:
- uses: actions/checkout@v4
# ✅ REQUIRED: Node 20
- name: Setup Node.js 20.x
uses: actions/setup-node@v3
with:
node-version: '20'
- name: Create .env file
run: |
echo "USERNAME=${{ secrets.USERNAME }}" >> .env
echo "PASSWORD=${{ secrets.PASSWORD }}" >> .env
echo "NEW_PASSWORD=${{ secrets.NEW_PASSWORD }}" >> .env
echo "FIRST_NAME=${{ secrets.FIRST_NAME }}" >> .env
echo "STREET_NAME=${{ secrets.STREET_NAME }}" >> .env
echo "CITY=${{ secrets.CITY }}" >> .env
echo "STATE=${{ secrets.STATE }}" >> .env
echo "COUNTRY=${{ secrets.COUNTRY }}" >> .env
echo "ZIP_CODE=${{ secrets.ZIP_CODE }}" >> .env
- name: Cache npm dependencies
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install deps + browsers
run: |
npm ci
npx playwright install --with-deps chromium firefox webkit
# ✅ FULL + RERUN LOGIC
- name: Run Playwright (rerun failed tests if applicable)
env:
TESTDINO_TOKEN: ${{ secrets.TESTDINO_TOKEN }}
SHARD_INDEX: ${{ matrix.shardIndex }}
SHARD_TOTAL: ${{ matrix.shardTotal }}
run: |
echo "GitHub run attempt: ${{ github.run_attempt }}"
if [[ "${{ github.run_attempt }}" -gt 1 ]]; then
echo "Detected re-run. Checking failed test metadata from TestDino."
npx tdpw last-failed \
--shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }} \
> last-failed-flags.txt
EXTRA_PW_FLAGS="$(cat last-failed-flags.txt)"
if [[ -n "$EXTRA_PW_FLAGS" ]]; then
echo "Running only failed tests for this shard:"
echo "$EXTRA_PW_FLAGS"
# IMPORTANT: JSON + BLOB BOTH REQUIRED
# Ensure playwright-report directory exists
mkdir -p ./playwright-report
eval "npx playwright test $EXTRA_PW_FLAGS"
exit 0
fi
echo "No failed test metadata found. Falling back to full shard."
fi
# First run (full shard)
# Ensure playwright-report directory exists
mkdir -p ./playwright-report
npx playwright test \
--grep="@chromium|@firefox|@webkit|@android|@ios" \
--shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }}
- name: Upload blob report
if: ${{ !cancelled() }}
uses: actions/upload-artifact@v4
with:
name: blob-report-${{ matrix.shardIndex }}
path: ./blob-report
retention-days: 1
# ✅ THIS WILL SHOW "Metadata cached successfully ✔" WHEN JSON EXISTS
- name: Cache tdpw last failed metadata
if: always()
env:
TESTDINO_TOKEN: ${{ secrets.TESTDINO_TOKEN }}
SHARD_INDEX: ${{ matrix.shardIndex }}
SHARD_TOTAL: ${{ matrix.shardTotal }}
run: |
npx tdpw cache --verbose
merge-reports:
name: Merge Reports
needs: run-tests
if: always()
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# ✅ Node 20 here as well
- name: Setup Node.js 20.x
uses: actions/setup-node@v3
with:
node-version: '20'
- name: Cache npm dependencies
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install deps + browsers
run: |
npm ci
npx playwright install --with-deps
- name: Download all blob reports
uses: actions/download-artifact@v4
with:
path: ./all-blob-reports
pattern: blob-report-*
merge-multiple: true
- name: Merge HTML & JSON reports
run: npx playwright merge-reports --config=playwright.config.js ./all-blob-reports
- name: Upload combined report
uses: actions/upload-artifact@v4
with:
name: Playwright Test Report
path: ./playwright-report
retention-days: 14
- name: Send TestDino report
run: |
npx --yes tdpw ./playwright-report \
--token="${{ secrets.TESTDINO_TOKEN }}" \
--upload-html \
--upload-traces \
--verbose