Skip to content

Commit

Permalink
different script to wait for emulator
Browse files Browse the repository at this point in the history
  • Loading branch information
gmaclennan committed Nov 14, 2024
1 parent d96ffbb commit 06a4521
Showing 1 changed file with 31 additions and 3 deletions.
34 changes: 31 additions & 3 deletions .github/workflows/maestro.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,42 @@ jobs:

- name: Start emulator
run: |
adb devices
$ANDROID_HOME/emulator/emulator -avd emu -no-window -gpu swiftshader_indirect -memory 2048 -no-snapshot -noaudio -skip-adb-auth -no-boot-anim -accel off -camera-back emulated -qemu -cpu max -machine gic-version=max &
shell: bash

- name: Wait for emulator to boot
run: |
adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 3; done; input keyevent 82'
echo "Device booted. Listing connected devices:"
adb devices
printf "${G}==> ${BL}Checking emulator booting up status 🧐${NC}\n"
start_time=$(date +%s)
spinner=( "⠹" "⠺" "⠼" "⠶" "⠦" "⠧" "⠇" "⠏" )
i=0
# Get the timeout value from the environment variable or use the default value of 300 seconds (5 minutes)
timeout=${EMULATOR_TIMEOUT:-300}
while true; do
result=$(adb shell getprop sys.boot_completed 2>&1)
if [ "$result" == "1" ]; then
printf "\e[K${G}==> \u2713 Emulator is ready : '$result' ${NC}\n"
adb devices -l
adb shell input keyevent 82
break
elif [ "$result" == "" ]; then
printf "${YE}==> Emulator is partially Booted! 😕 ${spinner[$i]} ${NC}\r"
else
printf "${RED}==> $result, please wait ${spinner[$i]} ${NC}\r"
i=$(( (i+1) % 8 ))
fi
current_time=$(date +%s)
elapsed_time=$((current_time - start_time))
if [ $elapsed_time -gt $timeout ]; then
printf "${RED}==> Timeout after ${timeout} seconds elapsed 🕛.. ${NC}\n"
break
fi
sleep 4
done
shell: bash

- name: Install APK
Expand Down

0 comments on commit 06a4521

Please sign in to comment.