-
-
Notifications
You must be signed in to change notification settings - Fork 122
257 lines (232 loc) · 10 KB
/
test-native-ios.yml
File metadata and controls
257 lines (232 loc) · 10 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
name: iOS Native Tests
env:
# Specify an iOS version to test on.
simulator_ios_version: 18
# Name of the simulator device to use.
simulator_device_name: iPhone 16 Pro
on:
push:
branches:
- main
- ci/native-tests-free-runners
- ci/rolldown-native-tests
- react-native-82
paths:
- '.github/actions/install/**'
- '.github/workflows/build-ios-test-container-app.yml'
- '.github/workflows/test-native-ios.yml'
- 'bun.lock'
- 'package.json'
- 'packages/one/metro-entry.js'
- 'packages/one/metro-entry-ctx.js'
- 'packages/one/src/**/*.native.*'
- 'packages/one/src/**/*.ios.*'
- 'packages/one/src/**/*.android.*'
- 'packages/one/src/cli/prebuild.ts'
- 'packages/one/src/cli/runAndroid.ts'
- 'packages/one/src/cli/runIos.ts'
- 'packages/one/src/metro-config/**'
- 'packages/vite-plugin-metro/**'
- 'packages/vxrn/**'
- 'tests/rn-test-container/app.json'
- 'tests/rn-test-container/e2e/**'
- 'tests/rn-test-container/ios/**'
- 'tests/rn-test-container/package.json'
- 'tests/rn-test-container/react-native.config.cjs'
- 'tests/rn-test-container/scripts/**'
- 'tests/test/**'
- 'packages/test/**'
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
jobs:
build-ios-test-container-dev:
name: Build iOS RN Test App (Dev)
uses: ./.github/workflows/build-ios-test-container-app.yml
secrets: inherit
permissions:
contents: read
pull-requests: read
with:
configuration: Debug
build-ios-test-container-prod:
name: Build iOS RN Test App (Prod)
uses: ./.github/workflows/build-ios-test-container-app.yml
secrets: inherit
permissions:
contents: read
pull-requests: read
with:
configuration: Release
test-ios-native:
name: Native iOS Tests
needs:
- build-ios-test-container-dev
- build-ios-test-container-prod
runs-on: macos-15
timeout-minutes: 90
steps:
- name: Set Xcode version
run: sudo xcode-select -s /Applications/Xcode_26.2.app
- name: Checkout
uses: actions/checkout@v6
- name: Install
uses: ./.github/actions/install
with:
install-playwright: 'false'
- name: Download Built Test Container App (Dev)
uses: actions/cache/restore@v5
with:
fail-on-cache-miss: true
key: ${{ needs.build-ios-test-container-dev.outputs.built-app-cache-key }}
path: ${{ needs.build-ios-test-container-dev.outputs.built-app-path }}
- name: Download Built Test Container App (Prod)
uses: actions/cache/restore@v5
with:
fail-on-cache-miss: true
key: ${{ needs.build-ios-test-container-prod.outputs.built-app-cache-key }}
path: ${{ needs.build-ios-test-container-prod.outputs.built-app-path }}
- name: Download Hermes V1 hermesc
if: ${{ needs.build-ios-test-container-prod.outputs.hermesc-cache-key }}
id: download-hermesc
continue-on-error: true
uses: actions/cache/restore@v5
with:
key: ${{ needs.build-ios-test-container-prod.outputs.hermesc-cache-key }}
path: ${{ needs.build-ios-test-container-prod.outputs.hermesc-path }}
- name: Get Simulator UDID
id: get-simulator-udid
env:
SIMULATOR_IOS_VERSION: ${{ env.simulator_ios_version }}
SIMULATOR_DEVICE_NAME: ${{ env.simulator_device_name }}
run: |
AVAILABLE_SIMULATORS=$(xcrun simctl list devices available --json | jq -r '[.devices | to_entries[] | select(.key | contains("SimRuntime.iOS")) | .key as $runtime | .value[] | { runtime: $runtime, name: .name, udid: .udid }]')
echo "Available simulators: $AVAILABLE_SIMULATORS"
SELECTED_SIMULATOR=$(echo $AVAILABLE_SIMULATORS | jq -r "[.[] | select(.runtime | contains(\"$SIMULATOR_IOS_VERSION\")) | select(.name == \"$SIMULATOR_DEVICE_NAME\")] | first")
if [ -z "$SELECTED_SIMULATOR" ] || [ "$SELECTED_SIMULATOR" = "null" ]; then
echo "Error: No simulator found for iOS version $SIMULATOR_IOS_VERSION and device name $SIMULATOR_DEVICE_NAME"
echo "Available devices:"
echo "$AVAILABLE_SIMULATORS" | jq -r '.[] | "\(.name) (\(.runtime))"'
exit 1
fi
echo "Selected simulator: $SELECTED_SIMULATOR"
SIMULATOR_UDID=$(echo $SELECTED_SIMULATOR | jq -r .udid)
if [ -z "$SIMULATOR_UDID" ] || [ "$SIMULATOR_UDID" = "null" ]; then
echo "Error: Could not get simulator UDID"
exit 1
fi
echo "Simulator UDID: $SIMULATOR_UDID"
echo "simulator_udid=$SIMULATOR_UDID" >> $GITHUB_OUTPUT
- name: Boot Simulator
env:
SIMULATOR_UDID: ${{ steps.get-simulator-udid.outputs.simulator_udid }}
run: xcrun simctl boot $SIMULATOR_UDID
- name: Cache Appium
id: appium-cache
uses: actions/cache@v5
with:
path: |
~/.appium
/usr/local/lib/node_modules/appium
/usr/local/bin/appium
key: appium-xcuitest-${{ runner.os }}-v3
- name: Install Appium
if: steps.appium-cache.outputs.cache-hit != 'true'
run: |
npm install -g appium
appium driver install xcuitest
- name: Verify Appium
run: |
# ensure cached appium is functional (symlink can break)
if ! appium --version 2>/dev/null; then
echo "appium not functional, reinstalling..."
npm install -g appium
appium driver install xcuitest 2>/dev/null || appium driver update xcuitest
fi
# ensure xcuitest driver is up to date
appium driver update xcuitest 2>/dev/null || true
appium --version
appium driver list --installed
- name: Start Appium Server
run: |
appium > /tmp/appium.log 2>&1 &
# wait for appium to be ready
for i in {1..30}; do
if curl -s http://localhost:4723/status | grep -q '"ready":true'; then
echo "Appium ready after $i seconds"
break
fi
if [ $i -eq 30 ]; then
echo "Appium failed to start"
cat /tmp/appium.log
exit 1
fi
sleep 1
done
- name: Pre-build WebDriverAgent
env:
SIMULATOR_UDID: ${{ steps.get-simulator-udid.outputs.simulator_udid }}
run: |
# WDA builds on first session and can take 15+ min on CI.
# use appium's xcodebuild to compile WDA ahead of time.
APPIUM_XCUITEST_PATH=$(appium driver run xcuitest print-wda-path 2>/dev/null || echo "")
# strip ansi codes and whitespace
APPIUM_XCUITEST_PATH=$(echo "$APPIUM_XCUITEST_PATH" | sed 's/\x1b\[[0-9;]*m//g' | tr -d '[:space:]')
# fallback: search known appium driver install locations
if [ -z "$APPIUM_XCUITEST_PATH" ] || [ ! -d "$APPIUM_XCUITEST_PATH" ]; then
echo "print-wda-path failed or returned invalid path: '$APPIUM_XCUITEST_PATH'"
APPIUM_XCUITEST_PATH=$(find ~/.appium -name "WebDriverAgent.xcodeproj" -print -quit 2>/dev/null | xargs dirname 2>/dev/null || echo "")
fi
if [ -n "$APPIUM_XCUITEST_PATH" ] && [ -d "$APPIUM_XCUITEST_PATH" ]; then
echo "Building WDA from: $APPIUM_XCUITEST_PATH"
xcodebuild build-for-testing \
-project "$APPIUM_XCUITEST_PATH/WebDriverAgent.xcodeproj" \
-scheme WebDriverAgentRunner \
-destination "platform=iOS Simulator,id=$SIMULATOR_UDID" \
-derivedDataPath /tmp/wda-build \
-quiet || echo "WDA pre-build failed, will build on first session"
else
echo "Could not find WDA path, will build on first session"
fi
- name: Test Dev (Metro)
env:
SIMULATOR_UDID: ${{ steps.get-simulator-udid.outputs.simulator_udid }}
IOS_TEST_CONTAINER_PATH_DEV: ${{ github.workspace }}/${{ needs.build-ios-test-container-dev.outputs.built-app-path }}
run: |
bun run --filter test-test test-ios:dev
- name: Test Dev (Rolldown)
env:
SIMULATOR_UDID: ${{ steps.get-simulator-udid.outputs.simulator_udid }}
IOS_TEST_CONTAINER_PATH_DEV: ${{ github.workspace }}/${{ needs.build-ios-test-container-dev.outputs.built-app-path }}
run: |
bun run --filter test-test test-ios:rolldown:dev
- name: Test Prod (Metro)
env:
SIMULATOR_UDID: ${{ steps.get-simulator-udid.outputs.simulator_udid }}
IOS_TEST_CONTAINER_PATH_PROD: ${{ github.workspace }}/${{ needs.build-ios-test-container-prod.outputs.built-app-path }}
HERMESC_PATH: ${{ steps.download-hermesc.outputs.cache-matched-key && format('{0}/{1}', github.workspace, needs.build-ios-test-container-prod.outputs.hermesc-path) || '' }}
run: |
bun run --filter test-test test-ios:prod
- name: Test Prod (Rolldown)
continue-on-error: true
env:
SIMULATOR_UDID: ${{ steps.get-simulator-udid.outputs.simulator_udid }}
IOS_TEST_CONTAINER_PATH_PROD: ${{ github.workspace }}/${{ needs.build-ios-test-container-prod.outputs.built-app-path }}
HERMESC_PATH: ${{ steps.download-hermesc.outputs.cache-matched-key && format('{0}/{1}', github.workspace, needs.build-ios-test-container-prod.outputs.hermesc-path) || '' }}
run: |
bun run --filter test-test test-ios:rolldown:prod
- name: Upload Appium Logs
uses: actions/upload-artifact@v7
if: ${{ always() }}
continue-on-error: true
with:
name: appium-tests.log
path: /tmp/appium.log
- name: Upload Appium Screenshots
uses: actions/upload-artifact@v7
if: ${{ always() }}
continue-on-error: true
with:
name: appium-screenshots
path: /tmp/appium-screenshots