Single headless emulator - 51 #63
This file contains 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
name: Android CI | |
on: | |
push: | |
branches: | |
- "*" | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v4 | |
- name: Install Dependencies | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y qemu-kvm libvirt-daemon-system libvirt-clients bridge-utils | |
sudo adduser $USER kvm | |
- name: Setup JDK and Android SDK | |
run: | | |
sudo apt-get install -y openjdk-17-jdk | |
wget https://dl.google.com/android/repository/commandlinetools-linux-6609375_latest.zip | |
unzip commandlinetools-linux-6609375_latest.zip -d cmdline-tools | |
echo "ANDROID_HOME=$PWD/cmdline-tools" >> $GITHUB_ENV | |
echo "PATH=$PATH:$PWD/cmdline-tools/cmdline-tools/bin:$PWD/cmdline-tools/emulator:$PWD/cmdline-tools/platform-tools" >> $GITHUB_ENV | |
source $GITHUB_ENV | |
sdkmanager --licenses | |
sdkmanager "platform-tools" "platforms;android-30" "system-images;android-30;google_apis;x86_64" | |
- name: Start Emulators and Check Readiness | |
run: | | |
sdkmanager --install "emulator" | |
for i in {1..4} | |
do | |
echo "no" | avdmanager create avd -n "testAVD$i" -k "system-images;android-30;google_apis;x86_64" --force | |
$ANDROID_HOME/emulator/emulator -avd "testAVD$i" -no-audio -no-window -no-boot-anim & | |
done | |
sleep 30 | |
adb wait-for-device | |
let port=5554 | |
for i in {1..4} | |
do | |
until adb -s emulator-$port shell 'getprop sys.boot_completed' | grep -m 1 '1'; do | |
echo "Waiting for emulator-$port to fully boot..." | |
sleep 10 | |
done | |
let port+=2 | |
done | |
echo "All emulators are ready." | |
- name: Execute Control Script | |
run: | | |
bash main.sh | |
- name: Cleanup Emulators | |
if: always() | |
run: | | |
adb devices | grep emulator | cut -f1 | while read line; do adb -s $line emu kill; done |