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,49 @@ jobs:
8082 - name : Setup Android SDK
8183 uses : android-actions/setup-android@v3
8284
83- - name : Increase VM Performance
85+ - name : Install ARM system image
86+ run : sdkmanager "system-images;android-28;default;armeabi-v7a"
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-28;default;armeabi-v7a" --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+ echo "Emulator is ready."
88118
89119 - 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
120+ run : ./gradlew connectedCheck --build-cache --parallel
121+
122+ - name : Kill Emulator
123+ if : always()
124+ run : |
125+ if [ -f emulator.pid ]; then
126+ kill $(cat emulator.pid) || true
127+ fi
107128
108129 build-release :
109130 name : Build APK & AAB
0 commit comments