Skip to content

Commit d647c34

Browse files
committed
Split the recordings into steps of their own, cache the system image, wait on the launcher instead of sleeping, free the build's memory before the emulator boots, and cap a video run at 13 minutes
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012xYtaUjbkB1hwLtK4TEzhq
1 parent c8a6287 commit d647c34

4 files changed

Lines changed: 64 additions & 18 deletions

File tree

‎.github/workflows/android-shell-video.yml‎

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,14 @@ jobs:
4242
name: Record the Android shell
4343
if: github.repository == 'CopilotKit/OpenBot'
4444
runs-on: ubuntu-latest
45-
timeout-minutes: 75
45+
timeout-minutes: 13
4646
permissions:
4747
contents: read
4848
env:
4949
API_LEVEL: "35"
5050
ARTIFACTS: ${{ github.workspace }}/artifacts
5151
PRIVATE_ARTIFACTS: ${{ github.workspace }}/private-artifacts
52-
VIDEO_PLAN: ${{ inputs.which || 'both' }}
52+
WHICH: ${{ inputs.which || 'both' }}
5353
GOOGLE_SIGN_IN: ${{ inputs.real_google_sign_in || 'false' }}
5454
steps:
5555
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
@@ -66,7 +66,7 @@ jobs:
6666
android-shell/gradle/wrapper/gradle-wrapper.properties
6767
6868
- name: Build the debug app and its tests
69-
timeout-minutes: 25
69+
timeout-minutes: 5
7070
working-directory: android-shell
7171
run: |
7272
mkdir -p "$ARTIFACTS" "$PRIVATE_ARTIFACTS"
@@ -81,14 +81,20 @@ jobs:
8181
done
8282
exit 1
8383
84+
- name: Free the build's memory for the emulator
85+
run: |
86+
(cd android-shell && ./gradlew --stop > /dev/null 2>&1) || true
87+
pkill -f KotlinCompileDaemon || true
88+
free -m
89+
8490
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
85-
if: env.VIDEO_PLAN != 'real'
91+
if: env.WHICH != 'real'
8692
with:
8793
bun-version: 1.4.3
8894

8995
- name: Build the web app and start mock stack A
90-
if: env.VIDEO_PLAN != 'real'
91-
timeout-minutes: 15
96+
if: env.WHICH != 'real'
97+
timeout-minutes: 3
9298
run: |
9399
bun install --frozen-lockfile
94100
cp .env.example .env
@@ -101,41 +107,57 @@ jobs:
101107
done
102108
echo "mock stack A did not start"; tail -n 40 "$ARTIFACTS/mock-a.log" "$ARTIFACTS/app-a.log"; exit 1
103109
110+
- name: Cache the emulator's system image
111+
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
112+
with:
113+
path: /usr/local/lib/android/sdk/system-images/android-35/google_apis/x86_64
114+
key: android-system-image-35-google_apis-x86_64-v1
115+
104116
- name: Enable KVM
105117
run: |
106118
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
107119
sudo udevadm control --reload-rules
108120
sudo udevadm trigger --name-match=kvm
109121
110122
- name: Boot the emulator (software keyboard on, animators on for the skeleton's shimmer)
111-
timeout-minutes: 20
123+
timeout-minutes: 4
112124
env:
113125
ANIMATOR_SCALE: "1"
114126
run: android-shell/ci/emulator.sh all
115127

116128
- name: Install the apps
117129
run: |
130+
command -v ffmpeg > /dev/null || { sudo apt-get update -qq && sudo apt-get install -y -qq ffmpeg > /dev/null; }
118131
adb install -r -g android-shell/app/build/outputs/apk/debug/app-debug.apk
119132
adb install -r -g android-shell/app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk
120133
if [ "$GOOGLE_SIGN_IN" = "true" ]; then
121134
adb install -r -g android-shell/app/build/outputs/apk/releaseTest/app-releaseTest.apk
122135
fi
123136
124-
- name: Record
125-
timeout-minutes: 40
137+
- name: Record the real-backend journey (private)
138+
if: env.WHICH != 'demo'
139+
timeout-minutes: 4
126140
env:
127141
RUN_MODE: video
142+
VIDEO_PLAN: real
128143
OPENBOT_SHELL_TEST_SESSION: ${{ secrets.OPENBOT_SHELL_TEST_SESSION }}
129144
OPENBOT_SHELL_GOOGLE_EMAIL: ${{ secrets.OPENBOT_SHELL_GOOGLE_EMAIL }}
130145
OPENBOT_SHELL_GOOGLE_PASSWORD: ${{ secrets.OPENBOT_SHELL_GOOGLE_PASSWORD }}
131146
OPENBOT_SHELL_GOOGLE_TOTP_SECRET: ${{ secrets.OPENBOT_SHELL_GOOGLE_TOTP_SECRET }}
132-
run: |
133-
command -v ffmpeg > /dev/null || { sudo apt-get update -qq && sudo apt-get install -y -qq ffmpeg > /dev/null; }
134-
python3 android-shell/ci/run_tests.py "$ARTIFACTS" "$PRIVATE_ARTIFACTS" "$GITHUB_WORKSPACE"
147+
run: python3 android-shell/ci/run_tests.py "$ARTIFACTS" "$PRIVATE_ARTIFACTS" "$GITHUB_WORKSPACE"
148+
149+
- name: Record the demo tour
150+
if: always() && env.WHICH != 'real'
151+
timeout-minutes: 4
152+
env:
153+
RUN_MODE: video
154+
VIDEO_PLAN: demo
155+
run: python3 android-shell/ci/run_tests.py "$ARTIFACTS" "$PRIVATE_ARTIFACTS" "$GITHUB_WORKSPACE"
135156

136157
- name: Collect
137158
if: always()
138159
run: |
160+
free -m; sudo dmesg 2>/dev/null | grep -i -E "killed process|out of memory" | tail -5 || true
139161
python3 android-shell/ci/summarize.py "$ARTIFACTS" > /dev/null || true
140162
python3 android-shell/ci/collect.py "$ARTIFACTS" "$PRIVATE_ARTIFACTS" || true
141163
ls -la "$ARTIFACTS/video" "$PRIVATE_ARTIFACTS/video" 2>/dev/null || true

‎.github/workflows/android-shell.yml‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,12 @@ jobs:
8888
done
8989
exit "$status"
9090
91+
- name: Free the build's memory for the emulator
92+
run: |
93+
(cd android-shell && ./gradlew --stop > /dev/null 2>&1) || true
94+
pkill -f KotlinCompileDaemon || true
95+
free -m
96+
9197
- name: Check what ships
9298
working-directory: android-shell
9399
run: |
@@ -137,6 +143,12 @@ jobs:
137143
tail -n 40 "$ARTIFACTS"/mock-a.log "$ARTIFACTS"/app-a.log "$ARTIFACTS"/mock-b.log "$ARTIFACTS"/app-b.log "$ARTIFACTS"/probe-server.log
138144
exit 1
139145
146+
- name: Cache the emulator's system image
147+
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
148+
with:
149+
path: /usr/local/lib/android/sdk/system-images/android-35/google_apis/x86_64
150+
key: android-system-image-35-google_apis-x86_64-v1
151+
140152
- name: Enable KVM
141153
run: |
142154
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
@@ -172,6 +184,7 @@ jobs:
172184
- name: Write the summary and collect the screenshots
173185
if: always()
174186
run: |
187+
free -m; sudo dmesg 2>/dev/null | grep -i -E "killed process|out of memory" | tail -5 || true
175188
python3 android-shell/ci/summarize.py "$ARTIFACTS" || true
176189
python3 android-shell/ci/collect.py "$ARTIFACTS" "$PRIVATE_ARTIFACTS" || true
177190
if [ -f "$ARTIFACTS/SUMMARY.md" ]; then cat "$ARTIFACTS/SUMMARY.md" >> "$GITHUB_STEP_SUMMARY"; fi

‎android-shell/ci/emulator.sh‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ if [ -n "${GITHUB_PATH:-}" ]; then echo "$SDK/platform-tools" >> "$GITHUB_PATH";
2222

2323
boot() {
2424
yes | sdkmanager --licenses > /dev/null 2>&1 || true
25-
sdkmanager --install "platform-tools" "emulator" "$IMAGE" > "$ARTIFACTS/sdkmanager.log" 2>&1 || {
25+
# The system image may come from the workflow's cache.
26+
local packages=("platform-tools" "emulator")
27+
[ -f "$SDK/system-images/android-${API_LEVEL}/${IMAGE_TAG}/x86_64/system.img" ] || packages+=("$IMAGE")
28+
sdkmanager --install "${packages[@]}" > "$ARTIFACTS/sdkmanager.log" 2>&1 || {
2629
tail -n 30 "$ARTIFACTS/sdkmanager.log"; exit 1; }
2730
echo no | avdmanager create avd --force -n shell -k "$IMAGE" -d pixel_7 > /dev/null
2831
local config="$ANDROID_AVD_HOME/shell.avd/config.ini"
@@ -31,14 +34,14 @@ boot() {
3134
if grep -q "^$1=" "$config"; then sed -i "s|^$1=.*|$1=$2|" "$config"; else echo "$1=$2" >> "$config"; fi
3235
}
3336
set_config hw.keyboard no
34-
set_config hw.ramSize 6144
37+
set_config hw.ramSize 4096
3538
set_config disk.dataPartition.size 8G
3639
set_config hw.gpu.enabled yes
3740
set_config hw.gpu.mode swiftshader_indirect
3841
set_config hw.camera.back none
3942
set_config hw.camera.front none
4043
set_config showDeviceFrame no
41-
nohup emulator -avd shell -memory 6144 -cores 4 -feature -Vulkan -no-window -no-audio -no-boot-anim -no-snapshot -gpu swiftshader_indirect \
44+
nohup emulator -avd shell -feature -Vulkan -no-window -no-audio -no-boot-anim -no-snapshot -gpu swiftshader_indirect \
4245
-camera-back none -camera-front none -netdelay none -netspeed full > "$ARTIFACTS/emulator.log" 2>&1 &
4346
adb wait-for-device
4447
local started=$SECONDS
@@ -57,7 +60,12 @@ prepare() {
5760
# tests (Settings.Global.HIDE_ERROR_DIALOGS), and a moment for the system to settle.
5861
adb shell settings put global hide_error_dialogs 1
5962
adb shell settings put global anr_show_background 0
60-
sleep 20
63+
# Wait (60 s at most) until the launcher has the focus, then close any system dialog.
64+
local deadline=$((SECONDS + 60))
65+
until adb shell dumpsys window 2>/dev/null | grep -m1 mCurrentFocus | grep -qi launcher; do
66+
if [ $SECONDS -gt $deadline ]; then echo "the launcher did not take the focus in 60 s"; break; fi
67+
sleep 1
68+
done
6169
adb shell am broadcast -a android.intent.action.CLOSE_SYSTEM_DIALOGS > /dev/null 2>&1 || true
6270
adb shell settings put global window_animation_scale 0
6371
adb shell settings put global transition_animation_scale 0

‎android-shell/ci/run_tests.py‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -414,8 +414,11 @@ def main():
414414
results.append({"id": f"video:{name}", "test": name, "class": "video", "variant": "debug",
415415
"status": video_status, "seconds": round(length), "message": message,
416416
"private": secret, "notes": [], "probe": []})
417-
with open(os.path.join(artifacts, "results.json"), "w") as f:
418-
json.dump(results, f, indent=2)
417+
# Several runs (one per recording step) add to the same results file.
418+
path = os.path.join(artifacts, "results.json")
419+
earlier = json.load(open(path)) if os.path.exists(path) else []
420+
with open(path, "w") as f:
421+
json.dump(earlier + results, f, indent=2)
419422
failed = [r for r in results if r["status"] not in ("passed", "skipped")]
420423
print(f"{len(results)} results, {len(failed)} not passed or skipped")
421424
sys.exit(1 if failed else 0)

0 commit comments

Comments
 (0)