From 7bde72f7157ca5de79097bc752c1290eb0dc3b5e Mon Sep 17 00:00:00 2001 From: Mikhail Kilin Date: Wed, 20 May 2026 23:09:20 +0300 Subject: [PATCH] Add iOS simulator UI smoke check --- apps/ios/TeleTuiIOS/README.md | 6 +++++ docs/ios/release-checklist.md | 1 + scripts/smoke-ios-simulator-ui.sh | 39 +++++++++++++++++++++++++++++++ 3 files changed, 46 insertions(+) create mode 100755 scripts/smoke-ios-simulator-ui.sh diff --git a/apps/ios/TeleTuiIOS/README.md b/apps/ios/TeleTuiIOS/README.md index f7a3ce3..5ea61d9 100644 --- a/apps/ios/TeleTuiIOS/README.md +++ b/apps/ios/TeleTuiIOS/README.md @@ -32,3 +32,9 @@ Launch the fake-backed app in the first available iPhone simulator: ```bash DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer scripts/run-ios-simulator-app.sh ``` + +Run the simulator launch plus screenshot sanity check: + +```bash +DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer scripts/smoke-ios-simulator-ui.sh +``` diff --git a/docs/ios/release-checklist.md b/docs/ios/release-checklist.md index 8ae83f6..a50c615 100644 --- a/docs/ios/release-checklist.md +++ b/docs/ios/release-checklist.md @@ -32,6 +32,7 @@ - `swift build --product TeleTuiIOSApp` - `swift run TeleTuiIOSSmokeTests` - `DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer scripts/build-ios-simulator-app.sh` +- `DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer scripts/smoke-ios-simulator-ui.sh` - `DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer scripts/check-ios-tdlib-linking.sh` once TDLib iOS artifacts are available `swift test` is not currently a CI gate on this host because the CLI Swift toolchain available to the package does not expose `XCTest` or `Testing`. The deterministic view-model coverage lives in the executable `TeleTuiIOSSmokeTests` target until an Xcode test target is introduced. diff --git a/scripts/smoke-ios-simulator-ui.sh b/scripts/smoke-ios-simulator-ui.sh new file mode 100755 index 0000000..1bb437a --- /dev/null +++ b/scripts/smoke-ios-simulator-ui.sh @@ -0,0 +1,39 @@ +#!/usr/bin/env bash +set -euo pipefail + +repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" + +if [[ -z "${DEVELOPER_DIR:-}" && -d /Applications/Xcode.app/Contents/Developer ]]; then + export DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer +fi + +screenshot_path="${IOS_SCREENSHOT_PATH:-/private/tmp/tele-tui-ios-simulator-smoke.png}" +simulator_udid="${IOS_SIMULATOR_UDID:-}" +if [[ -z "${simulator_udid}" ]]; then + simulator_udid="$(xcrun simctl list devices available | awk -F '[()]' '/iPhone/ { print $2; exit }')" +fi + +if [[ -z "${simulator_udid}" ]]; then + printf 'No available iPhone simulator found. Run scripts/check-ios-prereqs.sh for details.\n' >&2 + exit 1 +fi + +"${repo_root}/scripts/run-ios-simulator-app.sh" + +# Give SwiftUI a short render window after launch returns. +sleep "${IOS_SCREENSHOT_DELAY_SECONDS:-2}" + +xcrun simctl io "${simulator_udid}" screenshot "${screenshot_path}" + +width="$(sips -g pixelWidth "${screenshot_path}" | awk '/pixelWidth/ { print $2 }')" +height="$(sips -g pixelHeight "${screenshot_path}" | awk '/pixelHeight/ { print $2 }')" +bytes="$(wc -c < "${screenshot_path}" | tr -d ' ')" + +if [[ "${width}" -lt 300 || "${height}" -lt 600 || "${bytes}" -lt 10000 ]]; then + printf 'Simulator screenshot failed sanity checks: width=%s height=%s bytes=%s path=%s\n' \ + "${width}" "${height}" "${bytes}" "${screenshot_path}" >&2 + exit 1 +fi + +printf 'Simulator UI smoke screenshot: %s (%sx%s, %s bytes)\n' \ + "${screenshot_path}" "${width}" "${height}" "${bytes}"