openclaw/scripts/ci-xcodebuild.py
Peter Steinberger 1917d69a7a
ci(ios): report Xcode startup timing and runner resources
Warm source caches still leave variable delays before Xcode emits output and
while it resolves and compiles packages. Log CPU count, memory, machine model,
booted simulators, and UTC timestamps around the actual Xcode invocation.
Bound each read-only diagnostic to five seconds without blocking the build.

Run the helper from the trusted workflow harness in both checkout shapes and
route helper edits through iOS build and simulator coverage. Preserve the
smoke build-for-testing action, hourly build action, and historical and
frozen-hourly fallbacks.
2026-10-03 03:47:10 -07:00

39 lines
1.5 KiB
Python

#!/usr/bin/env python3
"""Report runner and simulator timing without changing the Xcode build."""
from datetime import datetime, timezone
import subprocess
import sys
import time
def stamp(message):
timestamp = datetime.now(timezone.utc).isoformat(timespec="milliseconds")
print(f"[ios-build] {timestamp} {message}", flush=True)
def diagnostic(label, command):
started = time.monotonic()
stamp(f"{label} start")
try:
result = subprocess.run(command, timeout=5, check=False)
outcome = f"exit={result.returncode}"
except subprocess.TimeoutExpired:
outcome = "timed out after 5s; continuing build"
except OSError as error:
outcome = f"unavailable: {error.strerror}; continuing build"
stamp(f"{label} end elapsed={time.monotonic() - started:.3f}s {outcome}")
if __name__ == "__main__":
diagnostic("runner hardware", ["sysctl", "hw.ncpu", "hw.memsize", "hw.model"])
diagnostic("booted simulators", ["xcrun", "simctl", "list", "devices", "booted"])
started = time.monotonic()
stamp("xcodebuild start")
try:
result = subprocess.run(["xcodebuild", *sys.argv[1:]], check=False)
code = result.returncode if result.returncode >= 0 else 128 - result.returncode
except OSError as error:
print(f"::error::Unable to start xcodebuild: {error.strerror}", flush=True)
code = 127
stamp(f"xcodebuild end elapsed={time.monotonic() - started:.3f}s exit={code}")
raise SystemExit(code)