-
Notifications
You must be signed in to change notification settings - Fork 16
571 lines (482 loc) Β· 20.2 KB
/
Copy pathios-e2e.yml
File metadata and controls
571 lines (482 loc) Β· 20.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
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
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
name: iOS E2E Tests
permissions:
contents: read
on:
pull_request:
branches: [main, release, emergency-release, "v*.*.*"]
push:
branches: [main, release, emergency-release, "v*.*.*"]
workflow_dispatch:
inputs:
ref:
description:
"Commit hash to run tests on (leave empty for default workflow branch)"
required: false
type: string
env:
NODE_VERSION: "20"
RUBY_VERSION: 3.1.4
APP_ID: "org.stellar.freighterdev"
APPLE_CONNECT_KEY_ID: "skip-android-16kb-setup"
# Sentry configuration (disabled for E2E, but vars still needed)
SENTRY_PROPERTIES_CONTENT: "disabled-for-e2e"
SENTRY_DSN: "disabled-for-e2e"
# Amplitude Analytics configuration (disabled for E2E)
AMPLITUDE_API_KEY: "disabled-for-e2e"
AMPLITUDE_EXPERIMENT_DEPLOYMENT_KEY: "disabled-for-e2e"
# Backend URLs configuration
FREIGHTER_BACKEND_V1_PROD_URL: ${{ vars.FREIGHTER_BACKEND_V1_PROD_URL }}
FREIGHTER_BACKEND_V1_STG_URL: ${{ vars.FREIGHTER_BACKEND_V1_STG_URL }}
FREIGHTER_BACKEND_V1_DEV_URL: ${{ vars.FREIGHTER_BACKEND_V1_DEV_URL }}
FREIGHTER_BACKEND_V2_PROD_URL: ${{ vars.FREIGHTER_BACKEND_V2_PROD_URL }}
FREIGHTER_BACKEND_V2_STG_URL: ${{ vars.FREIGHTER_BACKEND_V2_STG_URL }}
FREIGHTER_BACKEND_V2_DEV_URL: ${{ vars.FREIGHTER_BACKEND_V2_DEV_URL }}
# Wallet Kit Configuration (Production)
WALLET_KIT_PROJECT_ID_PROD: ${{ secrets.WALLET_KIT_PROJECT_ID_PROD }}
WALLET_KIT_MT_NAME_PROD: ${{ vars.WALLET_KIT_MT_NAME_PROD }}
WALLET_KIT_MT_DESCRIPTION_PROD: ${{ vars.WALLET_KIT_MT_DESCRIPTION_PROD }}
WALLET_KIT_MT_URL_PROD: ${{ vars.WALLET_KIT_MT_URL_PROD }}
WALLET_KIT_MT_ICON_PROD: ${{ vars.WALLET_KIT_MT_ICON_PROD }}
WALLET_KIT_MT_REDIRECT_NATIVE_PROD:
${{ vars.WALLET_KIT_MT_REDIRECT_NATIVE_PROD }}
# Wallet Kit Configuration (Development)
WALLET_KIT_PROJECT_ID_DEV: ${{ secrets.WALLET_KIT_PROJECT_ID_DEV }}
WALLET_KIT_MT_NAME_DEV: ${{ vars.WALLET_KIT_MT_NAME_DEV }}
WALLET_KIT_MT_DESCRIPTION_DEV: ${{ vars.WALLET_KIT_MT_DESCRIPTION_DEV }}
WALLET_KIT_MT_URL_DEV: ${{ vars.WALLET_KIT_MT_URL_DEV }}
WALLET_KIT_MT_ICON_DEV: ${{ vars.WALLET_KIT_MT_ICON_DEV }}
WALLET_KIT_MT_REDIRECT_NATIVE_DEV:
${{ vars.WALLET_KIT_MT_REDIRECT_NATIVE_DEV }}
# MP Collections Addresses (comma-separated list of collection addresses)
MP_COLLECTIONS_ADDRESSES: ${{ vars.MP_COLLECTIONS_ADDRESSES }}
# E2E Test Configuration
IS_E2E_TEST: "true"
E2E_TEST_RECOVERY_PHRASE: ${{ secrets.E2E_TEST_RECOVERY_PHRASE }}
E2E_TEST_FUNDED_RECOVERY_PHRASE:
${{ secrets.E2E_TEST_FUNDED_RECOVERY_PHRASE }}
IS_CI_ENV: "true"
jobs:
build:
name: Build iOS App
# Security guard: avoid running this job when it's a pull request from a fork.
if: >-
github.event_name != 'pull_request' ||
github.event.pull_request.head.repo.full_name == github.repository
runs-on: macos-26-xlarge
timeout-minutes: 120
steps:
- name: Checkout repo
uses: actions/checkout@v5
with:
ref: ${{ github.event.inputs.ref || github.ref }}
- name: Make scripts executable
run: find scripts -type f -exec chmod +x {} \;
- name: Display iOS environment information
run: ./scripts/display-ios-environment
- name: Set latest stable Xcode version
run: ./scripts/setup-xcode-latest-stable
- name: Verify selected Xcode Version
run: xcodebuild -version
- name: Enable Corepack
run: corepack enable
- name: Set up Node
uses: actions/setup-node@v6
with:
node-version: ${{ env.NODE_VERSION }}
cache: "yarn"
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ env.RUBY_VERSION }}
bundler-cache: true
- name: Set env and create .env file
run: |
export IOS_SCHEME="freighter-mobile-dev"
./scripts/gh-ios-env >> $GITHUB_ENV
- name: Cache CocoaPods
uses: actions/cache@v4
with:
path: |
ios/Pods
~/Library/Caches/CocoaPods
~/.cocoapods
key: ${{ runner.os }}-pods-${{ hashFiles('ios/Podfile.lock') }}
restore-keys: |
${{ runner.os }}-pods-
- name: Install ccache
run: brew install ccache
- name: Cache ccache
uses: actions/cache@v4
with:
path: ~/Library/Caches/ccache
key: ${{ runner.os }}-ccache-${{ hashFiles('ios/Podfile.lock') }}
restore-keys: |
${{ runner.os }}-ccache-
- name: Configure ccache
run: |
ccache --set-config=compiler_check=content
ccache --set-config=max_size=2G
ccache --zero-stats
- name: Run Yarn Install
run: yarn install --immutable
- name: Run Post Install
run: yarn postinstall
- name: Build iOS app for simulator
env:
SENTRY_DISABLE_AUTO_UPLOAD: "true"
run: |
cd ios
# Get absolute path to entitlements file
ENTITLEMENTS_PATH="$(pwd)/freighter-mobile/freighter-mobile-dev.entitlements"
echo "Using entitlements file at: $ENTITLEMENTS_PATH"
if [ ! -f "$ENTITLEMENTS_PATH" ]; then
echo "β Error: Entitlements file not found at $ENTITLEMENTS_PATH"
exit 1
fi
xcodebuild -workspace freighter-mobile.xcworkspace \
-scheme freighter-mobile-dev \
-configuration Release \
-sdk iphonesimulator \
-destination 'platform=iOS Simulator,name=iPhone 17 Pro,OS=26.2' \
-derivedDataPath ./build \
CODE_SIGNING_ALLOWED=YES \
CODE_SIGN_IDENTITY="-" \
CODE_SIGN_ENTITLEMENTS="$ENTITLEMENTS_PATH" \
CODE_SIGNING_REQUIRED=NO \
ONLY_ACTIVE_ARCH=YES \
COMPILER_INDEX_STORE_ENABLE=NO \
DEBUG_INFORMATION_FORMAT=dwarf
# Find the .app bundle (relative to ios/)
APP_PATH=$(find ./build/Build/Products/Release-iphonesimulator -name "*.app" -type d | head -n 1)
if [ -z "$APP_PATH" ]; then
echo "Error: .app bundle not found"
exit 1
fi
echo "Built app at: $APP_PATH (relative to ios/)"
# Get absolute path to repo root
REPO_ROOT="$(cd "$(git rev-parse --show-toplevel 2>/dev/null || pwd)" && pwd)"
# Remove leading ./ from APP_PATH if present
APP_PATH_CLEAN="${APP_PATH#./}"
# Create archive in repo root using absolute paths
cd "$REPO_ROOT"
tar -czf "$REPO_ROOT/app.tar.gz" -C "$REPO_ROOT/ios" "$APP_PATH_CLEAN"
# Verify archive was created
if [ -f "$REPO_ROOT/app.tar.gz" ]; then
echo "β
Created archive at: $REPO_ROOT/app.tar.gz"
ls -lh "$REPO_ROOT/app.tar.gz"
else
echo "β Error: Archive was not created at $REPO_ROOT/app.tar.gz"
echo "Current directory: $(pwd)"
echo "APP_PATH_CLEAN: $APP_PATH_CLEAN"
exit 1
fi
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: ios-e2e-build-${{ github.run_id }}
path: app.tar.gz
retention-days: 2
if-no-files-found: error
test:
name: E2E ${{ matrix.flow-name }}
needs: build
runs-on: macos-26-xlarge
timeout-minutes: 120
strategy:
fail-fast: false
# Running E2E flow tests in parallel shards:
# - LaunchAndInspect: Launch and inspect app state
# - CreateWallet: Basic wallet creation flow
# - ImportWallet: Import existing wallet with recovery phrase
# - ImportFundedWallet: Import wallet with funded account
# - SwitchToTestnet: Switch network to testnet
# - SendClassicTokenMainnet: Send XLM on mainnet (small amount: 0.000001 XLM)
# - SendClassicTokenMainnetFromDetails: Send XLM on mainnet starting from Token Details screen (small amount: 0.000001 XLM)
# - SwapClassicTokenMainnet: Swap tokens on mainnet (small amount: 0.000001 XLM)
# - ForgotPasswordWarning: Lock screen forgot password confirmation modal
# - SendFederatedAddress: Send XLM and USDC to a federated address on mainnet (small amount: 0.000001 each)
# - SignMessageMockDapp: WalletConnect sign message (requires mock server)
# - SignAuthEntryMockDapp: WalletConnect sign auth entry (requires mock server)
# Note: mock-dapp tests use shard-index:0, to run sequentially in isolation,
# to avoid e2e test flakiness related to starting/stopping the mock server and potential port conflicts.
matrix:
include:
- shard-index: 0
shard-total: 10
flow-name: LaunchAndInspect
requires-mock-server: false
- shard-index: 1
shard-total: 10
flow-name: CreateWallet
requires-mock-server: false
- shard-index: 2
shard-total: 10
flow-name: ImportWallet
requires-mock-server: false
- shard-index: 3
shard-total: 10
flow-name: ImportFundedWallet
requires-mock-server: false
- shard-index: 4
shard-total: 10
flow-name: SwitchToTestnet
requires-mock-server: false
- shard-index: 5
shard-total: 10
flow-name: SendClassicTokenMainnet
requires-mock-server: false
- shard-index: 6
shard-total: 10
flow-name: SwapClassicTokenMainnet
requires-mock-server: false
- shard-index: 7
shard-total: 10
flow-name: ForgotPasswordWarning
requires-mock-server: false
- shard-index: 8
shard-total: 10
flow-name: SendFederatedAddress
requires-mock-server: false
- shard-index: 9
shard-total: 10
flow-name: SendClassicTokenMainnetFromDetails
requires-mock-server: false
- shard-index: 0
shard-total: 10
flow-name: SignMessageMockDapp
requires-mock-server: true
- shard-index: 0
shard-total: 10
flow-name: SignAuthEntryMockDapp
requires-mock-server: true
steps:
- name: Checkout repo
uses: actions/checkout@v5
with:
ref: ${{ github.event.inputs.ref || github.ref }}
- name: Make scripts executable
run: find scripts -type f -exec chmod +x {} \;
- name: Enable Corepack
run: corepack enable
- name: Set up Node
uses: actions/setup-node@v6
with:
node-version: ${{ env.NODE_VERSION }}
cache: "yarn"
- name: Install idb-companion
run: |
brew tap facebook/fb
brew install facebook/fb/idb-companion
- name: Cache Maestro
uses: actions/cache@v4
with:
path: ~/.maestro
key: ${{ runner.os }}-maestro-v1
- name: Install Maestro
run: |
if [ ! -f "$HOME/.maestro/bin/maestro" ]; then
echo "Maestro not found in cache, installing..."
curl -fsSL "https://get.maestro.mobile.dev" | bash
else
echo "Maestro found in cache"
fi
export PATH="$PATH:$HOME/.maestro/bin"
maestro --version
- name: Download build artifact
uses: actions/download-artifact@v4
with:
name: ios-e2e-build-${{ github.run_id }}
path: downloaded-artifacts
- name: Extract app bundle
run: |
cd downloaded-artifacts
echo "=== Extracting app.tar.gz ==="
tar -xzf app.tar.gz
echo "=== Contents after extraction ==="
find . -type d -name "*.app" 2>/dev/null | head -5
echo "=== Directory structure ==="
ls -la
if [ -d "ios" ]; then
echo "=== Contents of ios/ directory ==="
find ios -type d -name "*.app" 2>/dev/null | head -5
fi
- name: Run Yarn Install
env:
SKIP_COCOAPODS: "yes"
run: yarn install --immutable
- name: Start Mock WalletConnect Server (for WalletConnect tests)
if: matrix.requires-mock-server
run: |
set -euo pipefail
# Create .env file for mock dApp (not checked in git)
echo "π Creating mock dApp .env file..."
cat > mock-dapp/.env << EOF
# WalletConnect Project ID
# Using DEV project ID for E2E testing with freighterdev app
WALLET_KIT_PROJECT_ID=${{ secrets.WALLET_KIT_PROJECT_ID_DEV }}
# Server configuration
PORT=3001
HOST=0.0.0.0
# Logging
LOG_LEVEL=debug
# Mobile app deep link scheme (dev build)
MOBILE_APP_SCHEME=freighterdev
EOF
# Add scripts to PATH
chmod +x e2e/scripts/*.sh
# Start the mock server
echo "π Starting mock WalletConnect dApp server..."
./e2e/scripts/start-mock-server.sh
# Print server log so it's visible in CI (not just on failure)
echo "--- mock-dapp server log ---"
cat mock-dapp/.server.log || true
echo "----------------------------"
# Store the PID for cleanup
# PID file is written to mock-dapp/.server.pid (repo root / mock-dapp)
if [ -f "mock-dapp/.server.pid" ]; then
echo "β
Mock server started successfully (PID: $(cat mock-dapp/.server.pid))"
cp mock-dapp/.server.pid /tmp/mock-server.pid
else
echo "β Failed to start mock server (PID file not found at mock-dapp/.server.pid)"
exit 1
fi
- name: Boot iOS Simulator
id: simulator
uses: futureware-tech/simulator-action@v4
with:
model: "iPhone 16e"
os_version: "26.2"
wait_for_boot: false
erase_before_boot: false
shutdown_after_job: false
- name: Optimize Simulator Performance
run: |
set -euo pipefail
DEVICE_UDID="${{ steps.simulator.outputs.udid }}"
echo "Optimizing simulator performance for device: $DEVICE_UDID"
# Wait for simulator to be fully ready
sleep 5
# Disable animations via accessibility settings
xcrun simctl spawn "$DEVICE_UDID" defaults write com.apple.Accessibility ReduceMotionEnabled -bool true 2>/dev/null || true
# Disable transparency effects
xcrun simctl spawn "$DEVICE_UDID" defaults write com.apple.universalaccess reduceTransparency -bool true 2>/dev/null || true
# Disable location services to reduce background processing
xcrun simctl privacy "$DEVICE_UDID" revoke location all 2>/dev/null || true
# Disable background app refresh
xcrun simctl spawn "$DEVICE_UDID" defaults write com.apple.BackgroundTaskManagement BackgroundAppRefreshEnabled -bool false 2>/dev/null || true
# Reduce window scale for better performance
defaults write com.apple.iphonesimulator SimulatorWindowLastScale "0.75" 2>/dev/null || true
echo "β
Simulator performance optimizations applied"
- name: Install app in Simulator
run: |
set -euo pipefail # Exit on error, undefined vars, pipe failures
echo "=== Finding .app bundle ==="
find downloaded-artifacts -type d -name "*.app" 2>/dev/null | head -5
APP_PATH=$(find downloaded-artifacts -type d -name "*.app" 2>/dev/null | head -n 1)
if [ -z "$APP_PATH" ]; then
echo "β Error: .app bundle not found in downloaded-artifacts"
echo "=== Contents of downloaded-artifacts ==="
ls -la downloaded-artifacts/ || true
if [ -d "downloaded-artifacts/ios" ]; then
echo "=== Contents of downloaded-artifacts/ios ==="
find downloaded-artifacts/ios -type d -name "*.app" 2>/dev/null || true
fi
exit 1
fi
if [ ! -d "$APP_PATH" ]; then
echo "β Error: .app bundle path is not a directory: $APP_PATH"
exit 1
fi
echo "Found .app bundle at: $APP_PATH"
# Get device UDID from simulator step output
# Note: simulator-action outputs 'udid', not 'device-udid'
DEVICE_UDID="${{ steps.simulator.outputs.udid }}"
if [ -z "$DEVICE_UDID" ]; then
echo "β Error: Device UDID is empty. Available outputs from simulator step:"
echo "udid: ${{ steps.simulator.outputs.udid }}"
echo "device-udid: ${{ steps.simulator.outputs.device-udid }}"
exit 1
fi
echo "Device UDID: $DEVICE_UDID"
# Convert to absolute path
APP_PATH_ABS=$(cd "$(dirname "$APP_PATH")" && pwd)/$(basename "$APP_PATH")
echo "Absolute path: $APP_PATH_ABS"
echo "=== Installing app ==="
xcrun simctl install "$DEVICE_UDID" "$APP_PATH_ABS" || {
echo "β Error: Failed to install app on simulator"
exit 1
}
echo "β
App installed successfully: $APP_PATH_ABS"
- name: Set recovery phrase in simulator clipboard
run: |
set -euo pipefail
DEVICE_UDID="${{ steps.simulator.outputs.udid }}"
if [ -z "${E2E_TEST_RECOVERY_PHRASE:-}" ]; then
echo "β Error: E2E_TEST_RECOVERY_PHRASE secret is not set"
exit 1
fi
echo "$E2E_TEST_RECOVERY_PHRASE" | xcrun simctl pbcopy "$DEVICE_UDID"
echo "β
Recovery phrase set in simulator clipboard (for ImportWallet clipboard button)"
- name: Run E2E tests
env:
MAESTRO_DISABLE_UPDATE_CHECK: "true"
MAESTRO_CLI_NO_ANALYTICS: "true"
DEVICE_UDID: ${{ steps.simulator.outputs.udid }}
run: |
set -euo pipefail # Exit on error, undefined vars, pipe failures
DEVICE_UDID="${{ steps.simulator.outputs.udid }}"
APP_ID="org.stellar.freighterdev"
LOG_FILE="e2e-artifacts/ios-simulator-logs.txt"
# Start capturing iOS simulator logs in the background
echo "π± Starting iOS simulator log capture..."
mkdir -p e2e-artifacts
xcrun simctl spawn "$DEVICE_UDID" log stream --level=debug --predicate 'processImagePath contains "freighter"' > "$LOG_FILE" 2>&1 &
LOG_PID=$!
echo "β
Log capture started (PID: $LOG_PID)"
# Cleanup function
cleanup() {
if [ -n "${LOG_PID:-}" ]; then
echo "π Stopping log capture..."
kill "$LOG_PID" 2>/dev/null || true
wait "$LOG_PID" 2>/dev/null || true
fi
}
trap cleanup EXIT INT TERM
# Verify Maestro is installed and accessible
MAESTRO_PATH="$HOME/.maestro/bin/maestro"
if [ ! -f "$MAESTRO_PATH" ]; then
echo "β Error: Maestro not found at $MAESTRO_PATH"
exit 1
fi
# Add Maestro to PATH and verify
export PATH="$PATH:$HOME/.maestro/bin"
if ! command -v maestro &> /dev/null; then
echo "β Error: maestro command not found in PATH"
echo "PATH: $PATH"
exit 1
fi
echo "β
Maestro found: $(maestro --version)"
echo "Running E2E tests (${{ matrix.flow-name }}, shard ${{ matrix.shard-index }}/${{ matrix.shard-total }})..."
yarn test:e2e -- --platform ios --shard-index ${{ matrix.shard-index }} --shard-total ${{ matrix.shard-total }} ${{ matrix.flow-name }} || {
echo "β Error: E2E tests failed"
exit 1
}
echo "β
All E2E tests passed"
- name: Upload test artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: ios-e2e-results-${{ github.run_id }}-${{ matrix.flow-name }}
path: e2e-artifacts/
retention-days: 7
if-no-files-found: ignore
- name: Stop Mock WalletConnect Server
if: always() && matrix.requires-mock-server
run: |
set -euo pipefail
# Add scripts to PATH
chmod +x e2e/scripts/*.sh
# Stop the mock server
echo "π Stopping mock WalletConnect dApp server..."
./e2e/scripts/stop-mock-server.sh
echo "β
Mock server stopped"