11name : iOS shell
22
3- # Builds the experimental iOS web view shell in ios-shell/ for the simulator and runs its UI tests:
4- # against the local probe site (ios-shell/Probe) and against the hosted web app at my.open.bot.
5- # Uploads screenshots, the app's diagnostics log and a SUMMARY.md. Simulator only: no signing,
6- # no secrets.
3+ # Builds the experimental iOS shell in ios-shell/ for the simulator and runs its UI tests: against
4+ # the local probe site (ios-shell/Probe), against two mock stacks of the real built web app
5+ # (app/workbench/mock-server.ts), and against the hosted web app at my.open.bot.
6+ #
7+ # Artifacts: ios-shell-<run id> (everything that is not a real account's), ios-shell-shots-<run id>
8+ # (downscaled screenshots, SUMMARY.md, diagnostics.jsonl) and, only when a test used a real account,
9+ # ios-shell-private-<run id>. Simulator only: no signing.
10+ #
11+ # Optional repository secrets for the tests against a real account (skipped when empty):
12+ # OPENBOT_SHELL_TEST_SESSION, OPENBOT_SHELL_GOOGLE_EMAIL, OPENBOT_SHELL_GOOGLE_PASSWORD,
13+ # OPENBOT_SHELL_GOOGLE_TOTP_SECRET.
714on :
815 push :
916 branches :
1219 paths :
1320 - ios-shell/**
1421 - .github/workflows/ios-shell.yml
22+ - app/src/lib/native-shell/**
23+ - app/workbench/mock-server.ts
1524 workflow_dispatch :
1625
1726permissions : {}
2534 name : Build and test on the iOS simulator
2635 if : github.repository == 'CopilotKit/OpenBot'
2736 runs-on : macos-latest
28- timeout-minutes : 60
37+ timeout-minutes : 90
2938 permissions :
3039 contents : read
3140 steps :
@@ -42,12 +51,40 @@ jobs:
4251 mkdir -p artifacts
4352 echo "XCODE_VERSION=$(xcodebuild -version | tr '\n' ' ')" >> "$GITHUB_ENV"
4453
45- - name : Install XcodeGen
46- run : brew install xcodegen
54+ - uses : oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
55+ with :
56+ bun-version : 1.4.3
4757
48- - name : Generate the Xcode project
49- working-directory : ios-shell
50- run : xcodegen generate
58+ - name : Install dependencies and build the web app
59+ timeout-minutes : 15
60+ run : |
61+ bun install --frozen-lockfile
62+ cp .env.example .env
63+ cd app && bun run build
64+
65+ - name : Start the mock stacks
66+ run : |
67+ # A: signed out unless the mock's cookie is sent, with the sign-in hand-off.
68+ MOCK_SIGNED_OUT=1 SERVER_PORT=3001 nohup bun app/workbench/mock-server.ts > artifacts/mock-a.log 2>&1 &
69+ APP_PORT=3010 SERVER_PORT=3001 nohup bun app/serve.ts > artifacts/app-a.log 2>&1 &
70+ # B: the same without the hand-off.
71+ MOCK_NO_HANDOFF=1 MOCK_SIGNED_OUT=1 SERVER_PORT=3002 nohup bun app/workbench/mock-server.ts > artifacts/mock-b.log 2>&1 &
72+ APP_PORT=3011 SERVER_PORT=3002 nohup bun app/serve.ts > artifacts/app-b.log 2>&1 &
73+ challenge="AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
74+ for _ in $(seq 1 60); do
75+ a_page="$(curl -s -o /dev/null -w '%{http_code}' http://127.0.0.1:3010/ || true)"
76+ b_page="$(curl -s -o /dev/null -w '%{http_code}' http://127.0.0.1:3011/ || true)"
77+ a_handoff="$(curl -s -o /dev/null -w '%{http_code}' "http://127.0.0.1:3010/api/auth/shell/handoff?challenge=$challenge" || true)"
78+ b_handoff="$(curl -s -o /dev/null -w '%{http_code}' "http://127.0.0.1:3011/api/auth/shell/handoff?challenge=$challenge" || true)"
79+ if [ "$a_page" = 200 ] && [ "$b_page" = 200 ] && [ "$a_handoff" = 200 ] && [ "$b_handoff" = 404 ]; then
80+ echo "mock stacks are up (A hand-off $a_handoff, B hand-off $b_handoff)"
81+ exit 0
82+ fi
83+ sleep 1
84+ done
85+ echo "mock stacks did not start: A $a_page/$a_handoff, B $b_page/$b_handoff"
86+ tail -n 40 artifacts/mock-a.log artifacts/app-a.log artifacts/mock-b.log artifacts/app-b.log
87+ exit 1
5188
5289 - name : Start the probe server
5390 run : |
@@ -63,6 +100,13 @@ jobs:
63100 cat artifacts/probe-server.log
64101 exit 1
65102
103+ - name : Install XcodeGen
104+ run : brew install xcodegen
105+
106+ - name : Generate the Xcode project
107+ working-directory : ios-shell
108+ run : xcodegen generate
109+
66110 - name : Pick and boot a simulator
67111 run : |
68112 picked="$(python3 ios-shell/ci/pick_simulator.py)"
@@ -78,14 +122,34 @@ jobs:
78122 xcrun simctl boot "$udid" || true
79123 xcrun simctl bootstatus "$udid" -b
80124
81- - name : Build and run the UI tests
82- timeout-minutes : 40
125+ - name : Build for testing
126+ timeout-minutes : 20
127+ run : |
128+ set -o pipefail
129+ xcodebuild build-for-testing \
130+ -project ios-shell/OpenBotShell.xcodeproj \
131+ -scheme OpenBotShell \
132+ -destination "platform=iOS Simulator,id=$SIM_UDID" \
133+ -derivedDataPath DerivedData \
134+ CODE_SIGNING_ALLOWED=NO \
135+ 2>&1 | tee xcodebuild-build.log | grep -E "error:|warning: .*(OpenBotShell|ios-shell)|BUILD (SUCCEEDED|FAILED)" || true
136+ grep -q "TEST BUILD SUCCEEDED\|BUILD SUCCEEDED" xcodebuild-build.log
137+
138+ - name : Run the UI tests
139+ timeout-minutes : 50
140+ env :
141+ # xcodebuild hands TEST_RUNNER_* to the test runner without the prefix. Empty: those tests skip.
142+ TEST_RUNNER_OPENBOT_SHELL_TEST_SESSION : ${{ secrets.OPENBOT_SHELL_TEST_SESSION }}
143+ TEST_RUNNER_OPENBOT_SHELL_GOOGLE_EMAIL : ${{ secrets.OPENBOT_SHELL_GOOGLE_EMAIL }}
144+ TEST_RUNNER_OPENBOT_SHELL_GOOGLE_PASSWORD : ${{ secrets.OPENBOT_SHELL_GOOGLE_PASSWORD }}
145+ TEST_RUNNER_OPENBOT_SHELL_GOOGLE_TOTP_SECRET : ${{ secrets.OPENBOT_SHELL_GOOGLE_TOTP_SECRET }}
83146 run : |
84147 set -o pipefail
85- xcodebuild test \
148+ xcodebuild test-without-building \
86149 -project ios-shell/OpenBotShell.xcodeproj \
87150 -scheme OpenBotShell \
88151 -destination "platform=iOS Simulator,id=$SIM_UDID" \
152+ -derivedDataPath DerivedData \
89153 -resultBundlePath TestResults.xcresult \
90154 -parallel-testing-enabled NO \
91155 CODE_SIGNING_ALLOWED=NO \
@@ -109,30 +173,54 @@ jobs:
109173 container="$(xcrun simctl get_app_container "$SIM_UDID" ai.openbot.shell data 2>/dev/null || true)"
110174 if [ -n "$container" ] && [ -f "$container/Documents/diagnostics.jsonl" ]; then
111175 cp "$container/Documents/diagnostics.jsonl" artifacts/diagnostics.jsonl
112- echo "::group::diagnostics.jsonl"
113- cat artifacts/diagnostics.jsonl
114- echo "::endgroup::"
115176 else
116177 echo "no diagnostics.jsonl in the app container ($container)"
117178 fi
118- xcrun simctl spawn "$SIM_UDID" log show --last 15m --style compact \
179+ xcrun simctl spawn "$SIM_UDID" log show --last 90m --style compact \
119180 --predicate 'process == "OpenBotShell"' > artifacts/simulator-app.log 2>&1 || true
120181 fi
121182
122- - name : Write the summary
183+ - name : Write the summary and collect the screenshots
123184 if : always()
124185 run : |
125186 python3 ios-shell/ci/summarize.py artifacts TestResults.xcresult xcodebuild.log || true
187+ python3 ios-shell/ci/collect_shots.py artifacts || true
126188 if [ -f artifacts/SUMMARY.md ]; then
127189 cat artifacts/SUMMARY.md >> "$GITHUB_STEP_SUMMARY"
128190 fi
191+ if [ -f artifacts/diagnostics.jsonl ]; then
192+ echo "::group::diagnostics.jsonl (tests with a real account left out)"
193+ cat artifacts/diagnostics.jsonl
194+ echo "::endgroup::"
195+ fi
196+ if [ -d private-artifacts ] && [ -n "$(ls -A private-artifacts/shots 2>/dev/null)" ]; then
197+ echo "HAS_PRIVATE=1" >> "$GITHUB_ENV"
198+ fi
199+
200+ - uses : actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
201+ if : always()
202+ with :
203+ name : ios-shell-shots-${{ github.run_id }}
204+ path : artifacts/shots/
205+ retention-days : 14
206+ if-no-files-found : warn
129207
130208 - uses : actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
131209 if : always()
132210 with :
133211 name : ios-shell-${{ github.run_id }}
134212 path : |
135213 artifacts/
214+ !artifacts/shots/
136215 xcodebuild.log
216+ xcodebuild-build.log
137217 retention-days : 14
138218 if-no-files-found : warn
219+
220+ - uses : actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
221+ if : always() && env.HAS_PRIVATE == '1'
222+ with :
223+ name : ios-shell-private-${{ github.run_id }}
224+ path : private-artifacts/
225+ retention-days : 7
226+ if-no-files-found : ignore
0 commit comments