Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ checks are exactly **`policy / policy`** and
| `compiler` | Each compiler runs every test configuration and a release build for every declared trait set. Verifies the selected Swift version. |
| `format` | Strict recursive Swift formatting using the repository's `.swift-format`, on the last compiler. |
| `linux` | Runs tests in each digest-pinned Swift Docker image. |
| `apple` | Builds each generic iOS, tvOS, watchOS or visionOS destination, skipping plugin and macro validation for non-interactive CI. Optional tests download the SDK-matching runtime and create/delete a matching simulator. |
| `apple` | Builds each generic iOS, tvOS, watchOS or visionOS destination, skipping plugin and macro validation for non-interactive CI. Optional tests use the SDK-matching simulator runtime, downloading it only when the runner lacks it, and create/delete a matching simulator. |
| `docs` | Builds the whole package once, emitting public symbol graphs with extension blocks, then converts each target's DocC archive with warnings as errors. |
| `demo` | Builds the release executable and checks a fresh terminal recording through the presentation action's recording-only mode. |
| `commands` | Runs each repository command in its own job in the member checkout. |
Expand Down
13 changes: 10 additions & 3 deletions scripts/run-validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,17 @@ def simulator(entry, root, environment):
sdk = {'iOS': 'iphonesimulator', 'tvOS': 'appletvsimulator',
'watchOS': 'watchsimulator', 'visionOS': 'xrsimulator'}[platform]
expected = run(['xcrun', '--sdk', sdk, '--show-sdk-version'], root, environment, capture=True).strip()
run([*XCODEBUILD, '-downloadPlatform', platform], root, environment)
inventory = json.loads(run(['xcrun', 'simctl', 'list', '-j'], root, environment, capture=True))
runtimes = [item for item in inventory['runtimes'] if item.get('isAvailable')

def matching():
inventory = json.loads(run(['xcrun', 'simctl', 'list', '-j'], root, environment, capture=True))
return [item for item in inventory['runtimes'] if item.get('isAvailable')
and item['name'].startswith(platform + ' ') and item['version'] == expected]

# Runner images preinstall the runtime that matches their Xcode; download only when it is absent.
runtimes = matching()
if not runtimes:
run([*XCODEBUILD, '-downloadPlatform', platform], root, environment)
runtimes = matching()
if not runtimes:
raise ValueError('No available simulator runtime matching ' + platform + ' ' + expected)
runtime = runtimes[-1]
Expand Down
37 changes: 36 additions & 1 deletion tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,41 @@ def test_format_rejects_missing_option_and_escaping_paths_before_running(self):
runner.execute(self.root, 'format', {}, self.config)
run.assert_not_called()

def test_simulator_uses_an_installed_runtime_without_downloading(self):
inventory = json.dumps({'runtimes': [{
'isAvailable': True, 'name': 'iOS 26.5', 'version': '26.5',
'identifier': 'com.apple.CoreSimulator.SimRuntime.iOS-26-5',
'supportedDeviceTypes': [{'name': 'iPhone 17', 'identifier': 'iPhone-17'}]}]})

def respond(command, cwd, environment, capture=False):
if '--show-sdk-version' in command:
return '26.5\n'
if command[:3] == ['xcrun', 'simctl', 'list']:
return inventory
return 'device-id\n'

with patch.object(runner, 'run', side_effect=respond) as run:
device = runner.simulator({'platform': 'iOS'}, self.root, {})
self.assertEqual(device, 'device-id')
self.assertFalse(any('-downloadPlatform' in call.args[0] for call in run.call_args_list))

def test_simulator_downloads_the_platform_only_when_no_runtime_matches(self):
listings = iter([json.dumps({'runtimes': []}), json.dumps({'runtimes': [{
'isAvailable': True, 'name': 'iOS 26.5', 'version': '26.5', 'identifier': 'runtime',
'supportedDeviceTypes': [{'name': 'iPhone 17', 'identifier': 'iPhone-17'}]}]})])

def respond(command, cwd, environment, capture=False):
if '--show-sdk-version' in command:
return '26.5\n'
if command[:3] == ['xcrun', 'simctl', 'list']:
return next(listings)
return 'device-id\n'

with patch.object(runner, 'run', side_effect=respond) as run:
runner.simulator({'platform': 'iOS'}, self.root, {})
downloads = [call.args[0] for call in run.call_args_list if '-downloadPlatform' in call.args[0]]
self.assertEqual(len(downloads), 1)

def test_compiler_runs_every_test_configuration_and_builds_every_trait(self):
self.config.update(test_configurations=['debug', 'release'], traits=[['default'], ['Feature', 'default'], []], build_system='native', environment={'VALUE': 'declared'})
with patch.object(runner, 'run') as run:
Expand Down Expand Up @@ -189,7 +224,7 @@ def execute(command, *args, **kwargs):
entry = {**self.config['platforms']['apple'][0], 'test': tests}
runner.execute(self.root, 'apple', entry, self.config)
commands = [call.args[0] for call in run.call_args_list if call.args[0][0] == 'xcodebuild']
self.assertEqual(len(commands), 3 if tests else 1)
self.assertEqual(len(commands), 2 if tests else 1)
self.assertIn('generic/platform=iOS', commands[0])
for command in commands:
self.assertIn('-skipPackagePluginValidation', command)
Expand Down
Loading