Skip to content

Open-source gym & body-weight tracker, now in the App Store (iPhone + Apple Watch) and as an Android APK. Plan routines, log workouts, see which muscles are trained, import from Strong/Hevy/FitNotes. Self-host it or use it on the phone alone.

iOS CI: wait for the app on a slow runner instead of a fixed time, and retry the first tap

Duarte Santos5b40eee6239e
diff --git a/.github/workflows/ios.yml b/.github/workflows/ios.yml
index 62e7d493b..2e81ffaf0 100644
--- a/.github/workflows/ios.yml
+++ b/.github/workflows/ios.yml
@@ -64,8 +64,11 @@ jobs:
xcrun simctl boot "$UDID"
xcrun simctl bootstatus "$UDID" -b
xcrun simctl install "$UDID" build/dd/Build/Products/Debug-iphonesimulator/App.app
+ # A busy runner can still be starting the simulator's own apps: give the page up to three
+ # minutes to reach its plugins rather than a fixed wait.
xcrun simctl launch --console-pty "$UDID" ch.duartesantos.opengym > build/console.log 2>&1 &
- sleep 45
+ for i in $(seq 36); do grep -q "RestAlert" build/console.log && break; sleep 5; done
+ sleep 5
xcrun simctl io "$UDID" screenshot build/first-screen.png || true
kill %1 || true
cat build/console.log | grep -v "^\s*$" | head -200
diff --git a/frontend/ios/App/AppUITests/OpenGymUITests.swift b/frontend/ios/App/AppUITests/OpenGymUITests.swift
index 0d5cfd0d2..0355d5734 100644
--- a/frontend/ios/App/AppUITests/OpenGymUITests.swift
+++ b/frontend/ios/App/AppUITests/OpenGymUITests.swift
@@ -31,6 +31,20 @@ final class OpenGymUITests: XCTestCase {
app.buttons.matching(NSPredicate(format: "label BEGINSWITH %@", prefix)).firstMatch
}
+ /**
+ * "Use on this device", until home shows. On a slow simulator the first tap can land while the
+ * page is still starting and go nowhere.
+ */
+ private func chooseLocal() {
+ let local = app.buttons["Use on this device"]
+ XCTAssertTrue(local.waitForExistence(timeout: 60), "the onboarding choice did not show up")
+ for _ in 0..<5 {
+ if local.exists { local.tap() }
+ if app.buttons["Log"].waitForExistence(timeout: 8) { return }
+ }
+ XCTFail("home never showed after the onboarding choice")
+ }
+
/** "Allow" on the notification question, whenever iOS asks it. */
private func allowNotificationsIfAsked() {
let allow = springboard.alerts.buttons["Allow"]
@@ -39,7 +53,7 @@ final class OpenGymUITests: XCTestCase {
func testRestEndsWithANotificationInTheBackground() {
app.launch()
- tap(app.buttons["Use on this device"], "the onboarding choice", timeout: 40)
+ chooseLocal()
shot("1-home")
tap(app.buttons["Load starter plan"], "Load starter plan")
tap(button(startingWith: "Full Body"), "the Full Body plan")
@@ -62,8 +76,7 @@ final class OpenGymUITests: XCTestCase {
func testWeighInSheetStaysAboveTheKeyboard() {
app.launch()
- let local = app.buttons["Use on this device"]
- if local.waitForExistence(timeout: 40) { local.tap() }
+ chooseLocal()
tap(app.buttons["Log"], "Log (body weight)")
let field = app.textFields.firstMatch
tap(field, "the weight field")