-
Notifications
You must be signed in to change notification settings - Fork 3
523 lines (447 loc) · 17 KB
/
Copy pathe2e-tests.yml
File metadata and controls
523 lines (447 loc) · 17 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
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
name: e2e-tests
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:
- 'Bitkit/**'
- 'BitkitNotification/**'
- 'BitkitTests/**'
- 'BitkitUITests/**'
- 'Bitkit.xcodeproj/**'
- 'Package.swift'
- '.github/workflows/e2e-tests.yml'
build-local:
needs: detect-changes
if: github.event.pull_request.draft == false && needs.detect-changes.outputs.code == 'true'
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Set up Xcode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: "26.2"
- name: System Information
run: |
echo "=== System Information ==="
echo "macOS Version:"
sw_vers
echo ""
echo "Xcode Version:"
xcodebuild -version
- name: Install xcbeautify
run: |
brew install xcbeautify
- name: Cache Swift Package Manager
uses: actions/cache@v5
with:
path: |
~/Library/Caches/org.swift.swiftpm
~/Library/org.swift.swiftpm
Bitkit.xcodeproj/project.xcworkspace/xcshareddata/swiftpm
key: ${{ runner.os }}-spm-${{ hashFiles('**/Package.resolved') }}
- name: Install dependencies
run: |
echo "⏱️ Starting dependency resolution at $(date)"
xcodebuild -resolvePackageDependencies -onlyUsePackageVersionsFromResolvedFile | xcbeautify
echo "✅ Dependencies resolved at $(date)"
- name: Pre-start simulator
run: |
echo "⏱️ Starting simulator at $(date)"
xcrun simctl boot "iPhone 17" || true
echo "✅ Simulator started at $(date)"
- name: Build iOS app (local)
env:
GITHUB_ACTOR: ${{ github.actor }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CHATWOOT_API: ${{ secrets.CHATWOOT_API }}
SIMULATOR_NAME: "iPhone 17"
OS_VERSION: "26.2"
GEO: false
run: |
echo "=== Building iOS app (local) ==="
echo "Using simulator: $SIMULATOR_NAME (iOS $OS_VERSION)"
if xcodebuild -showsdks | grep -q "iOS Simulator"; then
echo "✅ iOS Simulator platform already installed"
else
echo "⚙️ iOS Simulator platform not found — downloading..."
xcodebuild -downloadPlatform iOS
fi
xcodebuild -workspace Bitkit.xcodeproj/project.xcworkspace \
-scheme Bitkit \
-configuration Debug \
-destination "platform=iOS Simulator,name=$SIMULATOR_NAME,OS=$OS_VERSION" \
-derivedDataPath DerivedData \
SWIFT_ACTIVE_COMPILATION_CONDITIONS='DEBUG E2E_BUILD' \
-allowProvisioningUpdates \
build
- name: Prepare app for E2E tests (local)
run: |
# Copy the .app bundle to the expected location and name
mkdir -p e2e-app
cp -r DerivedData/Build/Products/Debug-iphonesimulator/Bitkit.app e2e-app/bitkit.app
- name: Upload iOS app (local)
uses: actions/upload-artifact@v6
with:
name: bitkit-e2e-ios_${{ github.run_number }}
path: e2e-app/
build-staging:
needs: detect-changes
if: github.event.pull_request.draft == false && needs.detect-changes.outputs.code == 'true'
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Set up Xcode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: "26.2"
- name: System Information
run: |
echo "=== System Information ==="
echo "macOS Version:"
sw_vers
echo ""
echo "Xcode Version:"
xcodebuild -version
- name: Install xcbeautify
run: |
brew install xcbeautify
- name: Cache Swift Package Manager
uses: actions/cache@v5
with:
path: |
~/Library/Caches/org.swift.swiftpm
~/Library/org.swift.swiftpm
Bitkit.xcodeproj/project.xcworkspace/xcshareddata/swiftpm
key: ${{ runner.os }}-spm-${{ hashFiles('**/Package.resolved') }}
- name: Install dependencies
run: |
echo "⏱️ Starting dependency resolution at $(date)"
xcodebuild -resolvePackageDependencies -onlyUsePackageVersionsFromResolvedFile | xcbeautify
echo "✅ Dependencies resolved at $(date)"
- name: Pre-start simulator
run: |
echo "⏱️ Starting simulator at $(date)"
xcrun simctl boot "iPhone 17" || true
echo "✅ Simulator started at $(date)"
- name: Build iOS app (regtest)
env:
GITHUB_ACTOR: ${{ github.actor }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SIMULATOR_NAME: "iPhone 17"
OS_VERSION: "26.2"
GEO: false
E2E_BACKEND: network
E2E_NETWORK: regtest
run: |
echo "=== Building iOS app (regtest) ==="
echo "Using simulator: $SIMULATOR_NAME (iOS $OS_VERSION)"
if xcodebuild -showsdks | grep -q "iOS Simulator"; then
echo "✅ iOS Simulator platform already installed"
else
echo "⚙️ iOS Simulator platform not found — downloading..."
xcodebuild -downloadPlatform iOS
fi
xcodebuild -workspace Bitkit.xcodeproj/project.xcworkspace \
-scheme Bitkit \
-configuration Debug \
-destination "platform=iOS Simulator,name=$SIMULATOR_NAME,OS=$OS_VERSION" \
-derivedDataPath DerivedData \
SWIFT_ACTIVE_COMPILATION_CONDITIONS='DEBUG E2E_BUILD' \
-allowProvisioningUpdates \
build
- name: Prepare app for E2E tests (regtest)
run: |
# Copy the .app bundle to the expected location and name
mkdir -p e2e-app
cp -r DerivedData/Build/Products/Debug-iphonesimulator/Bitkit.app e2e-app/bitkit.app
- name: Upload iOS app (regtest)
uses: actions/upload-artifact@v6
with:
name: bitkit-e2e-ios-regtest_${{ github.run_number }}
path: e2e-app/
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: [self-hosted, macOS]
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: security, grep: "@security" }
- { name: e2e, grep: '@transfer|@send|@lnurl|@lightning|@backup|@onboarding|@onchain_1|@onchain_2|@numberpad|@widgets|@boost|@receive|@settings|@security|@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: Download iOS app
uses: actions/download-artifact@v6
with:
name: bitkit-e2e-ios_${{ github.run_number }}
path: bitkit-e2e-tests/aut
- name: List iOS app 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: Docker info
run: |
docker --version
docker info
docker ps
docker compose version
- name: Reset regtest environment
working-directory: bitkit-e2e-tests
continue-on-error: true
run: |
cd docker && docker compose --verbose down -v -t 300
- name: Run regtest setup
working-directory: bitkit-e2e-tests
run: |
cd docker
mkdir -p lnd && chmod 777 lnd
docker compose --verbose up --force-recreate -d
- name: Wait for electrum server
working-directory: bitkit-e2e-tests
run: |
echo "Waiting for Electrum server..."
while ! nc -z '127.0.0.1' 60001; do
echo "Electrum server not ready, waiting..."
sleep 5
done
echo "Electrum server is ready!"
- name: Clear previous E2E artifacts
working-directory: bitkit-e2e-tests
run: |
rm -rf artifacts/
rm -rf /tmp/lock/
- name: Clear iOS Simulator environment
run: |
echo "🔧 Shutting down all running iOS simulators..."
xcrun simctl shutdown all || true
echo "🔧 Erasing target simulator: iPhone 17..."
xcrun simctl erase "iPhone 17" || true
echo "🔧 Disabling iOS Simulator notifications..."
defaults write com.apple.iphonesimulator DisableAllNotifications -bool true
- name: Run E2E Tests 1 (${{ matrix.shard.name }})
continue-on-error: true
id: test1
working-directory: bitkit-e2e-tests
run: ./ci_run_ios.sh --mochaOpts.grep '${{ matrix.shard.grep }}'
env:
RECORD_VIDEO: true
ATTEMPT: 1
- name: Run E2E Tests 2 (${{ matrix.shard.name }})
continue-on-error: true
if: steps.test1.outcome != 'success'
id: test2
working-directory: bitkit-e2e-tests
run: ./ci_run_ios.sh --mochaOpts.grep "${{ matrix.shard.grep }}"
env:
RECORD_VIDEO: true
ATTEMPT: 2
- name: Run E2E Tests 3 (${{ matrix.shard.name }})
if: steps.test1.outcome != 'success' && steps.test2.outcome != 'success'
id: test3
working-directory: bitkit-e2e-tests
run: ./ci_run_ios.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: Cleanup Docker containers
if: always()
working-directory: bitkit-e2e-tests
run: |
cd docker && docker compose down -v || true
e2e-tests-staging:
if: github.event.pull_request.draft == false && needs.detect-changes.outputs.code == 'true'
runs-on: macos-latest
timeout-minutes: 90
needs: [detect-changes, build-staging, e2e-branch]
strategy:
fail-fast: false
matrix:
shard:
- { name: multi_address_2_regtest, grep: "@multi_address_2" }
- { name: pubky_paykit, grep: "@pubky" }
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: Download iOS app (regtest)
uses: actions/download-artifact@v6
with:
name: bitkit-e2e-ios-regtest_${{ github.run_number }}
path: bitkit-e2e-tests/aut
- name: List iOS app 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: Install ffmpeg
run: |
echo "Installing ffmpeg with Homebrew..."
brew install ffmpeg
echo "ffmpeg version: $(ffmpeg -version | head -1)"
- name: Boot Simulator
run: |
echo "Erasing simulator..."
xcrun simctl erase "iPhone 17" || true
echo "Booting simulator..."
xcrun simctl boot "iPhone 17" || true
echo "Waiting for boot status..."
xcrun simctl bootstatus "iPhone 17" -b
echo "Opening Simulator app to ensure UI is ready..."
open -a Simulator
echo "Waiting for simulator to fully initialize..."
sleep 30
echo "Verifying simulator state..."
xcrun simctl list devices booted
- name: Run E2E Tests 1 (${{ matrix.shard.name }})
continue-on-error: true
id: test1
working-directory: bitkit-e2e-tests
run: ./ci_run_ios.sh --mochaOpts.grep '${{ matrix.shard.grep }}'
env:
BACKEND: regtest
SIMULATOR_NAME: "iPhone 17"
SIMULATOR_OS_VERSION: "26.2"
RECORD_VIDEO: true
ATTEMPT: 1
- name: Run E2E Tests 2 (${{ matrix.shard.name }})
continue-on-error: true
if: steps.test1.outcome != 'success'
id: test2
working-directory: bitkit-e2e-tests
run: ./ci_run_ios.sh --mochaOpts.grep "${{ matrix.shard.grep }}"
env:
BACKEND: regtest
SIMULATOR_NAME: "iPhone 17"
SIMULATOR_OS_VERSION: "26.2"
RECORD_VIDEO: true
ATTEMPT: 2
- name: Reset iOS Simulator before attempt 3
if: steps.test1.outcome != 'success' && steps.test2.outcome != 'success'
run: |
echo "🔁 Resetting iOS simulator before attempt 3..."
xcrun simctl shutdown all || true
xcrun simctl erase "iPhone 17" || true
xcrun simctl boot "iPhone 17" || true
xcrun simctl bootstatus "iPhone 17" -b
open -a Simulator
sleep 15
xcrun simctl list devices booted
- name: Run E2E Tests 3 (${{ matrix.shard.name }})
if: steps.test1.outcome != 'success' && steps.test2.outcome != 'success'
id: test3
working-directory: bitkit-e2e-tests
run: ./ci_run_ios.sh --mochaOpts.grep "${{ matrix.shard.grep }}"
env:
BACKEND: regtest
SIMULATOR_NAME: "iPhone 17"
SIMULATOR_OS_VERSION: "26.2"
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/
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!"