|
68 | 68 | -destination "platform=iOS Simulator,name=iPhone 17 Pro,OS=${IOS_RUNTIME_VERSION}" \ |
69 | 69 | -derivedDataPath "$DERIVED_DATA_PATH" |
70 | 70 |
|
| 71 | + - name: Resolve and boot iOS test simulator |
| 72 | + run: | |
| 73 | + set -euo pipefail |
| 74 | + RUNTIME_TOKEN="SimRuntime.iOS-${IOS_RUNTIME_VERSION//./-}" |
| 75 | + export RUNTIME_TOKEN |
| 76 | + UDID="$( |
| 77 | + xcrun simctl list devices -j | node -e ' |
| 78 | + const fs = require("node:fs"); |
| 79 | + const runtimeToken = process.env.RUNTIME_TOKEN; |
| 80 | + const payload = JSON.parse(fs.readFileSync(0, "utf8")); |
| 81 | + const entries = Object.entries(payload.devices ?? {}); |
| 82 | + const iosRuntimes = entries.filter(([runtime]) => runtime.includes("SimRuntime.iOS-")); |
| 83 | + const runtimeMatches = iosRuntimes.filter(([runtime]) => runtime.includes(runtimeToken)); |
| 84 | + const pool = runtimeMatches.length > 0 ? runtimeMatches : iosRuntimes; |
| 85 | + const available = pool.flatMap(([runtime, devices]) => |
| 86 | + (devices ?? []) |
| 87 | + .filter((device) => device.isAvailable) |
| 88 | + .map((device) => ({ ...device, runtime })), |
| 89 | + ); |
| 90 | + const preferred = |
| 91 | + available.find((device) => device.state === "Booted" && device.name === "iPhone 17 Pro") ?? |
| 92 | + available.find((device) => device.name === "iPhone 17 Pro") ?? |
| 93 | + available.find((device) => device.state === "Booted") ?? |
| 94 | + available[0]; |
| 95 | + if (!preferred?.udid) process.exit(1); |
| 96 | + process.stdout.write(preferred.udid); |
| 97 | + ' |
| 98 | + )" |
| 99 | + xcrun simctl shutdown all || true |
| 100 | + xcrun simctl boot "$UDID" || true |
| 101 | + xcrun simctl bootstatus "$UDID" -b |
| 102 | +
|
71 | 103 | - name: Run iOS integration test |
72 | 104 | run: node --test test/integration/ios.test.ts |
73 | 105 |
|
|
0 commit comments