-
Notifications
You must be signed in to change notification settings - Fork 16
428 lines (364 loc) Β· 14.8 KB
/
Copy pathandroid-e2e.yml
File metadata and controls
428 lines (364 loc) Β· 14.8 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
name: Android 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: "22"
RUBY_VERSION: 3.1.4
JAVA_VERSION: "17"
SKIP_COCOAPODS: "yes"
APP_ID: "org.stellar.freighterdev"
# 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"
# Android Keystores configuration (for create_keystore_file)
ANDROID_DEV_KEYSTORE_CONTENT: ${{ secrets.ANDROID_DEV_KEYSTORE_CONTENT }}
# Android Keystore Passwords and Aliases (for build.gradle)
ANDROID_DEV_KEYSTORE_PASSWORD: ${{ secrets.ANDROID_DEV_KEYSTORE_PASSWORD }}
ANDROID_DEV_KEYSTORE_ALIAS: ${{ vars.ANDROID_DEV_KEYSTORE_ALIAS }}
# Backend URLs
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 Android APK
# 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: ubuntu-latest-16-cores
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: 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 ANDROID_FLAVOR="dev"
./scripts/gh-android-env >> $GITHUB_ENV
- name: Set up JDK 17
uses: actions/setup-java@v5
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: zulu
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
- name: Set up Android SDK and NDK for 16KB page size alignment
run: ./scripts/setup-android-ndk-16kb
- name: Create Android keystore file
run: |
echo "Creating dev-release.keystore file..."
mkdir -p android/keystores
echo "$ANDROID_DEV_KEYSTORE_CONTENT" | base64 -d > android/keystores/dev-release.keystore
ls -lh android/keystores/dev-release.keystore
- name: Run Yarn Install
run: yarn install --immutable
- name: Run Post Install
run: yarn postinstall
- name: Build Android APK for emulator
env:
SENTRY_DISABLE_AUTO_UPLOAD: "true"
run: |
cd android
./gradlew assembleDevRelease \
-PreactNativeArchitectures=x86_64 \
--parallel \
--build-cache
# Find APK with relative path from android directory
APK_PATH_REL=$(find ./app/build/outputs/apk/dev/release -name "*.apk" | head -n 1)
if [ -z "$APK_PATH_REL" ]; then
echo "Error: APK not found in ./app/build/outputs/apk/dev/release"
echo "Searching for APK files:"
find ./app/build/outputs -name "*.apk" 2>/dev/null || true
echo "Contents of ./app/build/outputs/apk/dev/release:"
ls -la ./app/build/outputs/apk/dev/release/ 2>/dev/null || true
exit 1
fi
echo "Built APK at: $APK_PATH_REL (relative to android/)"
# Get absolute path before changing directory
REPO_ROOT=$(pwd)/..
APK_PATH_ABS="$REPO_ROOT/android/$APK_PATH_REL"
# Verify the file exists
if [ ! -f "$APK_PATH_ABS" ]; then
echo "Error: APK file does not exist at: $APK_PATH_ABS"
exit 1
fi
cd ..
# Copy to repo root with absolute path
cp "$APK_PATH_ABS" app.apk
# Verify copy was successful
if [ ! -f "app.apk" ]; then
echo "Error: Failed to copy APK to app.apk"
exit 1
fi
echo "β
APK copied successfully: $(pwd)/app.apk"
ls -lh app.apk
echo "APK_PATH=$(pwd)/app.apk" >> $GITHUB_ENV
- name: Clean up build artifacts
run: |
echo "=== Disk space before cleanup ==="
df -h
echo "=== Cleaning up Android build artifacts ==="
# Remove build outputs we don't need (keep only the APK)
rm -rf android/app/build/outputs/bundle
rm -rf android/app/build/intermediates
rm -rf android/app/build/tmp
rm -rf android/.gradle
echo "=== Cleaning up Gradle cache ==="
rm -rf ~/.gradle/caches
rm -rf ~/.gradle/daemon
echo "=== Cleaning up node_modules build artifacts ==="
find node_modules -name "*.o" -delete 2>/dev/null || true
find node_modules -name "*.a" -delete 2>/dev/null || true
echo "=== Disk space after cleanup ==="
df -h
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: android-e2e-build-${{ github.run_id }}
path: app.apk
retention-days: 2
test:
name: E2E ${{ matrix.flow-name }}
needs: build
runs-on: ubuntu-latest-16-cores
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
# - ImportAndSwitchToTestnet: Import funded wallet and switch network to testnet
# - SendClassicToken: Send XLM on testnet (small amount: 0.000001 XLM)
# - SendClassicTokenFromDetails: Send XLM on testnet starting from Token Details screen (small amount: 0.000001 XLM)
# - SwapClassicToken: Swap tokens on testnet (small amount: 0.000001 XLM)
# - ForgotPasswordWarning: Lock screen forgot password confirmation modal
# - SendFederatedAddress: Send XLM and USDC to a federated address on testnet (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: ImportAndSwitchToTestnet
requires-mock-server: false
- shard-index: 5
shard-total: 10
flow-name: SendClassicToken
requires-mock-server: false
- shard-index: 6
shard-total: 10
flow-name: SwapClassicToken
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: SendClassicTokenFromDetails
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: Set up Android SDK and NDK for 16KB page size alignment
run: ./scripts/setup-android-ndk-16kb
- 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: android-e2e-build-${{ github.run_id }}
path: downloaded-artifacts
- name: Run Yarn Install
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
# Store the PID for cleanup
# PID file is written to mock-dapp/.server.pid (start-mock-server.sh resolves
# relative to the mock-dapp directory which sits at the repo root).
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: Enable KVM for hardware acceleration
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: Boot Android Emulator and Run E2E Tests
uses: reactivecircus/android-emulator-runner@v2
id: emulator
continue-on-error: false
env:
MAESTRO_DISABLE_UPDATE_CHECK: "true"
MAESTRO_CLI_NO_ANALYTICS: "true"
SHARD_INDEX: ${{ matrix.shard-index }}
SHARD_TOTAL: ${{ matrix.shard-total }}
FLOW_NAME: ${{ matrix.flow-name }}
with:
api-level: 33
arch: x86_64
profile: pixel_7
cores: 4
ram-size: 4096
emulator-options:
"-no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio
-no-boot-anim -partition-size 4096 -cache-size 1024 -accel on"
disable-animations: true
script: ./scripts/run-android-e2e-on-emulator.sh
- name: Upload test artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: android-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"