ci: wait for emulator services to be ready post-snapshot#64
Open
gmaclennan wants to merge 4 commits intomainfrom
Open
ci: wait for emulator services to be ready post-snapshot#64gmaclennan wants to merge 4 commits intomainfrom
gmaclennan wants to merge 4 commits intomainfrom
Conversation
`sys.boot_completed` flips as soon as zygote is alive, which on a snapshot restore happens before `system_server` finishes binding the `settings`, `package`, and `activity` services. The previous wait-for-device loop returned almost instantly because the property was already set, and the next `adb shell settings put` then crashed with `cmd: Failure calling service settings: Broken pipe (32)`. Replace it with a probe that polls each service we're about to call until it actually responds, with a 120s ceiling. One retry on each `settings put` covers a residual race where `list` succeeds but a write transaction loses to first-time service initialisation. `disable-animations: false` is unchanged — emulator-runner's own `input keyevent 82` path crashes the emulator on this image, which is why the workflow drives the settings directly.
reactivecircus/android-emulator-runner v2 invokes the script with \`/usr/bin/sh\` (dash on Ubuntu), not bash. The previous version used \`[[ ]]\`, \`local\`, and \`\$SECONDS\` which dash refuses to parse with: /usr/bin/sh: 1: Syntax error: end of file unexpected (expecting \"}\") Replace with POSIX-only constructs: \`[ ]\` tests, \`\$(date +%s)\` for elapsed-time tracking, an inline loop with a \`ready\` flag instead of a function. Verified parses + runs under dash locally.
reactivecircus/android-emulator-runner v2 invokes the workflow's `script:` line by line through `sh -c`, not as a single multi-line script — so any function definition, while loop, or other multi-line construct is split across separate shell invocations and fails to parse (the previous attempts hit "expecting }" / "expecting done"). Move the entire body to scripts/run-android-instrumented-tests.sh and have the workflow invoke it as a single line. The script can use bash freely (proper shebang, set -euo pipefail).
Scope the script down to just the multi-line wait-for-emulator-services loop (the only part that can't survive the action's per-line `sh -c`). Animation settings and the gradle invocation move back inline as single-line statements; the `||` retry uses a one-line brace group, which dash parses fine.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
sys.boot_completedflips as soon as zygote is alive, which on a snapshot restore happens beforesystem_serverfinishes binding thesettings,package, andactivityservices. The previous wait-for-device +getproploop returned almost instantly because the property was already set, and the nextadb shell settings putthen crashed with:Replace it with
wait_for_emulator, which polls each service we're about to call until it actually responds, with a 120s ceiling. One retry on eachsettings putcovers a residual race wherelistsucceeds but a write transaction loses to first-time service initialisation.disable-animations: falseis unchanged — emulator-runner's owninput keyevent 82path crashes the emulator on this image, which is why the workflow drives the settings directly.Test plan
Generated by Claude Code