6767 instrumentation-tests :
6868 name : Instrumentation Tests
6969 runs-on : ubuntu-latest
70+ env :
71+ ANDROID_AVD_HOME : ${{ github.workspace }}/.android/avd
7072 if : github.ref == 'refs/heads/main' || github.event.pull_request.base.ref == 'main'
7173 needs : prepare
7274 steps :
@@ -80,30 +82,56 @@ jobs:
8082 - name : Setup Android SDK
8183 uses : android-actions/setup-android@v3
8284
83- - name : Increase VM Performance
85+ - name : Install system image
86+ run : sdkmanager "system-images;android-29;google_apis;x86"
87+
88+ - name : Create AVD
89+ run : |
90+ mkdir -p $ANDROID_AVD_HOME
91+ echo "no" | avdmanager create avd -n test -k "system-images;android-29;google_apis;x86" --device "pixel"
92+ avdmanager list avd
93+ ls -l $ANDROID_AVD_HOME
94+
95+ - name : Start Emulator
96+ run : |
97+ $ANDROID_HOME/emulator/emulator -avd test -accel off -no-snapshot-save -no-window -no-audio -gpu swiftshader_indirect -no-boot-anim &
98+ echo $! > emulator.pid
99+
100+ - name : Wait for Emulator to Boot
84101 run : |
85- echo "Installing KVM acceleration tools"
86- sudo apt-get update
87- sudo apt-get install -y qemu-kvm libvirt-daemon-system libvirt-clients bridge-utils
102+ echo "Waiting for emulator to start..."
103+ adb wait-for-device
104+
105+ boot_completed=""
106+ until [ "$boot_completed" = "1" ]; do
107+ sleep 5
108+ boot_completed=$(adb shell getprop sys.boot_completed | tr -d '\r')
109+ echo "Waiting... boot_completed=$boot_completed"
110+ done
111+
112+ until adb shell pm list packages > /dev/null 2>&1; do
113+ echo "Waiting for package manager to become available..."
114+ sleep 5
115+ done
116+
117+ api_level=""
118+ until [ -n "$api_level" ] && [ "$api_level" != "unknown" ]; do
119+ sleep 5
120+ api_level=$(adb shell getprop ro.build.version.sdk 2>/dev/null | tr -d '\r')
121+ echo "Waiting for emulator to report API level... api_level=$api_level"
122+ done
123+
124+ echo "Emulator fully ready with API level $api_level"
88125
89126 - name : Run Instrumentation Tests
90- uses : reactivecircus/android-emulator-runner@v2
91- with :
92- api-level : 29
93- target : google_apis
94- profile : pixel
95- emulator-options : " -no-window -no-audio -gpu swiftshader_indirect -no-boot-anim"
96- disable-animations : true
97- script : |
98- adb wait-for-device
99- boot_completed=""
100- while [ "$boot_completed" != "1" ]; do
101- sleep 5
102- boot_completed=$(adb shell getprop sys.boot_completed | tr -d '\r')
103- echo "Waiting for emulator... (boot_completed=$boot_completed)"
104- done
105- echo "Emulator ready!"
106- ./gradlew connectedCheck --build-cache --parallel
127+ run : ./gradlew connectedCheck --build-cache --parallel
128+
129+ - name : Kill Emulator
130+ if : always()
131+ run : |
132+ if [ -f emulator.pid ]; then
133+ kill $(cat emulator.pid) || true
134+ fi
107135
108136 build-release :
109137 name : Build APK & AAB
0 commit comments