From aa24f336c431ec69332a00bb53e58838c2e16b02 Mon Sep 17 00:00:00 2001 From: Philip Niedertscheider Date: Fri, 26 Dec 2025 12:17:35 +0100 Subject: [PATCH 1/3] feat(ci): Add script to ensure runtime is loaded --- .github/workflows/tests.yml | 8 +++ scripts/ci-ensure-runtime-loaded.sh | 87 +++++++++++++++++++++++++++++ 2 files changed, 95 insertions(+) create mode 100755 scripts/ci-ensure-runtime-loaded.sh diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index ba7a8210..9f2db409 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -24,6 +24,7 @@ jobs: - name: iOS action: test-ios logfiles: raw-*-ios.log + platform: ios - name: macOS action: test-macos logfiles: raw-*-macos.log @@ -33,12 +34,15 @@ jobs: - name: tvOS action: test-tvos logfiles: raw-*-tvos.log + platform: tvos - name: watchOS action: test-watchos logfiles: raw-*-watchos.log + platform: watchos - name: visionOS action: test-visionos logfiles: raw-*-visionos.log + platform: visionos steps: - name: Checkout the repository uses: actions/checkout@v6 @@ -47,6 +51,10 @@ jobs: with: xcode-version: "26.2" + - name: Ensuring required simulator runtimes are loaded + if: matrix.build.platform != null + run: scripts/ci-ensure-runtime-loaded.sh --os-version 26.2 --platform ${{ matrix.build.platform }} + - name: Run Tests run: make ${{ matrix.build.action }} diff --git a/scripts/ci-ensure-runtime-loaded.sh b/scripts/ci-ensure-runtime-loaded.sh new file mode 100755 index 00000000..7705f2c2 --- /dev/null +++ b/scripts/ci-ensure-runtime-loaded.sh @@ -0,0 +1,87 @@ +#!/bin/bash +set -euo pipefail + +# Parse named arguments +OS_VERSION="" +PLATFORM="" + +usage() { + echo "Usage: $0 --os-version --platform " + echo " OS version: Version to ensure is loaded (e.g., 26.1 for beta, 16.4 for older iOS)" + echo " Platform: Platform to ensure is loaded (e.g., iOS, tvOS, visionOS)" + echo " Example: $0 --os-version 26.1 --platform iOS" + echo " Example: $0 --os-version 16.4" + exit 1 +} + +while [[ $# -gt 0 ]]; do + case $1 in + --os-version) + OS_VERSION="$2" + shift 2 + ;; + --platform) + PLATFORM="$2" + shift 2 + ;; + *) + echo "Unknown argument: $1" + usage + ;; + esac +done + +if [ -z "$OS_VERSION" ]; then + echo "Error: --os-version argument is required" + usage +fi + +if [ -z "$PLATFORM" ]; then + echo "Error: --platform argument is required" + usage +fi + +check_runtime_loaded() { + echo "Checking if runtime $PLATFORM ($OS_VERSION) is loaded..." + if xcrun simctl list runtimes -v | grep -qE "$PLATFORM $OS_VERSION" && ! xcrun simctl list runtimes -v | grep -qE "$PLATFORM $OS_VERSION.*unavailable" ; then + echo "Runtime $OS_VERSION is loaded" + exit 0 + fi + echo "Runtime $OS_VERSION is not loaded" +} + +reload_runtime() { + echo "Reloading runtime $PLATFORM ($OS_VERSION)..." + + echo "Unloading CoreSimulator services volumes" + for dir in /Library/Developer/CoreSimulator/Volumes/*; do + echo "Ejecting $dir" + sudo diskutil unmount force "$dir" || true + done + + echo "Killing CoreSimulator services to force reload..." + sudo launchctl kill -9 system/com.apple.CoreSimulator.simdiskimaged || true + sudo pkill -9 com.apple.CoreSimulator.CoreSimulatorService || true + + echo "Killed all CoreSimulator services" +} + +wait_for_runtime() { + echo "Wait for a runtime to be loaded" + count=0 + MAX_ATTEMPTS=60 # 300 seconds (5 minutes) timeout + while [ $count -lt $MAX_ATTEMPTS ]; do + check_runtime_loaded + echo "Waiting for runtime $OS_VERSION to be loaded... attempt $count" + count=$((count + 1)) + sleep 5 + done + echo "Exceeded maximum attempts ($MAX_ATTEMPTS) to check for runtime" +} + +check_runtime_loaded +reload_runtime +wait_for_runtime + +echo "Runtime $PLATFORM ($OS_VERSION) is not loaded after reload attempts" +exit 1 From 03ee6ff61259942a9473235b60eb33c08e39cfd0 Mon Sep 17 00:00:00 2001 From: Philip Niedertscheider Date: Fri, 26 Dec 2025 12:27:23 +0100 Subject: [PATCH 2/3] more verbose script --- .github/workflows/tests.yml | 7 +++---- scripts/ci-ensure-runtime-loaded.sh | 7 ++++++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 9f2db409..d84cb0ab 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -24,7 +24,6 @@ jobs: - name: iOS action: test-ios logfiles: raw-*-ios.log - platform: ios - name: macOS action: test-macos logfiles: raw-*-macos.log @@ -34,15 +33,15 @@ jobs: - name: tvOS action: test-tvos logfiles: raw-*-tvos.log - platform: tvos + platform: tvOS - name: watchOS action: test-watchos logfiles: raw-*-watchos.log - platform: watchos + platform: watchOS - name: visionOS action: test-visionos logfiles: raw-*-visionos.log - platform: visionos + platform: visionOS steps: - name: Checkout the repository uses: actions/checkout@v6 diff --git a/scripts/ci-ensure-runtime-loaded.sh b/scripts/ci-ensure-runtime-loaded.sh index 7705f2c2..eed1512d 100755 --- a/scripts/ci-ensure-runtime-loaded.sh +++ b/scripts/ci-ensure-runtime-loaded.sh @@ -43,7 +43,12 @@ fi check_runtime_loaded() { echo "Checking if runtime $PLATFORM ($OS_VERSION) is loaded..." - if xcrun simctl list runtimes -v | grep -qE "$PLATFORM $OS_VERSION" && ! xcrun simctl list runtimes -v | grep -qE "$PLATFORM $OS_VERSION.*unavailable" ; then + RUNTIMES=$(xcrun simctl list runtimes -v) + + echo "Available runtimes:" + echo "$RUNTIMES" + + if echo "$RUNTIMES" | grep -qE "$PLATFORM $OS_VERSION" && ! echo "$RUNTIMES" | grep -qE "$PLATFORM $OS_VERSION.*unavailable" ; then echo "Runtime $OS_VERSION is loaded" exit 0 fi From c248ec7dc278b2e980b6b54ef11f323f58188b07 Mon Sep 17 00:00:00 2001 From: Philip Niedertscheider Date: Fri, 26 Dec 2025 12:31:03 +0100 Subject: [PATCH 3/3] change name of script --- .github/workflows/tests.yml | 2 +- .../{ci-ensure-runtime-loaded.sh => ensure-runtime-loaded.sh} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename scripts/{ci-ensure-runtime-loaded.sh => ensure-runtime-loaded.sh} (100%) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d84cb0ab..7aec3508 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -52,7 +52,7 @@ jobs: - name: Ensuring required simulator runtimes are loaded if: matrix.build.platform != null - run: scripts/ci-ensure-runtime-loaded.sh --os-version 26.2 --platform ${{ matrix.build.platform }} + run: scripts/ensure-runtime-loaded.sh --os-version 26.2 --platform ${{ matrix.build.platform }} - name: Run Tests run: make ${{ matrix.build.action }} diff --git a/scripts/ci-ensure-runtime-loaded.sh b/scripts/ensure-runtime-loaded.sh similarity index 100% rename from scripts/ci-ensure-runtime-loaded.sh rename to scripts/ensure-runtime-loaded.sh