fix script #23
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: E2E CI | |
on: | |
push: | |
branches: | |
- chore/maestro-ci | |
jobs: | |
run-tests: | |
runs-on: ubuntu-22.04-arm64-2cpu | |
timeout-minutes: 30 | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Get APK for testing | |
run: | | |
curl -o test.apk "https://github.com/digidem/comapeo-mobile/releases/download/untagged-142428c7d3d78b089aab/CoMapeo0.0.apk" | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: '17' | |
# https://developer.android.com/tools/variables | |
- name: Set up environment variables | |
run: | | |
mkdir -p $HOME/.android/sdk | |
mkdir -p $HOME/.android | |
echo "ANDROID_HOME=$HOME/.android/sdk" >> $GITHUB_ENV | |
echo "ANDROID_SDK_ROOT=$HOME/.android/sdk" >> $GITHUB_ENV | |
echo "ANDROID_SDK_HOME=$HOME" >> $GITHUB_ENV | |
echo "ANDROID_USER_HOME=$HOME/.android" >> $GITHUB_ENV | |
echo "ANDROID_EMULATOR_HOME=$HOME/.android" >> $GITHUB_ENV | |
echo "ANDROID_AVD_HOME=$HOME/.android/avd" >> $GITHUB_ENV | |
- name: Install Maestro | |
run: curl -Ls 'https://get.maestro.mobile.dev' | bash | |
- name: Setup Android SDK | |
uses: android-actions/setup-android@v3 | |
with: | |
packages: 'platform-tools' | |
# https://github.com/lzhiyong/android-sdk-tools/releases | |
- name: Install ADB | |
run: | | |
curl --compressed --location --output tools.zip https://github.com/lzhiyong/android-sdk-tools/releases/download/34.0.3/android-sdk-tools-static-aarch64.zip | |
unzip -d tools -n -q tools.zip | |
rm -f tools.zip | |
cp tools/platform-tools/adb $ANDROID_HOME/platform-tools/adb | |
rm -fr tools | |
shell: bash | |
# https://ci.android.com/builds/branches/aosp-emu-master-dev/grid | |
- name: Install Emulator | |
run: | | |
curl --compressed --location --output emulator.zip $(curl --location --silent https://ci.android.com/builds/submitted/11162281/emulator-linux_aarch64/latest/sdk-repo-linux_aarch64-emulator-11162281.zip | grep -o 'https://storage[^"]*' | sed 's/\\u0026/\&/g') | |
unzip -d $ANDROID_HOME -n -q emulator.zip | |
rm -f emulator.zip | |
cp $ANDROID_HOME/platform-tools/package.xml $ANDROID_HOME/emulator/package.xml | |
sed -i \ | |
-e 's|path="[a-zA-Z-]*"|path="emulator"|g' \ | |
-e 's|<display-name>Android .*<\/display-name>|<display-name>Android Emulator<\/display-name>|g' \ | |
$ANDROID_HOME/emulator/package.xml | |
echo 'Vulkan = off\nGLDirectMem = on' >> $ANDROID_USER_HOME/advancedFeatures.ini | |
shell: bash | |
- name: Install SDK Tools | |
run: | | |
sdkmanager 'platforms;android-34' 'system-images;android-34;google_apis;arm64-v8a' 'tools' | |
bash -c 'yes || true' | sdkmanager --licenses | |
shell: bash | |
- name: Create virtual device | |
run: | | |
pwd | |
echo no | avdmanager create avd --force --name emu --device "pixel_8" -k 'system-images;android-34;google_apis;arm64-v8a' | |
avdmanager list avd | |
ls -al $ANDROID_EMULATOR_HOME | |
echo "Emulator version:" | |
$ANDROID_HOME/emulator/emulator @emu -version | |
shell: bash | |
- 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: | | |
BL='\033[0;34m' | |
G='\033[0;32m' | |
RED='\033[0;31m' | |
YE='\033[1;33m' | |
NC='\033[0m' # No Color | |
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 | |
run: | | |
adb install test.apk | |
shell: bash | |
- name: Run Maestro tests | |
run: | | |
$HOME/.maestro/bin/maestro test e2e || true | |
adb logcat -d > logcat_output.txt | |
shell: bash | |
- name: Upload Logcat Output | |
uses: actions/upload-artifact@v4 | |
with: | |
name: logcat-output | |
path: logcat_output.txt | |
- name: Upload Maestro test artifacts | |
if: always() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: maestro-test-results | |
path: /home/runner/.maestro/tests/*/ | |
- name: Upload Screen Recording | |
if: always() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: E2E Screen Recording | |
path: ${{ github.workspace }}/recording-e2e-flow.* |