Skip to content

Commit 5225257

Browse files
authored
fix(build-system-tests): bound Android emulator boot-wait to stop 6h canary hangs (#7031)
The macos-15-intel React Native Android canary regularly cold-boots into a wedged emulator. With no job timeout and an unbounded `adb wait-for-device` boot-wait loop, the job spins until GitHub's 6h hard limit cancels it. Compounding this, the snapshot cache key always hits but the cached snapshot is incompatible with the current runner emulator ("Failed to load snapshot 'default_boot'"), while the snapshot-resave step is gated on a cache miss, so the broken snapshot stays sticky. Minimum mitigation: - timeout-minutes: 45 on the emulator job so a wedged boot can't burn 6h. - Wrap the boot-wait in `timeout 420` in both the cold-boot and cached steps; on timeout, emit a ::error:: annotation, dump `adb devices`, and fail fast. This needs GNU coreutils on macOS (brew install coreutils), mirroring the proven recipe in reusable-e2e.yml. - Bump the snapshot cache key v1 -> v2 so a compatible snapshot is regenerated on the next cold boot. Follow-up (not in this PR): replace the hand-rolled emulator launch with reactivecircus/android-emulator-runner and move the Android matrix to ubuntu-latest (KVM) for reliability and speed. Co-authored-by: soberm <12175134+soberm@users.noreply.github.com>
1 parent 6cdc424 commit 5225257

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

.github/workflows/reusable-build-system-test-react-native.yml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ on:
1111
jobs:
1212
build:
1313
runs-on: macos-15-intel
14+
# Bound the whole job so a wedged emulator boot can't run until GitHub's 6h hard limit.
15+
timeout-minutes: 45
1416
strategy:
1517
fail-fast: false
1618
matrix:
@@ -87,7 +89,7 @@ jobs:
8789
~/Library/Android/sdk/build-tools
8890
~/Library/Android/sdk/platform-tools
8991
~/.android/avd
90-
key: ${{ runner.os }}-android-sdk-27-x86_64-snapshot-v1
92+
key: ${{ runner.os }}-android-sdk-27-x86_64-snapshot-v2
9193
env:
9294
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 5
9395

@@ -126,14 +128,20 @@ jobs:
126128
run: |
127129
echo -e "echo \$ANDROID_HOME"
128130
echo $ANDROID_HOME
131+
# macOS runners have no GNU `timeout`; coreutils provides it for the emulator boot-wait guard below (mirrors reusable-e2e.yml).
132+
brew install coreutils
129133
$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --install "build-tools;33.0.2" "platform-tools" "system-images;android-27;default;x86_64"
130134
$ANDROID_HOME/cmdline-tools/latest/bin/avdmanager create avd --name Pixel_5_API_27 --force --device "pixel_5" --abi x86_64 --package "system-images;android-27;default;x86_64"
131135
132136
- name: Start Android emulator (cold boot - first run)
133137
if: ${{ matrix.platform == 'android' && steps.android-cache.outputs.cache-hit != 'true' }}
134138
run: |
135139
$ANDROID_HOME/emulator/emulator -avd Pixel_5_API_27 -port ${{ env.EMULATOR_PORT }} -no-boot-anim -no-audio -no-snapshot-load -gpu host -accel on &
136-
$ANDROID_HOME/platform-tools/adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed | tr -d '\r') ]]; do sleep 1; done; input keyevent 82'
140+
if ! timeout 420 $ANDROID_HOME/platform-tools/adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed | tr -d '\r') ]]; do sleep 1; done; input keyevent 82'; then
141+
echo "::error::Android emulator did not reach sys.boot_completed within 420s; failing fast instead of hanging until the 6h limit"
142+
$ANDROID_HOME/platform-tools/adb devices
143+
exit 1
144+
fi
137145
$ANDROID_HOME/platform-tools/adb devices
138146
# disable spell checker
139147
$ANDROID_HOME/platform-tools/adb shell settings put secure spell_checker_enabled 0
@@ -148,7 +156,11 @@ jobs:
148156
if: ${{ matrix.platform == 'android' && steps.android-cache.outputs.cache-hit == 'true' }}
149157
run: |
150158
$ANDROID_HOME/emulator/emulator -avd Pixel_5_API_27 -port ${{ env.EMULATOR_PORT }} -no-boot-anim -no-audio -snapshot default_boot -gpu host -accel on &
151-
$ANDROID_HOME/platform-tools/adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed | tr -d '\r') ]]; do sleep 1; done; input keyevent 82'
159+
if ! timeout 420 $ANDROID_HOME/platform-tools/adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed | tr -d '\r') ]]; do sleep 1; done; input keyevent 82'; then
160+
echo "::error::Android emulator did not reach sys.boot_completed within 420s; failing fast instead of hanging until the 6h limit"
161+
$ANDROID_HOME/platform-tools/adb devices
162+
exit 1
163+
fi
152164
$ANDROID_HOME/platform-tools/adb devices
153165
154166
- name: Create MegaApp ${{ env.MEGA_APP_NAME }} and run build on NodeJS ${{ matrix.node-version }}

0 commit comments

Comments
 (0)