@@ -25,19 +25,19 @@ jobs:
2525 group : android-e2e-${{ github.ref }}
2626 cancel-in-progress : true
2727
28- # Pin the emulator "discovery directory" for BOTH the emulator (launched by
29- # the action) and the simulator-server backend (spawned by the tool-server
30- # inside the action's script). The Android touch/key backend finds the
31- # running emulator's gRPC console by scanning $XDG_RUNTIME_DIR/avd/running/
32- # pid_*.ini for grpc.port/grpc.token. XDG_RUNTIME_DIR is unset on GitHub
33- # runners and /run/user/$UID doesn't exist for the runner user, so the
34- # emulator and the backend can otherwise resolve DIFFERENT fallback dirs —
35- # the backend then logs "Failed to find any running emulator" and exits
36- # before becoming ready. Pinning it (checked first by both) removes that
37- # divergence. Job-level env reaches every step, including the emulator
38- # subprocess the action spawns.
28+ # Pin the emulator "discovery directory" for BOTH the emulator and the
29+ # simulator-server backend (spawned on demand by the tool-server). The
30+ # Android touch/key backend finds the running emulator's gRPC console by
31+ # scanning $XDG_RUNTIME_DIR/avd/running/pid_*.ini for grpc.port/grpc.token.
32+ # XDG_RUNTIME_DIR is unset on GitHub runners and /run/user/$UID doesn't
33+ # exist for the runner user, so the emulator and the backend can otherwise
34+ # resolve DIFFERENT fallback dirs — the backend then logs "Failed to find
35+ # any running emulator" and exits before becoming ready. Pinning it
36+ # (checked first by both) removes that divergence.
3937 env :
4038 XDG_RUNTIME_DIR : /tmp/xdg-runtime
39+ AVD_NAME : test
40+ SYSTEM_IMAGE : system-images;android-34;google_apis;x86_64
4141
4242 steps :
4343 - name : checkout
@@ -79,14 +79,59 @@ jobs:
7979 mkdir -p "$XDG_RUNTIME_DIR"
8080 chmod 700 "$XDG_RUNTIME_DIR"
8181
82+ # `emulator` and the system image are not part of the preinstalled SDK on
83+ # the runner image; platform-tools (adb) usually is, but installing it is
84+ # a no-op when already present.
85+ - name : Install Android emulator and system image
86+ run : |
87+ CMDLINE_BIN=$(dirname "$(command -v sdkmanager || echo "$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager")")
88+ yes | "$CMDLINE_BIN/sdkmanager" --licenses > /dev/null || true
89+ "$CMDLINE_BIN/sdkmanager" --install "emulator" "platform-tools" "$SYSTEM_IMAGE" > /dev/null
90+ {
91+ echo "$CMDLINE_BIN"
92+ echo "$ANDROID_HOME/emulator"
93+ echo "$ANDROID_HOME/platform-tools"
94+ } >> "$GITHUB_PATH"
95+
96+ - name : Create AVD
97+ run : echo no | avdmanager create avd --name "$AVD_NAME" --package "$SYSTEM_IMAGE" --force
98+
99+ # `-grpc 8554` guarantees grpc.port is written to the discovery ini
100+ # (token-less is fine — the backend handles a missing grpc.token).
101+ # `-accel on` fails fast if KVM didn't take, instead of silently falling
102+ # back to a software-emulated boot that would blow the job timeout.
103+ - name : Boot emulator
104+ run : |
105+ nohup emulator -avd "$AVD_NAME" -no-snapshot -accel on \
106+ -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim \
107+ -grpc 8554 -camera-back none > emulator.log 2>&1 &
108+ timeout 300 adb wait-for-device
109+ timeout 600 adb shell 'while [ "$(getprop sys.boot_completed)" != 1 ]; do sleep 1; done'
110+ adb shell input keyevent 82
111+ adb shell settings put global window_animation_scale 0.0
112+ adb shell settings put global transition_animation_scale 0.0
113+ adb shell settings put global animator_duration_scale 0.0
114+ SERIAL=$(adb devices | awk 'NR>1 && $2=="device"{print $1; exit}')
115+ echo "Emulator ready: $SERIAL"
116+ echo "ANDROID_SERIAL=$SERIAL" >> "$GITHUB_ENV"
117+
118+ - name : Install app on emulator
119+ run : |
120+ APK=$(find apps/expo-example/android/app/build/outputs/apk/release -name '*.apk' | head -1)
121+ if [ -z "$APK" ]; then
122+ echo "Could not find built APK" >&2
123+ exit 1
124+ fi
125+ echo "Installing $APK on $ANDROID_SERIAL"
126+ adb install -r "$APK"
127+
82128 # Start the tool-server out-of-band and hand `flow run` its URL via
83129 # $GITHUB_ENV. The simulator-server it later spawns inherits this step's
84130 # env; XDG_RUNTIME_DIR (pinned at job level) keeps its emulator-discovery
85- # dir aligned with the emulator's, and adb is already on PATH from the
86- # preinstalled SDK — so it no longer has to run inside the emulator step.
87- # Backgrounded with our own readiness poll to dodge flow-run's hard ~15s
88- # in-process startup timeout. SIMSERVER_LOG=debug surfaces the backend's
89- # discovery/connect steps in argent-server.log (drop once green).
131+ # dir aligned with the emulator's. Backgrounded with our own readiness
132+ # poll to dodge flow-run's hard ~15s in-process startup timeout.
133+ # SIMSERVER_LOG=debug surfaces the backend's discovery/connect steps in
134+ # argent-server.log (drop once green).
90135 - name : Start Argent tool-server
91136 run : |
92137 nohup env SIMSERVER_LOG=debug argent server start --detach --no-auth --port 3001 \
@@ -104,25 +149,12 @@ jobs:
104149 cat argent-server.log >&2
105150 exit 1
106151
107- - name : Set up emulator and run tap E2E test
108- uses : reactivecircus/android-emulator-runner@v2
109- with :
110- api-level : 34
111- target : google_apis
112- arch : x86_64
113- force-avd-creation : false
114- # `-grpc 8554` guarantees grpc.port is written to the discovery ini
115- # (token-less is fine — the backend handles a missing grpc.token).
116- emulator-options : -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -grpc 8554 -camera-back none
117- disable-animations : true
118- # android-emulator-runner runs each line of `script` as a separate
119- # `sh -c`, so exported vars don't persist between lines and multi-line
120- # constructs (if/fi) break. Keep every command self-contained on one
121- # line. ARGENT_TOOLS_URL is inherited from the tool-server step above
122- # via $GITHUB_ENV, so `flow run` reuses that server.
123- script : |
124- adb install -r "$(find "$GITHUB_WORKSPACE/apps/expo-example/android/app/build/outputs/apk/release" -name '*.apk' | head -1)"
125- argent flow run simple-tap-test --device "$(adb devices | awk 'NR>1 && $2=="device"{print $1; exit}')"
152+ - name : Run tap E2E test
153+ run : argent flow run simple-tap-test --device "$ANDROID_SERIAL"
154+
155+ - name : Print emulator log
156+ if : always()
157+ run : cat emulator.log 2>/dev/null || echo "no emulator.log"
126158
127159 # The simulator-server's stderr (prefixed `[sim <udid>]`) is written to the
128160 # tool-server log — this is where a "simulator-server exited before ready"
0 commit comments