Single headless emulator - 47 #60
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: Setup Dependencies and Tools | |
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 | |
export PATH=$PATH:$(pwd)/cmdline-tools/tools/bin | |
yes | sdkmanager --licenses | |
sdkmanager "platform-tools" "platforms;android-30" "system-images;android-30;google_apis;x86_64" | |
export ANDROID_HOME=$(pwd)/cmdline-tools | |
- name: Start Emulators and Poll for Readiness | |
run: | | |
for i in {1..4} | |
do | |
echo "no" | avdmanager create avd -n "testAVD$i" -k "system-images;android-30;google_apis;x86_64" --force | |
emulator -avd "testAVD$i" -no-audio -no-window -no-boot-anim & | |
done | |
# Wait for devices to get connected | |
adb wait-for-device | |
# Polling for device readiness | |
let port=5554 # Starting port number for adb connections | |
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 # Increment by 2 for the next emulator | |
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 |