From 5e2ede3a00720f4235ec1d2454ecad267659acd7 Mon Sep 17 00:00:00 2001 From: Samuel Newman Date: Fri, 17 Jul 2026 13:15:56 +0300 Subject: [PATCH] Provision Android emulator without external action --- .github/scripts/cleanup-nightly-e2e.sh | 1 + .github/workflows/nightly-e2e.yml | 68 +++++++++++++++++++++----- 2 files changed, 57 insertions(+), 12 deletions(-) diff --git a/.github/scripts/cleanup-nightly-e2e.sh b/.github/scripts/cleanup-nightly-e2e.sh index b6f569253c..8511c10b78 100755 --- a/.github/scripts/cleanup-nightly-e2e.sh +++ b/.github/scripts/cleanup-nightly-e2e.sh @@ -24,6 +24,7 @@ stop_pid_file() { stop_pid_file "$artifact_dir/metro.pid" stop_pid_file "$artifact_dir/mock-server.pid" +stop_pid_file "$artifact_dir/emulator.pid" if [[ "$platform" == "ios" ]]; then if [[ -f "$artifact_dir/redis-bin.txt" ]]; then diff --git a/.github/workflows/nightly-e2e.yml b/.github/workflows/nightly-e2e.yml index 0405c67179..d4b3f9b3d3 100644 --- a/.github/workflows/nightly-e2e.yml +++ b/.github/workflows/nightly-e2e.yml @@ -168,18 +168,62 @@ jobs: "$RUNNER_TEMP/maestro/bin/maestro" --version | tee artifacts/android/maestro-version.log test "$("$RUNNER_TEMP/maestro/bin/maestro" --version)" = "$MAESTRO_VERSION" - - name: Boot one Android emulator and run Maestro suite - uses: reactivecircus/android-emulator-runner@1dcd0090116d15e7c562f8db72807de5e036a4ed # v2.34.0 - with: - api-level: 35 - target: google_apis - arch: x86_64 - profile: pixel_6 - avd-name: nightly-e2e - emulator-port: 5554 - disable-animations: true - emulator-options: -no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim -camera-back none - script: .github/scripts/run-nightly-e2e.sh android emulator-5554 + - name: Install and boot one Android emulator + run: | + echo "Booting Android emulator" > artifacts/android/phase.txt + android_sdk="${ANDROID_SDK_ROOT:-${ANDROID_HOME:?ANDROID_HOME is not set}}" + sdkmanager_bin=$(command -v sdkmanager) + avdmanager_bin=$(command -v avdmanager) + system_image="system-images;android-35;google_apis;x86_64" + + yes | "$sdkmanager_bin" --sdk_root="$android_sdk" --licenses >/dev/null || true + "$sdkmanager_bin" --sdk_root="$android_sdk" \ + "platform-tools" "emulator" "$system_image" + + export ANDROID_AVD_HOME="$RUNNER_TEMP/.android/avd" + mkdir -p "$ANDROID_AVD_HOME" + echo "ANDROID_AVD_HOME=$ANDROID_AVD_HOME" >> "$GITHUB_ENV" + echo no | "$avdmanager_bin" create avd \ + --force \ + --name nightly-e2e \ + --package "$system_image" \ + --device pixel_6 + + if [ -e /dev/kvm ] && [ ! -w /dev/kvm ]; then + sudo chmod 666 /dev/kvm + fi + + "$android_sdk/emulator/emulator" @nightly-e2e \ + -port 5554 \ + -no-window \ + -gpu swiftshader_indirect \ + -no-snapshot \ + -noaudio \ + -no-boot-anim \ + -camera-back none \ + > artifacts/android/emulator.log 2>&1 & + echo "$!" > artifacts/android/emulator.pid + + adb -s emulator-5554 wait-for-device + booted=false + for _ in $(seq 1 120); do + if [ "$(adb -s emulator-5554 shell getprop sys.boot_completed 2>/dev/null | tr -d '\r')" = "1" ]; then + booted=true + break + fi + sleep 5 + done + if [ "$booted" != "true" ]; then + echo "Android emulator did not finish booting" >&2 + exit 1 + fi + + adb -s emulator-5554 shell settings put global window_animation_scale 0 + adb -s emulator-5554 shell settings put global transition_animation_scale 0 + adb -s emulator-5554 shell settings put global animator_duration_scale 0 + + - name: Run Android Maestro suite + run: .github/scripts/run-nightly-e2e.sh android emulator-5554 - name: Clean up Android services and emulator if: always()