-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
392 lines (361 loc) · 17.1 KB
/
Copy pathrun-appium-e2e-workflow.yml
File metadata and controls
392 lines (361 loc) · 17.1 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
# Runs Appium smoke tests for one smoke tag on Android or iOS.
# Called from run-appium-smoke-tests-{android,ios}.yml (one job per tag/split).
name: Run Appium E2E
on:
workflow_call:
inputs:
test-suite-name:
description: 'Name of the test suite (used for artifacts and report paths)'
required: true
type: string
platform:
description: 'Platform to test (ios or android)'
required: true
type: string
test_suite_tag:
description: 'Smoke tag id to filter tests (e.g. SmokeAccounts matches describe titles)'
required: true
type: string
split_number:
description: 'Which shard to run (1-based index)'
required: false
type: number
default: 1
total_splits:
description: 'Total number of shards for this tag'
required: false
type: number
default: 1
test-timeout-minutes:
description: 'Timeout in minutes for the Playwright test step'
required: false
type: number
default: 25
build_type:
description: 'Build type (main or flask)'
required: false
type: string
default: 'main'
metamask_environment:
description: 'MetaMask environment'
required: false
type: string
default: 'e2e'
runner_provider:
description: 'Runner provider (namespace or current)'
required: false
type: string
default: 'current'
permissions:
contents: read
checks: write
jobs:
test-appium-mobile:
name: ${{ inputs.test-suite-name }}
runs-on: >-
${{
inputs.runner_provider == 'namespace' &&
(inputs.platform == 'ios' && 'namespace-profile-metamask-ios-e2e' ||
'namespace-profile-metamask-android-build') ||
(inputs.platform == 'ios' &&
(startsWith(github.base_ref, 'release/') &&
fromJSON('["ghcr.io/cirruslabs/macos-runner:tahoe"]') ||
fromJSON('["ghcr.io/cirruslabs/macos-runner:tahoe", "low-priority"]'))) ||
(startsWith(github.base_ref, 'release/') &&
fromJSON('["ghcr.io/cirruslabs/ubuntu-runner-amd64:24.04-lg"]') ||
fromJSON('["ghcr.io/cirruslabs/ubuntu-runner-amd64:24.04-lg", "low-priority"]'))
}}
steps:
- name: Checkout (Namespace)
uses: namespacelabs/nscloud-checkout-action@938f5d2d403d6224d9a0c0dc559b1dae09c2ede4 # v8.1.1
if: ${{ inputs.runner_provider == 'namespace' }}
- name: Checkout
uses: actions/checkout@v4
if: ${{ inputs.runner_provider != 'namespace' }}
- name: Setup E2E environment (Android)
if: ${{ inputs.platform == 'android' }}
uses: ./.github/actions/setup-e2e-env
with:
platform: android
setup-simulator: 'true'
android-avd-name: appium_smoke_avd
android-api-level: '34'
android-tag: default
android-abi: x86_64
android-device: pixel_5
configure-keystores: 'false'
install-foundry: 'true'
runner_provider: ${{ inputs.runner_provider }}
- name: Setup E2E environment (iOS)
if: ${{ inputs.platform == 'ios' }}
uses: ./.github/actions/setup-e2e-env
with:
platform: ios
setup-simulator: 'false'
configure-keystores: 'false'
install-foundry: 'true'
skip-pod-install: 'true'
install-applesimutils: 'false'
runner_provider: ${{ inputs.runner_provider }}
- name: Cache ffmpeg (Homebrew)
if: ${{ inputs.platform == 'ios' }}
uses: actions/cache@v4
with:
path: ~/.cache/mms-ffmpeg
key: brew-ffmpeg-${{ runner.os }}-v1
restore-keys: |
brew-ffmpeg-${{ runner.os }}-
- name: Install ffmpeg for XCUITest screen recording
if: ${{ inputs.platform == 'ios' }}
run: bash scripts/e2e/ensure-ffmpeg-ci.sh
shell: bash
- name: Determine Android artifact paths
if: ${{ inputs.platform == 'android' }}
id: android-artifacts
run: |
if [[ "${{ inputs.build_type }}" == "flask" ]]; then
{
echo "apk-target-path=android/app/build/outputs/apk/flask/release"
echo "apk-file-name=app-flask-release.apk"
} >> "$GITHUB_OUTPUT"
else
{
echo "apk-target-path=android/app/build/outputs/apk/prod/release"
echo "apk-file-name=app-prod-release.apk"
} >> "$GITHUB_OUTPUT"
fi
- name: Download Android build artifacts (Namespace)
if: ${{ inputs.platform == 'android' && inputs.runner_provider == 'namespace' }}
id: download-android-apk-namespace
continue-on-error: true
uses: namespace-actions/download-artifact@7cbad919e4b0e09f17e9d6311a444ff002992b5b # v2.0.1
with:
name: ${{ inputs.build_type }}-${{ inputs.metamask_environment }}-release.apk
path: ${{ steps.android-artifacts.outputs.apk-target-path }}
- name: Download Android build artifacts (GitHub — build may be on Cirrus)
if: >-
${{
inputs.platform == 'android' &&
inputs.runner_provider == 'namespace' &&
steps.download-android-apk-namespace.outcome != 'success'
}}
uses: actions/download-artifact@v4
with:
name: ${{ inputs.build_type }}-${{ inputs.metamask_environment }}-release.apk
path: ${{ steps.android-artifacts.outputs.apk-target-path }}
- name: Download Android build artifacts (current)
if: ${{ inputs.platform == 'android' && inputs.runner_provider != 'namespace' }}
uses: actions/download-artifact@v4
with:
name: ${{ inputs.build_type }}-${{ inputs.metamask_environment }}-release.apk
path: ${{ steps.android-artifacts.outputs.apk-target-path }}
- name: Download iOS build artifacts (Namespace)
if: ${{ inputs.platform == 'ios' && inputs.runner_provider == 'namespace' }}
uses: namespace-actions/download-artifact@7cbad919e4b0e09f17e9d6311a444ff002992b5b # v2.0.1
with:
name: ${{ inputs.build_type }}-${{ inputs.metamask_environment }}-MetaMask.app
path: artifacts/${{ inputs.build_type }}-${{ inputs.metamask_environment }}-MetaMask.app
- name: Download iOS build artifacts (current)
if: ${{ inputs.platform == 'ios' && inputs.runner_provider != 'namespace' }}
uses: actions/download-artifact@v4
with:
name: ${{ inputs.build_type }}-${{ inputs.metamask_environment }}-MetaMask.app
path: artifacts/${{ inputs.build_type }}-${{ inputs.metamask_environment }}-MetaMask.app
- name: Restore iOS bundle executable permissions
if: ${{ inputs.platform == 'ios' }}
env:
APP_PATH: artifacts/${{ inputs.build_type }}-${{ inputs.metamask_environment }}-MetaMask.app
run: |
BUNDLE_EXEC=$(/usr/libexec/PlistBuddy -c "Print CFBundleExecutable" "$APP_PATH/Info.plist" 2>/dev/null)
if [ -z "$BUNDLE_EXEC" ]; then
echo "Could not read CFBundleExecutable from Info.plist"
exit 1
fi
ACTUAL_PATH=$(find "$APP_PATH" -maxdepth 1 -iname "$BUNDLE_EXEC" -type f | head -1)
if [ -z "$ACTUAL_PATH" ]; then
echo "Bundle executable not found: $BUNDLE_EXEC"
exit 1
fi
if [ "$(basename "$ACTUAL_PATH")" != "$BUNDLE_EXEC" ]; then
mv "$ACTUAL_PATH" "$APP_PATH/${BUNDLE_EXEC}_fix"
mv "$APP_PATH/${BUNDLE_EXEC}_fix" "$APP_PATH/$BUNDLE_EXEC"
fi
chmod +x "$APP_PATH/$BUNDLE_EXEC"
if [ -d "$APP_PATH/Frameworks" ]; then
find "$APP_PATH/Frameworks" -type d -name "*.framework" | while IFS= read -r fw; do
binary="$fw/$(basename "$fw" .framework)"
if [ -f "$binary" ]; then
chmod +x "$binary"
fi
done
find "$APP_PATH/Frameworks" -type f -name "*.dylib" -exec chmod +x {} \;
fi
echo "Restored execute permissions on main binary and all framework binaries"
shell: bash
- name: Resolve XCUITest driver version for WDA cache key
if: ${{ inputs.platform == 'ios' }}
id: xcuitest-version
run: echo "version=$(node scripts/e2e/resolve-xcuitest-driver-version.mjs)" >> "$GITHUB_OUTPUT"
- name: Get Xcode version for WDA cache key
if: ${{ inputs.platform == 'ios' }}
id: xcode-version
run: echo "version=$(xcodebuild -version 2>/dev/null | head -1 | tr ' ' '-')" >> "$GITHUB_OUTPUT"
- name: Restore WDA DerivedData cache
if: ${{ inputs.platform == 'ios' }}
uses: actions/cache@v4
with:
path: ~/appium-wda
key: wda-derived-data-xcuitest-${{ steps.xcuitest-version.outputs.version }}-${{ steps.xcode-version.outputs.version }}-${{ runner.os }}
restore-keys: |
wda-derived-data-xcuitest-${{ steps.xcuitest-version.outputs.version }}-${{ steps.xcode-version.outputs.version }}-
- name: Check if WDA is prebuilt
if: ${{ inputs.platform == 'ios' }}
id: wda-prebuilt
run: |
WDA_APP=$(find ~/appium-wda/Build/Products -name 'WebDriverAgentRunner-Runner.app' -type d 2>/dev/null | head -1 || true)
XCTESTRUN=$(find ~/appium-wda/Build/Products -name '*.xctestrun' 2>/dev/null | head -1 || true)
if [ -n "$WDA_APP" ] && [ -n "$XCTESTRUN" ]; then
echo "ready=true" >> "$GITHUB_OUTPUT"
echo "WDA prebuilt artifacts found"
else
echo "ready=false" >> "$GITHUB_OUTPUT"
echo "WDA cache miss — prepare-ios-appium-runner will prebuild after sim boot"
fi
shell: bash
- name: Prepare iOS Appium runner
if: ${{ inputs.platform == 'ios' }}
id: prepare-ios-appium
timeout-minutes: 30
run: node scripts/e2e/prepare-ios-appium-runner.mjs
env:
IOS_SIMULATOR_NAME: iPhone 16 Pro
IOS_APP_PATH: artifacts/${{ inputs.build_type }}-${{ inputs.metamask_environment }}-MetaMask.app
IOS_BUNDLE_ID: io.metamask.MetaMask
SKIP_WDA_PREBUILD: ${{ steps.wda-prebuilt.outputs.ready == 'true' && 'true' || 'false' }}
IOS_SIMULATOR_POST_BOOT_SETTLE_MS: '30000'
IOS_APP_WARM_LAUNCH_SETTLE_MS: '15000'
- name: Resolve Appium test grep pattern
id: appium-grep
run: echo "pattern=${{ inputs.test_suite_tag }}" >> "$GITHUB_OUTPUT"
shell: bash
- name: Verify Appium runner connectivity (iOS)
if: ${{ inputs.platform == 'ios' }}
run: yarn tsx scripts/e2e/verify-appium-runner-connectivity.mjs ios
env:
IOS_SIMULATOR_UDID: ${{ steps.prepare-ios-appium.outputs.ios-simulator-udid }}
- name: Run Appium smoke tests (Android)
id: run-tests-android
if: ${{ inputs.platform == 'android' }}
timeout-minutes: ${{ inputs.test-timeout-minutes }}
run: >-
yarn playwright test
--config tests/playwright.smoke-appium.config.ts
--project android-smoke
--grep "${{ steps.appium-grep.outputs.pattern }}"
--shard=${{ inputs.split_number }}/${{ inputs.total_splits }}
--pass-with-no-tests
env:
APPIUM_SMOKE_SUITE_NAME: ${{ inputs.test-suite-name }}
APPIUM_SMOKE_JOB_TITLE: Appium ${{ inputs.test-suite-name }} (android)
APPIUM_SMOKE_ARTIFACT_NAME: appium-smoke-report-${{ inputs.test-suite-name }}
APPIUM_SMOKE_VIDEOS_ARTIFACT_NAME: appium-smoke-videos-${{ inputs.test-suite-name }}
PLAYWRIGHT_JSON_OUTPUT_FILE: tests/test-reports/playwright-json/playwright-report.json
APPIUM_RECORD_VIDEO_ON_FAILURE: 'true'
SKIP_APPIUM_STOP: 'true'
ANDROID_APK_PATH: ${{ steps.android-artifacts.outputs.apk-target-path }}/${{ steps.android-artifacts.outputs.apk-file-name }}
ANDROID_AVD_NAME: appium_smoke_avd
ANDROID_APPIUM_USE_PACKAGE_ONLY: 'true'
ANDROID_BOOT_TIMEOUT_MS: '300000'
ANDROID_EMULATOR_CI_CORES: '8'
ANDROID_EMULATOR_POST_BOOT_SETTLE_MS: '30000'
ANDROID_EMULATOR_NETWORK_READY_TIMEOUT_MS: '90000'
ANDROID_EMULATOR_NETWORK_READY_CONSECUTIVE_PINGS: '3'
- name: Run Appium smoke tests (iOS)
id: run-tests-ios
if: ${{ inputs.platform == 'ios' }}
timeout-minutes: ${{ inputs.test-timeout-minutes }}
run: >-
yarn playwright test
--config tests/playwright.smoke-appium.config.ts
--project ios-smoke
--grep "${{ steps.appium-grep.outputs.pattern }}"
--shard=${{ inputs.split_number }}/${{ inputs.total_splits }}
--pass-with-no-tests
env:
APPIUM_SMOKE_SUITE_NAME: ${{ inputs.test-suite-name }}
APPIUM_SMOKE_JOB_TITLE: Appium ${{ inputs.test-suite-name }} (ios)
APPIUM_SMOKE_ARTIFACT_NAME: appium-smoke-report-${{ inputs.test-suite-name }}
APPIUM_SMOKE_VIDEOS_ARTIFACT_NAME: appium-smoke-videos-${{ inputs.test-suite-name }}
PLAYWRIGHT_JSON_OUTPUT_FILE: tests/test-reports/playwright-json/playwright-report.json
APPIUM_RECORD_VIDEO_ON_FAILURE: 'true'
SKIP_APPIUM_STOP: 'true'
IOS_APP_PATH: artifacts/${{ inputs.build_type }}-${{ inputs.metamask_environment }}-MetaMask.app
IOS_SIMULATOR_NAME: iPhone 16 Pro
IOS_SIMULATOR_UDID: ${{ steps.prepare-ios-appium.outputs.ios-simulator-udid }}
IOS_WDA_PREINSTALLED: ${{ steps.prepare-ios-appium.outputs.ios-wda-preinstalled }}
IOS_WDA_BUNDLE_ID: ${{ steps.prepare-ios-appium.outputs.ios-wda-bundle-id }}
SKIP_DEVICE_BOOT: 'true'
SKIP_APP_REINSTALL: 'true'
USE_PREBUILT_WDA: 'true'
IOS_SIMULATOR_POST_BOOT_SETTLE_MS: '30000'
IOS_PRE_LAUNCH_SETTLE_MS: '1500'
- name: Upload Playwright HTML report (Namespace)
if: ${{ always() && inputs.runner_provider == 'namespace' }}
uses: namespace-actions/upload-artifact@f6ccaacc655aec41b93af180d1d7eef21af862d2 # v1.0.3
with:
name: appium-smoke-report-${{ inputs.test-suite-name }}
path: tests/test-reports/appium-smoke-report/${{ inputs.test-suite-name }}/
if-no-files-found: ignore
retention-days: 7
- name: Upload Playwright HTML report (current)
if: ${{ always() && inputs.runner_provider != 'namespace' }}
uses: actions/upload-artifact@v4
with:
name: appium-smoke-report-${{ inputs.test-suite-name }}
path: tests/test-reports/appium-smoke-report/${{ inputs.test-suite-name }}/
if-no-files-found: ignore
retention-days: 7
- name: Upload Playwright JSON report (Namespace)
# Fixed inner filename (playwright-report.json) for github-tools playwright-test-health-report;
# suite/shard identity is in the artifact name prefix playwright-json-report-*.
if: ${{ always() && inputs.runner_provider == 'namespace' }}
uses: namespace-actions/upload-artifact@f6ccaacc655aec41b93af180d1d7eef21af862d2 # v1.0.3
with:
name: playwright-json-report-${{ inputs.test-suite-name }}
path: tests/test-reports/playwright-json/playwright-report.json
if-no-files-found: ignore
retention-days: 7
- name: Upload Playwright JSON report (current)
if: ${{ always() && inputs.runner_provider != 'namespace' }}
uses: actions/upload-artifact@v4
with:
name: playwright-json-report-${{ inputs.test-suite-name }}
path: tests/test-reports/playwright-json/playwright-report.json
if-no-files-found: ignore
retention-days: 7
- name: Upload failure screen recordings (Namespace)
if: ${{ always() && (steps.run-tests-android.outcome == 'failure' || steps.run-tests-ios.outcome == 'failure') && inputs.runner_provider == 'namespace' }}
uses: namespace-actions/upload-artifact@f6ccaacc655aec41b93af180d1d7eef21af862d2 # v1.0.3
with:
name: appium-smoke-videos-${{ inputs.test-suite-name }}
path: tests/test-reports/appium-smoke-videos/${{ inputs.test-suite-name }}/
if-no-files-found: ignore
retention-days: 7
- name: Upload failure screen recordings (current)
if: ${{ always() && (steps.run-tests-android.outcome == 'failure' || steps.run-tests-ios.outcome == 'failure') && inputs.runner_provider != 'namespace' }}
uses: actions/upload-artifact@v4
with:
name: appium-smoke-videos-${{ inputs.test-suite-name }}
path: tests/test-reports/appium-smoke-videos/${{ inputs.test-suite-name }}/
if-no-files-found: ignore
retention-days: 7
- name: Publish test results to GitHub Checks
if: always()
uses: dorny/test-reporter@dc3a92680fcc15842eef52e8c4606ea7ce6bd3f3
with:
name: Appium ${{ inputs.test-suite-name }} (${{ inputs.platform }})
path: tests/test-reports/appium-smoke-junit/${{ inputs.test-suite-name }}.xml
reporter: java-junit
fail-on-error: false
list-suites: all
list-tests: failed