diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index 8698d6ef9..c108958a8 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -71,6 +71,34 @@ jobs: # of which Xcode built a given run. xcodebuild -version + - name: Reset the test simulators + # HealthChat: a hosted VM hands out a fresh simulator every run; this runner reuses the same + # devices, so app containers, caches and logs survive between runs. Suites asserting on clean + # state then fail on the previous run's leftovers — LoggingTests expects no log files and + # finds nine, in the same device container each time. + # + # Only the two devices the tooling pins are erased (UnitTests.swift, PreviewTests.swift, + # CI.swift), never `simctl erase all`: this machine is shared with the release pipeline, and + # a blanket wipe would take out simulator state that has nothing to do with this job. A + # missing device is not an error — the tooling creates it. + run: | + set -eu + for device in "iPhone 17" "iPhone SE (3rd generation)"; do + # Match on a trailing "(" so "iPhone 17" cannot also match "iPhone 17 Pro" — the same + # guard the tooling uses when it resolves a device. + udid=$(xcrun simctl list devices "iOS 26.5" available \ + | grep -F "$device (" \ + | grep -oE '[0-9A-F]{8}(-[0-9A-F]{4}){3}-[0-9A-F]{12}' \ + | head -1 || true) + if [ -n "$udid" ]; then + echo "Erasing $device ($udid)" + xcrun simctl shutdown "$udid" 2>/dev/null || true + xcrun simctl erase "$udid" + else + echo "$device not present — the tooling will create it" + fi + done + - name: Run tests # HealthChat: previews are skipped. PreviewTests renders a snapshot for every preview in the # app and was the entire reason this job could not fit in an hour — it never once finished,