Automate Maestro E2E Tests on IOS #5
Workflow file for this run
This file contains hidden or 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: Maestro E2E Android | |
| on: | |
| push: | |
| branches: [master] | |
| pull_request: | |
| branches: [master] | |
| types: [opened, reopened, synchronize] | |
| workflow_dispatch: | |
| concurrency: | |
| group: maestro-android-${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| e2e-android: | |
| name: Test on Android | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 60 | |
| env: | |
| ANDROID_HOME: /home/runner/androidsdk | |
| ANDROID_SDK_ROOT: /home/runner/androidsdk | |
| ANDROID_AVD_HOME: /mnt/avd | |
| ANDROID_OS_IMAGE: system-images;android-32;google_apis;x86_64 | |
| ANDROID_PLATFORM: platforms;android-36 | |
| steps: | |
| - name: Enable KVM group perms | |
| run: | | |
| echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules | |
| sudo udevadm control --reload-rules | |
| sudo udevadm trigger --name-match=kvm | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Free disk space | |
| run: | | |
| df -h | |
| sudo rm -rf /usr/share/dotnet || true | |
| sudo rm -rf /opt/ghc || true | |
| sudo rm -rf /usr/local/.ghcup || true | |
| sudo rm -rf /opt/hostedtoolcache/CodeQL || true | |
| sudo docker system prune -af || true | |
| sudo mkdir -p /mnt/avd | |
| sudo chmod -R 777 /mnt/avd | |
| df -h | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "20.19.4" | |
| cache: npm | |
| - name: Install JS dependencies | |
| run: npm ci --ignore-scripts --prefer-offline --no-audit | |
| - name: Ensure Android native project | |
| run: | | |
| if [ ! -d android ]; then | |
| npx expo prebuild -p android --clean --no-install --non-interactive | |
| fi | |
| - name: Set up Java | |
| uses: actions/setup-java@v5 | |
| with: | |
| distribution: temurin | |
| java-version: "17" | |
| - name: Install Maestro CLI | |
| run: | | |
| curl --proto '=https' --tlsv1.2 -fsSL "https://get.maestro.mobile.dev" | bash | |
| echo "$HOME/.maestro/bin" >> "$GITHUB_PATH" | |
| export PATH="$HOME/.maestro/bin:$PATH" | |
| "$HOME/.maestro/bin/maestro" --version | |
| - name: Set up bartek-scripts | |
| run: | | |
| git clone --depth 1 https://github.com/mobile-dev-inc/bartek-scripts.git $HOME/scripts | |
| echo "$HOME/scripts/bin" >> "$GITHUB_PATH" | |
| - name: Set up Android command-line tools | |
| run: | | |
| install_android_sdk https://dl.google.com/android/repository/commandlinetools-linux-12266719_latest.zip | |
| echo "$ANDROID_HOME/cmdline-tools/latest/bin" >> "$GITHUB_PATH" | |
| echo "$ANDROID_HOME/emulator" >> "$GITHUB_PATH" | |
| echo "$ANDROID_HOME/platform-tools" >> "$GITHUB_PATH" | |
| - name: Set up Android SDK components | |
| run: | | |
| export PATH="$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/emulator:$ANDROID_HOME/platform-tools:$PATH" | |
| yes | sdkmanager --licenses | |
| sdkmanager --install \ | |
| "emulator" \ | |
| "platform-tools" \ | |
| "$ANDROID_PLATFORM" \ | |
| "build-tools;36.0.0" \ | |
| "$ANDROID_OS_IMAGE" | |
| - name: Create local.properties | |
| run: | | |
| echo "sdk.dir=$ANDROID_HOME" > android/local.properties | |
| cat android/local.properties | |
| - name: Build Android debug APK | |
| working-directory: android | |
| run: | | |
| chmod +x ./gradlew | |
| ./gradlew assembleDebug \ | |
| -PreactNativeArchitectures=x86_64 \ | |
| --stacktrace \ | |
| --console=plain \ | |
| --no-daemon \ | |
| --max-workers=2 | |
| - name: Create AVD | |
| run: | | |
| export PATH="$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/emulator:$ANDROID_HOME/platform-tools:$PATH" | |
| mkdir -p "$ANDROID_AVD_HOME" | |
| echo "no" | avdmanager create avd \ | |
| --force \ | |
| --package "$ANDROID_OS_IMAGE" \ | |
| --name "MyAVD" \ | |
| --sdcard 512M | |
| cat << EOF >> "$ANDROID_AVD_HOME/MyAVD.avd/config.ini" | |
| hw.cpu.ncore=2 | |
| hw.gpu.enabled=yes | |
| hw.gpu.mode=swiftshader_indirect | |
| hw.ramSize=3072 | |
| vm.heapSize=576 | |
| disk.dataPartition.size=2048M | |
| hw.lcd.density=440 | |
| hw.lcd.height=2220 | |
| hw.lcd.width=1080 | |
| fastboot.forceColdBoot=yes | |
| showDeviceFrame=no | |
| EOF | |
| - name: Run AVD | |
| run: | | |
| export PATH="$ANDROID_HOME/emulator:$ANDROID_HOME/platform-tools:$PATH" | |
| emulator @MyAVD \ | |
| -verbose \ | |
| -no-snapshot \ | |
| -no-window \ | |
| -no-audio \ | |
| -no-boot-anim \ | |
| -accel on \ | |
| -camera-back none \ | |
| -partition-size 2048 \ | |
| -qemu -m 3072 \ | |
| > ~/emulator_stdout.log \ | |
| 2> ~/emulator_stderr.log & | |
| - name: Wait for AVD to start up | |
| run: | | |
| export PATH="$ANDROID_HOME/platform-tools:$PATH" | |
| for i in {1..120}; do | |
| adb devices | |
| if adb devices | grep -q "emulator-.*device"; then | |
| echo "Emulator device online" | |
| break | |
| fi | |
| sleep 2 | |
| done | |
| adb wait-for-device | |
| adb shell 'while [[ "$(getprop sys.boot_completed | tr -d "\r")" != "1" ]]; do sleep 1; done;' && echo "Emulator booted" | |
| while true; do | |
| adb shell service list | grep 'package' && echo 'service "package" is active!' && break | |
| echo 'waiting for service "package" to start' | |
| sleep 1 | |
| done | |
| adb shell settings put global window_animation_scale 0 || true | |
| adb shell settings put global transition_animation_scale 0 || true | |
| adb shell settings put global animator_duration_scale 0 || true | |
| - name: Install app | |
| run: | | |
| adb install -r android/app/build/outputs/apk/debug/*.apk | |
| - name: Start screen recording of AVD | |
| run: | | |
| adb shell screenrecord /sdcard/screenrecord.mp4 & | |
| echo $! > ~/screenrecord.pid | |
| - name: Run tests | |
| timeout-minutes: 20 | |
| run: | | |
| mkdir -p .maestro/output | |
| maestro test .maestro/automated/suite.yaml \ | |
| --format junit \ | |
| --output .maestro/output/results.xml | |
| - name: Stop screen recording of AVD | |
| if: success() || failure() | |
| run: | | |
| kill -SIGINT "$(cat ~/screenrecord.pid)" || echo "failed to kill screenrecord" | |
| sleep 5 | |
| adb pull /sdcard/screenrecord.mp4 ~/screenrecord.mp4 || true | |
| - name: Upload Maestro artifacts | |
| uses: actions/upload-artifact@v4 | |
| if: failure() | |
| with: | |
| name: maestro-android-artifacts | |
| path: | | |
| .maestro/output/ | |
| ~/.maestro | |
| ~/emulator_stdout.log | |
| ~/emulator_stderr.log | |
| ~/screenrecord.mp4 | |
| if-no-files-found: ignore | |
| include-hidden-files: true |