From a00da2becd3d5dfc2e618d4a9fc327c259fc3dfe Mon Sep 17 00:00:00 2001 From: a-maurice Date: Tue, 27 Jun 2023 16:24:36 -0700 Subject: [PATCH 1/2] Improve the iOS simulator install logic --- scripts/gha/test_simulator.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/scripts/gha/test_simulator.py b/scripts/gha/test_simulator.py index 5fbefe84..a20c442e 100644 --- a/scripts/gha/test_simulator.py +++ b/scripts/gha/test_simulator.py @@ -394,14 +394,25 @@ def _create_and_boot_simulator(apple_platform, device_name, device_os): if not device_id: # download and create device - os.environ["GEM_HOME"] = "$HOME/.gem" - args = ["gem", "install", "xcode-install"] - logging.info("Download xcode-install: %s", " ".join(args)) + args = ["brew", "install", "xcodesorg/made/xcodes"] + logging.info("Download xcodes: %s", " ".join(args)) subprocess.run(args=args, check=True) - args = ["xcversion", "simulators", "--install=%s %s" % (apple_platform, device_os)] + # Get the set of available versions for the given Apple platform + args = ["xcodes", "runtimes"] + runtimes = subprocess.run(args=args, capture_output=True, text=True, check=True) + available_versions = re.findall('{0} ([\d|.]+)'.format(apple_platform), runtimes.stdout.strip()) + logging.info("Found available versions for %s: %s", apple_platform, ", ".join(available_versions)) + + # If the requested version is available, use it, otherwise default to the latest + if (device_os not in available_versions): + logging.warning("Unable to find version %s, will fall back to %s", device_os, available_versions[-1]) + device_os = available_versions[-1] + logging.info("Will try to use %s", device_os) + + args = ["xcodes", "runtimes", "install", "%s %s" % (apple_platform, device_os)] logging.info("Download simulator: %s", " ".join(args)) - subprocess.run(args=args, check=False) + subprocess.run(args=args, check=True) args = ["xcrun", "simctl", "create", "test_simulator", device_name, "%s%s" % (apple_platform, device_os)] logging.info("Create test simulator: %s", " ".join(args)) From 8f4b3e30968fd85a1b83740c139070639a0abc90 Mon Sep 17 00:00:00 2001 From: a-maurice Date: Tue, 27 Jun 2023 17:17:18 -0700 Subject: [PATCH 2/2] Update test_simulator.py --- scripts/gha/test_simulator.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/gha/test_simulator.py b/scripts/gha/test_simulator.py index a20c442e..3dfd0b0b 100644 --- a/scripts/gha/test_simulator.py +++ b/scripts/gha/test_simulator.py @@ -408,11 +408,10 @@ def _create_and_boot_simulator(apple_platform, device_name, device_os): if (device_os not in available_versions): logging.warning("Unable to find version %s, will fall back to %s", device_os, available_versions[-1]) device_os = available_versions[-1] - logging.info("Will try to use %s", device_os) args = ["xcodes", "runtimes", "install", "%s %s" % (apple_platform, device_os)] logging.info("Download simulator: %s", " ".join(args)) - subprocess.run(args=args, check=True) + subprocess.run(args=args, check=False) args = ["xcrun", "simctl", "create", "test_simulator", device_name, "%s%s" % (apple_platform, device_os)] logging.info("Create test simulator: %s", " ".join(args))