@@ -9,14 +9,25 @@ inputs:
99 description : " Preferred simulator device name"
1010 required : false
1111 default : " iPhone 17 Pro"
12+ boot-timeout-seconds :
13+ description : " Maximum time to wait for simulator bootstatus"
14+ required : false
15+ default : " 300"
16+
17+ outputs :
18+ simulator-udid :
19+ description : " UDID of the booted iOS simulator"
20+ value : ${{ steps.boot.outputs.simulator-udid }}
1221
1322runs :
1423 using : " composite"
1524 steps :
1625 - name : Resolve and boot iOS test simulator
26+ id : boot
1727 run : |
1828 set -euo pipefail
19- RUNTIME_TOKEN="SimRuntime.iOS-${{ inputs.runtime-version }}"
29+ RUNTIME_VERSION="${{ inputs.runtime-version }}"
30+ RUNTIME_TOKEN="SimRuntime.iOS-${RUNTIME_VERSION//./-}"
2031 export RUNTIME_TOKEN
2132 export PREFERRED_DEVICE_NAME="${{ inputs.preferred-device-name }}"
2233 UDID="$(
@@ -40,10 +51,37 @@ runs:
4051 available.find((device) => device.state === "Booted") ??
4152 available[0];
4253 if (!preferred?.udid) process.exit(1);
54+ console.error(`Selected ${preferred.name} (${preferred.udid}) from ${preferred.runtime}`);
4355 process.stdout.write(preferred.udid);
4456 '
4557 )"
58+ echo "simulator-udid=$UDID" >> "$GITHUB_OUTPUT"
4659 xcrun simctl shutdown all || true
4760 xcrun simctl boot "$UDID" || true
48- xcrun simctl bootstatus "$UDID" -b
61+ xcrun simctl bootstatus "$UDID" -b &
62+ BOOTSTATUS_PID="$!"
63+ TIMEOUT_SECONDS="${{ inputs.boot-timeout-seconds }}"
64+ BOOT_TIMEOUT_FILE="$(mktemp)"
65+ (
66+ sleep "$TIMEOUT_SECONDS"
67+ if kill -0 "$BOOTSTATUS_PID" 2>/dev/null; then
68+ echo "Timed out waiting ${TIMEOUT_SECONDS}s for simulator $UDID to boot" >&2
69+ touch "$BOOT_TIMEOUT_FILE"
70+ kill "$BOOTSTATUS_PID" 2>/dev/null || true
71+ fi
72+ ) &
73+ BOOT_WATCHDOG_PID="$!"
74+ set +e
75+ wait "$BOOTSTATUS_PID"
76+ BOOTSTATUS_EXIT="$?"
77+ set -e
78+ kill "$BOOT_WATCHDOG_PID" 2>/dev/null || true
79+ wait "$BOOT_WATCHDOG_PID" 2>/dev/null || true
80+ if [ -f "$BOOT_TIMEOUT_FILE" ]; then
81+ rm -f "$BOOT_TIMEOUT_FILE"
82+ xcrun simctl list devices || true
83+ exit 1
84+ fi
85+ rm -f "$BOOT_TIMEOUT_FILE"
86+ exit "$BOOTSTATUS_EXIT"
4987 shell : bash
0 commit comments