Skip to content

Commit c2f8d3d

Browse files
areeyanclaude
andcommitted
CI: emulator screenshots of every screen with live data
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 9b6896a commit c2f8d3d

2 files changed

Lines changed: 88 additions & 0 deletions

File tree

‎.github/workflows/screenshots.yml‎

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Screenshots
2+
3+
# Boots an emulator, installs the latest release APK, drives through the
4+
# screens with live data and saves screenshots + the crash log.
5+
on:
6+
workflow_dispatch:
7+
8+
jobs:
9+
shots:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
14+
- name: Latest APK
15+
env:
16+
GH_TOKEN: ${{ github.token }}
17+
run: gh release download latest -p AKL-Live.apk -R ${{ github.repository }}
18+
19+
- name: Enable KVM
20+
run: |
21+
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
22+
sudo udevadm control --reload-rules
23+
sudo udevadm trigger --name-match=kvm
24+
25+
- uses: reactivecircus/android-emulator-runner@v2
26+
with:
27+
api-level: 34
28+
target: google_apis
29+
arch: x86_64
30+
profile: pixel_7
31+
disable-animations: false
32+
script: bash tools/ci_screens.sh
33+
34+
- uses: actions/upload-artifact@v4
35+
if: always()
36+
with:
37+
name: screenshots
38+
path: shots/

‎tools/ci_screens.sh‎

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/bin/bash
2+
# Run inside the emulator job (.github/workflows/screenshots.yml).
3+
set -x
4+
mkdir -p shots
5+
shot() { adb exec-out screencap -p > "shots/$1.png"; }
6+
7+
# tap the centre of the first on-screen element whose text is $1
8+
tap_text() {
9+
adb shell uiautomator dump /sdcard/ui.xml > /dev/null
10+
adb shell cat /sdcard/ui.xml > shots/ui.xml
11+
b=$(grep -o "text=\"$1\"[^>]*bounds=\"[^\"]*\"" shots/ui.xml | head -1 | grep -o 'bounds="[^"]*"' | grep -o '[0-9]\+')
12+
set -- $b
13+
[ -n "$4" ] && adb shell input tap $(( ($1 + $3) / 2 )) $(( ($2 + $4) / 2 ))
14+
}
15+
16+
adb logcat -c
17+
adb install -r AKL-Live.apk
18+
adb shell am start -n nz.aryan.akllive/.MainActivity
19+
sleep 35
20+
shot 1-buses
21+
read W H <<< "$(adb shell wm size | grep -o '[0-9]\+x[0-9]\+' | tr x ' ')"
22+
adb shell input swipe $((W / 2)) $((H * 3 / 4)) $((W / 2)) $((H / 4)) 600
23+
sleep 3
24+
shot 2-buses-lower
25+
adb shell input swipe $((W / 2)) $((H * 3 / 4)) $((W / 2)) $((H / 5)) 600
26+
sleep 3
27+
shot 3-route-map
28+
29+
tap_text "Trains"
30+
sleep 30
31+
shot 4-trains
32+
# zoom in on the City Rail Link
33+
adb shell input tap $((W / 2)) $((H / 4))
34+
adb shell input tap $((W / 2)) $((H / 4))
35+
sleep 3
36+
shot 5-trains-zoomed
37+
# open a station's departures (a label is a fine target once zoomed)
38+
tap_text "Waitematā" || true
39+
adb shell input tap $((W / 2)) $((H / 5))
40+
sleep 12
41+
shot 6-station
42+
43+
tap_text "Settings"
44+
sleep 3
45+
shot 7-settings
46+
47+
adb shell dumpsys window | grep -i "mCurrentFocus" > shots/focus.txt
48+
adb logcat -d -v brief AndroidRuntime:E '*:S' > shots/crash.txt
49+
adb logcat -d > shots/logcat.txt
50+
exit 0

0 commit comments

Comments
 (0)