Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: attempt arm64 CI #846

Draft
wants to merge 47 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
1d221e0
chore: attempt arm64 CI
gmaclennan Nov 14, 2024
ff0ad3e
actually run action
gmaclennan Nov 14, 2024
2358de1
replace placeholder paths
gmaclennan Nov 14, 2024
dd518a1
change avd name
gmaclennan Nov 14, 2024
a331728
add device
gmaclennan Nov 14, 2024
b7fa56f
try to fix emulator name
gmaclennan Nov 14, 2024
e81faae
fix avd path
gmaclennan Nov 14, 2024
08b081d
get there eventually...
gmaclennan Nov 14, 2024
9ad3eae
😠
gmaclennan Nov 14, 2024
a43459f
one day we'll get there...
gmaclennan Nov 14, 2024
b22b9a9
remove platform install
gmaclennan Nov 14, 2024
37432ae
😏
gmaclennan Nov 14, 2024
df779d0
😝
gmaclennan Nov 14, 2024
9c66ca8
argh, file locations for Android SDK are a headache!
gmaclennan Nov 14, 2024
e2a6e20
oh wow this is complicated...
gmaclennan Nov 14, 2024
0f771cd
one day...
gmaclennan Nov 14, 2024
5ed4d67
ok
gmaclennan Nov 14, 2024
949f316
add platforms install
gmaclennan Nov 14, 2024
20f9625
remove accel-check
gmaclennan Nov 14, 2024
45ce86a
run emulator in background
gmaclennan Nov 14, 2024
364cfe7
remove hw accel check
gmaclennan Nov 14, 2024
d96ffbb
tweak emulator flags
gmaclennan Nov 14, 2024
06a4521
different script to wait for emulator
gmaclennan Nov 14, 2024
2d2aff5
fix script
gmaclennan Nov 14, 2024
8640cfc
fixes
gmaclennan Nov 14, 2024
91dcd98
latest emulator
gmaclennan Nov 14, 2024
124a819
switch emulator versions
gmaclennan Nov 14, 2024
12e20b6
install less
gmaclennan Nov 14, 2024
fc9fc15
try different build
gmaclennan Nov 14, 2024
645d233
skip jdk install and watch emulator
gmaclennan Nov 14, 2024
f54f33f
add JDK back
gmaclennan Nov 14, 2024
2a5d976
more debugging
gmaclennan Nov 15, 2024
2f9b9ba
tweak output
gmaclennan Nov 15, 2024
9e5baa8
update system0image
gmaclennan Nov 15, 2024
c3400d0
adjust versions
gmaclennan Nov 15, 2024
f035733
fix
gmaclennan Nov 15, 2024
367cc54
fix system image
gmaclennan Nov 15, 2024
a6e84b7
run emulator in background
gmaclennan Nov 15, 2024
8c464a2
try api30
gmaclennan Nov 15, 2024
d0069a8
fix emu command
gmaclennan Nov 15, 2024
4764041
back to api 28
gmaclennan Nov 15, 2024
d808414
fix emulator opts
gmaclennan Nov 15, 2024
be08b08
one last try
gmaclennan Nov 15, 2024
d1e3290
ok one other thing
gmaclennan Nov 15, 2024
debfed0
carry on regardless
gmaclennan Nov 15, 2024
5b4278c
log boot prop at end
gmaclennan Nov 15, 2024
46b089c
give it longer to boot
gmaclennan Nov 15, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
141 changes: 141 additions & 0 deletions .github/workflows/maestro.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
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/platforms
mkdir -p $HOME/.android/sdk/platform-tools
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/11435509/emulator-linux_aarch64/latest/sdk-repo-linux_aarch64-emulator-11435509.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 'system-images;android-28;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-28;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
timeout-minutes: 5
run: |
adb devices
nohup $ANDROID_HOME/emulator/emulator -avd emu -cores 2 -no-window -gpu swiftshader_indirect -memory 2048 -skip-adb-auth -ports 5554,5555 -no-snapshot -show-kernel -noaudio -no-boot-anim -logcat "*:v" -accel off -camera-back emulated -qemu -cpu max -machine gic-version=2 &> emu.log &
echo "Emulator started"
shell: bash

- name: Wait for emulator to boot
timeout-minutes: 12
continue-on-error: true
run: |
adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 4; done; input keyevent 82'
adb devices -l

- 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: Emulator logs
if: always()
run: |
adb devices -l
jobs
cat emu.log
echo "boot prop"
adb shell getprop sys.boot_completed
shell: bash

- 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.*
58 changes: 58 additions & 0 deletions scripts/wait-for-emulator.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/bin/bash

BL='\033[0;34m'
G='\033[0;32m'
RED='\033[0;31m'
YE='\033[1;33m'
NC='\033[0m' # No Color

function check_emulator_status () {
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
};

function disable_animation() {
adb shell "settings put global window_animation_scale 0.0"
adb shell "settings put global transition_animation_scale 0.0"
adb shell "settings put global animator_duration_scale 0.0"
};

function hidden_policy() {
adb shell "settings put global hidden_api_policy_pre_p_apps 1;settings put global hidden_api_policy_p_apps 1;settings put global hidden_api_policy 1"
};

sleep 2
check_emulator_status
sleep 1
disable_animation
sleep 1
# hidden_policy
# sleep 1
Loading