Created
June 26, 2024 02:57
-
-
Save rayworks/e1239c42a2ce541da53e95f8b142805b to your computer and use it in GitHub Desktop.
CI scripts in GitHub workflow
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
#!/bin/bash | |
adb wait-for-device | |
A=$(adb shell getprop sys.boot_completed | tr -d '\r') | |
while [ "$A" != "1" ]; do | |
sleep 2 | |
A=$(adb shell getprop sys.boot_completed | tr -d '\r') | |
done | |
echo "Unlocking screen" | |
adb shell input keyevent 82 | |
echo "Emulator is ready" |
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
ci: | |
name: ci | |
runs-on: [self-hosted, macos, arm64 ] | |
steps: | |
- name: Run instrumentation tests | |
run: | | |
# Running emulator | |
wdir=$(pwd) | |
echo $wdir | |
# Kill all running emulators | |
adb devices | grep emulator | cut -f1 | while read line; do adb -s $line emu kill; done | |
# Install the emulator system image if not | |
cd $ANDROID_HOME/cmdline-tools/latest/bin | |
sdk="system-images;android-34;default;arm64-v8a" | |
installedImage=$(./sdkmanager --list_installed | grep -o $sdk) | |
if [[ $installedImage = $sdk ]]; then | |
echo "The required SDK is already installed"; | |
else | |
yes | ./sdkmanager --install $sdk | |
yes | ./sdkmanager --licenses | |
fi | |
name=Test_Pixel_2_API_34 | |
cd $ANDROID_HOME/cmdline-tools/latest/bin | |
echo no | ./avdmanager create avd --force --name $name --abi arm64-v8a --package $sdk | |
cd $ANDROID_HOME/emulator | |
./emulator -list-avds | |
echo 'starting the AVD' | |
nohup ./emulator -avd $name -memory 2048 -cache-size 1000 -partition-size 6144 -wipe-data -no-boot-anim -no-window -no-audio 2>&1 & | |
echo 'waiting for booting AVD' | |
chmod +x $wdir/.github/workflows/android-wait-for-emulator.sh | |
$wdir/.github/workflows/android-wait-for-emulator.sh | |
echo 'ready to run tests...' | |
# Do testing | |
cd $wdir | |
./gradlew connectedCheck --stacktrace | |
# Kill and delete the created emulator | |
adb devices | |
adb devices | grep emulator | cut -f1 | while read line; do adb -s $line emu kill && sleep 10; done | |
cd $ANDROID_HOME/cmdline-tools/latest/bin | |
./avdmanager delete avd -n $name | |
cd $wdir | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment