-
Notifications
You must be signed in to change notification settings - Fork 2
458 lines (397 loc) · 15.2 KB
/
e2e.yml
File metadata and controls
458 lines (397 loc) · 15.2 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
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
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
name: E2E
on:
workflow_dispatch:
inputs:
e2e_branch:
description: "Branch of synonymdev/bitkit-e2e-tests to use (main | default-feature-branch | custom branch name)"
required: false
default: "default-feature-branch"
pull_request:
types: [ opened, synchronize, reopened, ready_for_review ]
env:
TERM: xterm-256color
FORCE_COLOR: 1
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
detect-changes:
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
outputs:
code: ${{ github.event_name == 'workflow_dispatch' || steps.filter.outputs.code == 'true' }}
steps:
- uses: actions/checkout@v6
- uses: dorny/paths-filter@v3
if: github.event_name == 'pull_request'
id: filter
with:
filters: |
code:
- 'app/**'
- 'gradle/**'
- '*.gradle.kts'
- 'gradle.properties'
- '.github/workflows/e2e.yml'
build-local:
needs: detect-changes
if: github.event.pull_request.draft == false && needs.detect-changes.outputs.code == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Setup Java
uses: actions/setup-java@v5
with:
java-version: "17"
distribution: "adopt"
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v5
- name: Decode google-services.json
run: echo "$GOOGLE_SERVICES_JSON_BASE64" | base64 -d > app/google-services.json
env:
GOOGLE_SERVICES_JSON_BASE64: ${{ secrets.GOOGLE_SERVICES_JSON_BASE64 }}
- name: Build debug app (local)
env:
GITHUB_ACTOR: ${{ github.actor }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CHATWOOT_API: ${{ secrets.CHATWOOT_API }}
E2E: true
GEO: false
run: ./gradlew assembleDevDebug
- name: Rename APK
run: |
apk=$(find app/build/outputs/apk/dev/debug -name 'bitkit-dev-debug-*-universal.apk')
mv "$apk" app/build/outputs/apk/dev/debug/bitkit_e2e.apk
- name: Upload APK (local)
uses: actions/upload-artifact@v6
with:
name: bitkit-e2e-apk_${{ github.run_number }}
path: app/build/outputs/apk/dev/debug/bitkit_e2e.apk
build-staging:
needs: detect-changes
if: github.event.pull_request.draft == false && needs.detect-changes.outputs.code == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Setup Java
uses: actions/setup-java@v5
with:
java-version: "17"
distribution: "adopt"
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v5
- name: Decode google-services.json
run: echo "$GOOGLE_SERVICES_JSON_BASE64" | base64 -d > app/google-services.json
env:
GOOGLE_SERVICES_JSON_BASE64: ${{ secrets.GOOGLE_SERVICES_JSON_BASE64 }}
- name: Build debug app (regtest)
env:
GITHUB_ACTOR: ${{ github.actor }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CHATWOOT_API: ${{ secrets.CHATWOOT_API }}
E2E: true
E2E_BACKEND: network
GEO: false
run: ./gradlew assembleDevDebug
- name: Rename APK
run: |
apk=$(find app/build/outputs/apk/dev/debug -name 'bitkit-dev-debug-*-universal.apk')
mv "$apk" app/build/outputs/apk/dev/debug/bitkit_e2e.apk
- name: Upload APK (regtest)
uses: actions/upload-artifact@v6
with:
name: bitkit-e2e-apk-regtest_${{ github.run_number }}
path: app/build/outputs/apk/dev/debug/bitkit_e2e.apk
e2e-branch:
needs: detect-changes
if: github.event.pull_request.draft == false && needs.detect-changes.outputs.code == 'true'
uses: synonymdev/bitkit-e2e-tests/.github/workflows/determine-e2e-branch.yml@main
with:
app_branch: ${{ github.head_ref || github.ref_name }}
e2e_branch_input: ${{ github.event.inputs.e2e_branch || 'default-feature-branch' }}
e2e-tests-local:
if: github.event.pull_request.draft == false && needs.detect-changes.outputs.code == 'true'
runs-on: ubuntu-latest
needs: [detect-changes, build-local, e2e-branch]
strategy:
fail-fast: false
matrix:
shard:
- { name: onboarding_backup_numberpad, grep: "@onboarding|@backup|@numberpad" }
- { name: onchain_boost_receive_widgets, grep: "@onchain|@boost|@receive|@widgets" }
- { name: settings, grep: "@settings" }
- { name: send, grep: "@send" }
- { name: lightning_security, grep: "@lightning|@security" }
- { name: lnurl_transfer, grep: "@lnurl|@transfer" }
- { name: multi_address_local, grep: "@multi_address_1|@multi_address_3|@multi_address_4" }
name: e2e-tests-local - ${{ matrix.shard.name }}
steps:
- name: Show selected E2E branch
env:
E2E_BRANCH: ${{ needs.e2e-branch.outputs.branch }}
run: echo $E2E_BRANCH
- name: Clone E2E tests
uses: actions/checkout@v6
with:
repository: synonymdev/bitkit-e2e-tests
path: bitkit-e2e-tests
ref: ${{ needs.e2e-branch.outputs.branch }}
- name: Enable KVM
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
- name: AVD cache
uses: actions/cache@v5
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-33-x86_64-pixel_6
- name: Create AVD and generate snapshot for caching
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@v2
with:
profile: pixel_6
api-level: 33
arch: x86_64
avd-name: Pixel_6
force-avd-creation: false
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-front none
disable-animations: false
script: echo "Generated AVD snapshot for caching."
- name: Download APK
uses: actions/download-artifact@v6
with:
name: bitkit-e2e-apk_${{ github.run_number }}
path: bitkit-e2e-tests/aut
- name: List APK directory contents
run: ls -l bitkit-e2e-tests/aut
- name: Setup Node.js
uses: actions/setup-node@v5
with:
node-version: 22
- name: Cache npm cache
uses: actions/cache@v5
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install dependencies
working-directory: bitkit-e2e-tests
run: npm ci
- name: Run regtest setup
working-directory: bitkit-e2e-tests
run: |
cd docker
mkdir lnd && chmod 777 lnd
docker compose pull --quiet
docker compose up -d
- name: Wait for electrum server and LND
working-directory: bitkit-e2e-tests
timeout-minutes: 10
run: |
while ! nc -z '127.0.0.1' 60001; do sleep 1; done
sudo bash -c "while [ ! -f docker/lnd/data/chain/bitcoin/regtest/admin.macaroon ]; do sleep 1; done"
sudo chmod -R 777 docker/lnd
- name: Run E2E Tests 1 (${{ matrix.shard.name }})
continue-on-error: true
id: test1
uses: reactivecircus/android-emulator-runner@v2
with:
profile: pixel_6
api-level: 33
arch: x86_64
avd-name: Pixel_6
force-avd-creation: false
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-front none
script: cd bitkit-e2e-tests && ./ci_run_android.sh --mochaOpts.grep "${{ matrix.shard.grep }}"
env:
RECORD_VIDEO: true
ATTEMPT: 1
- name: Run E2E Tests 2 (${{ matrix.shard.name }})
continue-on-error: true
id: test2
if: steps.test1.outcome != 'success'
uses: reactivecircus/android-emulator-runner@v2
with:
profile: pixel_6
api-level: 33
arch: x86_64
avd-name: Pixel_6
force-avd-creation: false
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-front none
script: cd bitkit-e2e-tests && ./ci_run_android.sh --mochaOpts.grep "${{ matrix.shard.grep }}"
env:
RECORD_VIDEO: true
ATTEMPT: 2
- name: Run E2E Tests 3 (${{ matrix.shard.name }})
id: test3
if: steps.test1.outcome != 'success' && steps.test2.outcome != 'success'
uses: reactivecircus/android-emulator-runner@v2
with:
profile: pixel_6
api-level: 33
arch: x86_64
avd-name: Pixel_6
force-avd-creation: false
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-front none
script: cd bitkit-e2e-tests && ./ci_run_android.sh --mochaOpts.grep "${{ matrix.shard.grep }}"
env:
RECORD_VIDEO: true
ATTEMPT: 3
- name: Upload E2E Artifacts (${{ matrix.shard.name }})
if: failure()
uses: actions/upload-artifact@v6
with:
name: e2e-artifacts_${{ matrix.shard.name }}_${{ github.run_number }}
path: bitkit-e2e-tests/artifacts/
- name: Dump docker logs on failure (${{ matrix.shard.name }})
if: failure()
uses: jwalton/gh-docker-logs@v2
e2e-tests-staging:
if: github.event.pull_request.draft == false && needs.detect-changes.outputs.code == 'true'
runs-on: ubuntu-latest
needs: [detect-changes, build-staging, e2e-branch]
strategy:
fail-fast: false
matrix:
shard:
- { name: multi_address_2_regtest, grep: "@multi_address_2" }
name: e2e-tests-staging - ${{ matrix.shard.name }}
steps:
- name: Show selected E2E branch
env:
E2E_BRANCH: ${{ needs.e2e-branch.outputs.branch }}
run: echo $E2E_BRANCH
- name: Clone E2E tests
uses: actions/checkout@v6
with:
repository: synonymdev/bitkit-e2e-tests
path: bitkit-e2e-tests
ref: ${{ needs.e2e-branch.outputs.branch }}
- name: Enable KVM
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
- name: AVD cache
uses: actions/cache@v5
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-33-x86_64-pixel_6
- name: Create AVD and generate snapshot for caching
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@v2
with:
profile: pixel_6
api-level: 33
arch: x86_64
avd-name: Pixel_6
force-avd-creation: false
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-front none
disable-animations: false
script: echo "Generated AVD snapshot for caching."
- name: Download APK (regtest)
uses: actions/download-artifact@v6
with:
name: bitkit-e2e-apk-regtest_${{ github.run_number }}
path: bitkit-e2e-tests/aut
- name: List APK directory contents
run: ls -l bitkit-e2e-tests/aut
- name: Setup Node.js
uses: actions/setup-node@v5
with:
node-version: 22
- name: Cache npm cache
uses: actions/cache@v5
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install dependencies
working-directory: bitkit-e2e-tests
run: npm ci
- name: Run E2E Tests 1 (${{ matrix.shard.name }})
continue-on-error: true
id: test1
uses: reactivecircus/android-emulator-runner@v2
with:
profile: pixel_6
api-level: 33
arch: x86_64
avd-name: Pixel_6
force-avd-creation: false
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-front none
script: cd bitkit-e2e-tests && ./ci_run_android.sh --mochaOpts.grep "${{ matrix.shard.grep }}"
env:
BACKEND: regtest
RECORD_VIDEO: true
ATTEMPT: 1
- name: Run E2E Tests 2 (${{ matrix.shard.name }})
continue-on-error: true
id: test2
if: steps.test1.outcome != 'success'
uses: reactivecircus/android-emulator-runner@v2
with:
profile: pixel_6
api-level: 33
arch: x86_64
avd-name: Pixel_6
force-avd-creation: false
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-front none
script: cd bitkit-e2e-tests && ./ci_run_android.sh --mochaOpts.grep "${{ matrix.shard.grep }}"
env:
BACKEND: regtest
RECORD_VIDEO: true
ATTEMPT: 2
- name: Run E2E Tests 3 (${{ matrix.shard.name }})
id: test3
if: steps.test1.outcome != 'success' && steps.test2.outcome != 'success'
uses: reactivecircus/android-emulator-runner@v2
with:
profile: pixel_6
api-level: 33
arch: x86_64
avd-name: Pixel_6
force-avd-creation: false
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-front none
script: cd bitkit-e2e-tests && ./ci_run_android.sh --mochaOpts.grep "${{ matrix.shard.grep }}"
env:
BACKEND: regtest
RECORD_VIDEO: true
ATTEMPT: 3
- name: Upload E2E Artifacts (${{ matrix.shard.name }})
if: failure()
uses: actions/upload-artifact@v6
with:
name: e2e-artifacts-regtest_${{ matrix.shard.name }}_${{ github.run_number }}
path: bitkit-e2e-tests/artifacts/
- name: Dump docker logs on failure (${{ matrix.shard.name }})
if: failure()
uses: jwalton/gh-docker-logs@v2
e2e-status:
if: always() && github.event.pull_request.draft == false
name: e2e-status
runs-on: ubuntu-latest
needs: [detect-changes, e2e-tests-local, e2e-tests-staging]
steps:
- name: E2E skipped - no code changes
if: needs.detect-changes.outputs.code != 'true'
run: echo "✅ E2E skipped - no code changes"
- name: Verify all E2E shards succeeded
if: needs.detect-changes.outputs.code == 'true'
run: |
if [ "${{ needs.e2e-tests-local.result }}" != "success" ] || [ "${{ needs.e2e-tests-staging.result }}" != "success" ]; then
echo "❌ Some E2E shards failed."
exit 1
fi
echo "✅ All E2E shards passed!"