-
Notifications
You must be signed in to change notification settings - Fork 345
380 lines (340 loc) · 13.4 KB
/
test-ui-e2e-only-desktop.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
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
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
name: "@Desktop • UI e2e • Test App"
run-name: "@Desktop • UI e2e • Test App triggered by ${{ inputs.login || github.actor }} ${{ format('on ref {0}', github.ref_name) }}"
on:
schedule:
- cron: "0 5 * * 1-5"
workflow_dispatch:
inputs:
ref:
description: the branch which triggered this workflow
required: false
login:
description: The GitHub username that triggered the workflow
required: false
base_ref:
description: The base branch to merge the head into when checking out the code
required: false
test_filter:
description: Filter test pattern to execute only tests suites named according to pattern(s) separated by '|' (e.g. to execute accounts and settings describe blocks "Accounts @smoke" or "Accounts @smoke|Settings")
required: false
invert_filter:
description: Ignore test having name pattern (entered in the previous field)
type: boolean
default: false
slack_notif:
description: "Send notification to Slack?"
required: false
type: boolean
default: false
export_to_xray:
description: Send tests results to Xray
required: false
type: boolean
default: false
test_execution:
description: "Test Execution ticket ID"
required: false
type: string
default: "B2CQA-2461"
build_type:
description: "Firebase env to target (pick js for release testing)"
required: false
type: choice
options:
- js
- staging
- testing
default: testing
concurrency:
group: ${{ github.workflow }}-${{ github.ref_name != 'develop' && github.ref || github.run_id }}
cancel-in-progress: true
permissions:
id-token: write
contents: read
jobs:
e2e-tests-linux:
name: "Desktop Tests E2E (Ubuntu)"
env:
NODE_OPTIONS: "--max-old-space-size=7168"
INSTRUMENT_BUILD: true
FORCE_COLOR: 3
CI_OS: "ubuntu-latest"
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
SPECULOS_IMAGE_TAG: ghcr.io/ledgerhq/speculos:0.11
runs-on: [ledger-live-4xlarge]
strategy:
fail-fast: false
matrix:
shardIndex: [1, 2, 3]
shardTotal: [3]
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.ref || github.sha }}
- name: Setup caches
id: caches
uses: LedgerHQ/ledger-live/tools/actions/composites/setup-caches@develop
with:
skip-turbo-cache: "false"
accountId: ${{ secrets.AWS_ACCOUNT_ID_PROD }}
roleName: ${{ secrets.AWS_CACHE_ROLE_NAME }}
region: ${{ secrets.AWS_CACHE_REGION }}
turbo-server-token: ${{ secrets.TURBOREPO_SERVER_TOKEN }}
- uses: LedgerHQ/ledger-live/tools/actions/composites/setup-test-desktop@develop
id: setup-test-desktop
with:
build_type: ${{ inputs.build_type || 'testing' }}
skip_ruby: true
install_playwright: true
turborepo-server-port: ${{ steps.caches.outputs.port }}
- name: Generate token
id: generate-token
uses: tibdex/github-app-token@v1
with:
app_id: ${{ secrets.GH_BOT_APP_ID }}
private_key: ${{ secrets.GH_BOT_PRIVATE_KEY }}
- name: Retrieving coin apps
uses: actions/checkout@v4
with:
ref: master
repository: LedgerHQ/coin-apps
token: ${{ steps.generate-token.outputs.token }}
path: coin-apps
- name: Pull docker image
run: docker pull ${{ env.SPECULOS_IMAGE_TAG }}
shell: bash
- name: Run playwright tests [Linux => xvfb-run]
id: tests
run: |
export SPECULOS_IMAGE_TAG=${{ env.SPECULOS_IMAGE_TAG }}
export COINAPPS=$PWD/coin-apps
export MOCK=0
if [ "${{ inputs.invert_filter }}" = true ]; then invert_filter="-invert"; fi
xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- pnpm desktop test:playwright:speculos --max-failures 50 ${INPUTS_TEST_FILTER:+--grep$invert_filter} "${{ inputs.test_filter }}" --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }}
env:
INPUTS_TEST_FILTER: ${{ inputs.test_filter }}
SEED: ${{ secrets.SEED_QAA_B2C }}
XRAY: ${{ inputs.export_to_xray }}
TEST_EXECUTION: ${{ inputs.test_execution }}
PROJECT_KEY: B2CQA
- name: Upload Allure Results
if: ${{ !cancelled() }}
uses: actions/[email protected]
with:
retention-days: 1
name: allure-results-${{ matrix.shardIndex }}
path: "apps/ledger-live-desktop/allure-results"
- name: Upload Xray Results
if: ${{ !cancelled() && inputs.export_to_xray }}
uses: actions/[email protected]
with:
retention-days: 1
name: xray-reports-${{ matrix.shardIndex }}
path: apps/ledger-live-desktop/tests/artifacts/xray/xray-report.json
report-to-allure:
name: "Create Allure Report and upload it"
runs-on: [ledger-live-medium]
needs: e2e-tests-linux
outputs:
test_result: ${{ steps.summary.outputs.test_result }}
status_color: ${{ steps.summary.outputs.status_color }}
status_emoji: ${{ steps.summary.outputs.status_emoji }}
report-url: ${{ steps.allure-server.outputs.report-url }}
if: ${{ !cancelled() }}
env:
ALLURE_RESULTS: "allure-results"
steps:
- name: Publish report on Allure Server
id: allure-server
if: ${{ !cancelled() }}
uses: LedgerHQ/ledger-live/tools/actions/composites/upload-allure-report@develop
with:
platform: linux
login: ${{ vars.ALLURE_USERNAME }}
password: ${{ secrets.ALLURE_LEDGER_LIVE_PASSWORD }}
path: ${{ env.ALLURE_RESULTS }}
- name: Get summary
if: ${{ !cancelled() && (inputs.slack_notif || github.event_name == 'schedule' )}}
id: summary
uses: LedgerHQ/ledger-live/tools/actions/composites/get-allure-summary@develop
with:
allure-results-path: ${{ env.ALLURE_RESULTS }}
platform: linux
notify-to-slack:
name: "Notify to slack"
runs-on: [ledger-live-medium]
needs: report-to-allure
if: ${{ !cancelled() && (inputs.slack_notif || github.event_name == 'schedule' )}}
steps:
- uses: actions/github-script@v7
if: ${{ !cancelled() && (inputs.slack_notif || github.event_name == 'schedule' )}}
name: prepare status
id: status
env:
STATUS_EMOJI: ${{ needs.report-to-allure.outputs.status_emoji }}
with:
script: |
const fs = require("fs");
const path = require("path");
const [ owner, repo ] = "${{ github.repository }}".split("/");
const jobs = await github.paginate(github.rest.actions.listJobsForWorkflowRunAttempt, {
owner,
repo,
run_id: "${{ github.run_id }}",
attempt_number: "${{ github.run_attempt }}",
});
const findJobUrl = os =>
jobs.find(job => job.name == `Live Desktop Tests (${os})`)?.html_url;
const keys = {
linux: {
symbol: "🐧",
name: "Linux",
jobUrl: findJobUrl("Linux")
},
};
const report = {
linux: {
pass: ${{ needs.e2e-tests-linux.outputs.status == 'success' }},
status: "${{ needs.e2e-tests-linux.outputs.status }}",
}
};
const statusEmoji = process.env.STATUS_EMOJI;
let summary = `### Playwright Tests
`
summary += `|`
const reportKeys = Object.keys(report);
const playwrightSuccess = Object.entries(report).every(([os, values]) => !!values.pass);
reportKeys.forEach((k) => {
summary += ` [${keys[k].symbol} ${keys[k].name}](${keys[k].jobUrl}) |`;
});
summary += `
|`;
for (let i = 0; i < reportKeys.length; i++) {
summary += ` :--: |`;
}
summary += `
|`;
Object.entries(report).forEach(([os, values]) => {
summary += ` ${values.pass ? statusEmoji : "❌"} (${values.status}) |`;
});
summary += `
${{ steps.comment.outputs.body }}
`
const output = {
summary,
actions: [{
// 20 chars max
label: "Regen. Screenshots",
// 20 chars max
identifier: "regen_screenshots",
// 40 chars max
description: "Will regenerate playwright screenshots",
}, {
// 20 chars max
label: "Run full LLD suite",
// 20 chars max
identifier: "lld_full_suite",
// 40 chars max
description: "Run the full e2e test suite for LLD",
}],
};
const slackPayload = {
"attachments": [
{
"color": "${{ needs.report-to-allure.outputs.status_color }}",
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": ":ledger-logo: Ledger Live Desktop E2E tests results on ${{ github.ref_name }}",
"emoji": true
}
},
{
"type": "divider"
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": `- 🐧 linux: ${statusEmoji} ${{ needs.report-to-allure.outputs.test_result || 'No test results' }}`
}
},
{
"type": "divider"
},
{
"type": "section",
"fields": [
{
"type": "mrkdwn",
"text": "*Allure Report*\n<${{ needs.report-to-allure.outputs.report-url }}|allure-results-linux>"
},
{
"type": "mrkdwn",
"text": "*Workflow*\n<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|Workflow Run>"
}
]
}
]
}
]
};
fs.writeFileSync("payload-slack-content.json", JSON.stringify(slackPayload), "utf-8");
- name: Print Slack Payload Content
run: cat ${{ github.workspace }}/payload-slack-content.json
- name: Post to a Slack channel
id: slack
uses: slackapi/[email protected]
with:
channel-id: "C05FKJ7DFAP"
payload-file-path: ${{ github.workspace }}/payload-slack-content.json
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_LIVE_CI_BOT_TOKEN }}
STATUS_COLOR: ${{ needs.report-to-allure.outputs.status_color }}
upload-to-xray:
name: "Upload to Xray"
runs-on: [ledger-live-medium]
env:
XRAY_CLIENT_ID: ${{ secrets.XRAY_CLIENT_ID }}
XRAY_CLIENT_SECRET: ${{ secrets.XRAY_CLIENT_SECRET }}
XRAY_API_URL: https://xray.cloud.getxray.app/api/v2
JIRA_URL: https://ledgerhq.atlassian.net/browse
needs: e2e-tests-linux
if: ${{ !cancelled() && inputs.export_to_xray }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.ref || github.sha }}
- name: Download Xray Results
uses: actions/[email protected]
with:
path: "apps/ledger-live-desktop/artifacts/xray"
pattern: xray-reports-*
merge-multiple: false
- name: Extract and Aggregate Xray results
run: ./aggregate-xray-reports.sh
- name: Upload aggregated xray results
uses: actions/[email protected]
with:
name: aggregated-xray-reports
path: "apps/ledger-live-desktop/artifacts/xray/aggregated-xray-reports.json"
- name: Authenticate to Xray
id: authenticate
run: |
response=$(curl -H "Content-Type: application/json" -X POST --data '{"client_id": "${{ secrets.XRAY_CLIENT_ID }}", "client_secret": "${{ secrets.XRAY_CLIENT_SECRET }}"}' ${{ env.XRAY_API_URL }}/authenticate)
echo "xray_token=$response" >> $GITHUB_OUTPUT
- name: Publish merged report on Xray
id: publish-xray
run: |
response=$(curl -H "Content-Type: application/json" \
-H "Authorization: Bearer ${{ steps.authenticate.outputs.xray_token }}" \
-X POST \
--data @apps/ledger-live-desktop/artifacts/xray/aggregated-xray-reports.json \
${{ env.XRAY_API_URL }}/import/execution)
key=$(echo $response | jq -r '.key')
echo "xray_key=$key" >> $GITHUB_OUTPUT
- name: Write Xray report in summary
shell: bash
run: echo "::notice title=Xray report URL::${{ env.JIRA_URL }}/${{ steps.publish-xray.outputs.xray_key }}"