-
Notifications
You must be signed in to change notification settings - Fork 206
275 lines (259 loc) · 9.87 KB
/
playwright.yml
File metadata and controls
275 lines (259 loc) · 9.87 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
name: Playwright Tests
on:
- pull_request
- workflow_dispatch
permissions:
checks: write
pull-requests: write
contents: write
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
create-qase-run:
name: Create Qase Run
runs-on: ubuntu-latest
continue-on-error: true
timeout-minutes: 3
outputs:
run_id: ${{ steps.create-run.outputs.run_id }}
public_link: ${{ steps.create-public-link.outputs.public_link }}
steps:
- name: Create Qase Test Run
id: create-run
env:
QASE_TOKEN: ${{ secrets.QASE_TOKEN }}
GH_RUN_ID: ${{ github.run_id }}
GH_EVENT_NAME: ${{ github.event_name }}
PR_URL: ${{ github.event.pull_request.html_url }}
run: |
if [ -z "$QASE_TOKEN" ]; then
echo "No Qase API token available, skipping Qase run creation"
exit 0
fi
RUN_TITLE="[Jumper] CI Run $GH_RUN_ID"
if [ "$GH_EVENT_NAME" = "pull_request" ]; then
DESCRIPTION="Pull Request: [$PR_URL]($PR_URL)"
else
DESCRIPTION=""
fi
data=$(jq -n \
--arg title "$RUN_TITLE" \
--arg description "$DESCRIPTION" \
'{title: $title, description: $description}')
response=$(curl --silent --fail --show-error --request POST \
--url https://api.qase.io/v1/run/WJ \
--header "Token: $QASE_TOKEN" \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data "$data")
run_id=$(echo "$response" | jq -r '.result.id')
echo "run_id=$run_id" >> "$GITHUB_OUTPUT"
echo "Qase API Response: $response"
echo "Extracted Run ID: $run_id"
- name: Create public link to run
id: create-public-link
env:
QASE_TOKEN: ${{ secrets.QASE_TOKEN }}
QASE_RUN_ID: ${{ steps.create-run.outputs.run_id }}
run: |
public_link=$(curl --silent --fail --show-error --request PATCH \
--url "https://api.qase.io/v1/run/WJ/$QASE_RUN_ID/public" \
--header "Token: $QASE_TOKEN" \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '{"status":true}' \
| jq -r '.result.url')
echo "public_link=$public_link" >> "$GITHUB_OUTPUT"
echo "Public link: $public_link"
test:
needs: [create-qase-run]
name: Test (${{ matrix.shard }} / ${{ strategy.job-total}})
continue-on-error: false # Instead we use fail-fast to forward the failure state to subsequent jobs
# 25 min headroom — `swapActions.spec.ts` and `mainMenu.spec.ts` use
# `test.slow()` (3× per-test timeout) and one Hyperliquid case has
# `timeoutMs: 90_000`. 20 min was tight against worst-case shard timing.
timeout-minutes: 25
runs-on: ubuntu-latest
strategy:
matrix:
shard: [1, 2, 3, 4, 5]
fail-fast: false
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0
- uses: actions/setup-node@v4
with:
node-version: 22
cache: "pnpm"
- name: Install pnpm
run: npm install -g pnpm
- name: Install dependencies
run: pnpm install
- name: Install Playwright Browsers
run: |
pnpm exec playwright install --with-deps chromium
- name: Install xvfb
run: sudo apt-get update && sudo apt-get install -y xvfb
- name: Run Playwright tests
env:
QASE_TESTOPS_RUN_ID: ${{ needs.create-qase-run.outputs.run_id || '' }}
QASE_TESTOPS_API_TOKEN: ${{ secrets.QASE_TOKEN }}
SHARD: ${{ matrix.shard }}/${{ strategy.job-total }}
TEST_WALLET_SEED_PHRASE: ${{ secrets.TEST_WALLET_SEED_PHRASE }}
TEST_WALLET_PASSWORD: ${{ secrets.TEST_WALLET_PASSWORD }}
if: ${{ !cancelled()}} # Always attempt to run the tests even if cache setup failed
run: |
if [ -n "$QASE_TESTOPS_API_TOKEN" ] && [ -n "$QASE_TESTOPS_RUN_ID" ]; then
echo "Running tests with Qase reporting (Run ID: $QASE_TESTOPS_RUN_ID)"
xvfb-run -a pnpm run test:ci:e2e:qase \
--shard "$SHARD"
else
echo "Running tests without Qase reporting (API token or run ID not available)"
xvfb-run -a pnpm run test:ci:e2e \
--shard "$SHARD"
fi
- name: Upload blob report to Github Actions Artifacts
if: ${{ !cancelled() }}
uses: actions/upload-artifact@v4
with:
name: blob-report-${{ matrix.shard }}
path: blob-report
retention-days: 1
merge-reports:
if: ${{ !cancelled() }}
needs: [test]
timeout-minutes: 3
outputs:
summary: ${{ steps.summary.outputs.summary }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0
- uses: actions/setup-node@v4
with:
node-version: 22
cache: "pnpm"
- name: Install dependencies
run: pnpm install
- name: Download blob reports from GitHub Actions Articfacts
uses: actions/download-artifact@v4
with:
path: all-blob-reports
pattern: blob-report-*
merge-multiple: true
- name: Merge into HTML and JSON Reports
run: npx playwright merge-reports --reporter=html,json ./all-blob-reports
env:
PLAYWRIGHT_JSON_OUTPUT_NAME: report.json
- uses: daun/playwright-report-summary@be9e270edd5ad86038604d3caa84a819a6ff6fed # v3.10.0
id: summary
with:
report-file: ./report.json
create-comment: false
- name: Upload HTML report
uses: actions/upload-artifact@v4
with:
name: html-report--attempt-${{ github.run_attempt }}
path: playwright-report
retention-days: 2
post-comment:
needs: [create-qase-run, merge-reports]
if: ${{ !cancelled() && github.event_name == 'pull_request' }}
runs-on: ubuntu-latest
steps:
- uses: marocchino/sticky-pull-request-comment@v2
with:
message: |
${{ needs.merge-reports.outputs.summary }}
${{ needs.create-qase-run.outputs.public_link != '' && needs.create-qase-run.outputs.public_link != null && format('📋 [View Detailed Qase Report]({0})', needs.create-qase-run.outputs.public_link) || '' }}
notify-slack-on-failure:
needs: [create-qase-run, test, merge-reports]
if: ${{ failure() && github.event_name == 'pull_request' }}
runs-on: ubuntu-latest
steps:
- name: Build Slack payload
id: build-payload
env:
PR_AUTHOR: ${{ github.event.pull_request.user.login }}
QASE_LINK: ${{ needs.create-qase-run.outputs.public_link }}
PR_URL: ${{ github.event.pull_request.html_url }}
PR_NUMBER: ${{ github.event.pull_request.number }}
PR_TITLE: ${{ github.event.pull_request.title }}
REPO_NAME: ${{ github.repository }}
REPO_URL: ${{ github.server_url }}/${{ github.repository }}
WORKFLOW_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
run: |
# Build blocks using jq — all values come from safe env vars
BLOCKS=$(jq -n \
--arg author "$PR_AUTHOR" \
--arg repo_url "$REPO_URL" \
--arg repo_name "$REPO_NAME" \
--arg pr_url "$PR_URL" \
--arg pr_number "$PR_NUMBER" \
--arg pr_title "$PR_TITLE" \
--arg workflow_url "$WORKFLOW_URL" \
--arg qase_link "$QASE_LINK" \
'[
{
"type": "header",
"text": {
"type": "plain_text",
"text": "❌ UI Tests Failed"
}
},
{
"type": "section",
"fields": [
{
"type": "mrkdwn",
"text": "*Repository:*\n<\($repo_url)|\($repo_name)>"
},
{
"type": "mrkdwn",
"text": "*Pull Request:*\n<\($pr_url)|#\($pr_number) - \($pr_title)>"
},
{
"type": "mrkdwn",
"text": "*Author:*\n<@\($author)>"
},
{
"type": "mrkdwn",
"text": "*Workflow Run:*\n<\($workflow_url)|View Run>"
}
]
}
] + (if $qase_link != "" and $qase_link != "null" then [{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*Qase Report:* <\($qase_link)|View Detailed Report>"
}
}] else [] end) + [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "<@\($author)> Please review the test failures and fix any issues."
}
},
{
"type": "divider"
}
]')
PAYLOAD=$(jq -n \
--argjson blocks "$BLOCKS" \
'{
"channel": "#jumper-ui-tests",
"text": "❌ UI Tests Failed",
"blocks": $blocks
}')
echo "payload<<EOF" >> "$GITHUB_OUTPUT"
echo "$PAYLOAD" >> "$GITHUB_OUTPUT"
echo "EOF" >> "$GITHUB_OUTPUT"
- name: Send Slack notification
uses: slackapi/slack-github-action@v2
with:
webhook-type: incoming-webhook
webhook: ${{ secrets.SLACK_WEBHOOK_URL_UI_TESTS }}
payload: ${{ steps.build-payload.outputs.payload }}