test-e2e.yaml•10.9 kB
name: Test E2E
on:
workflow_dispatch:
pull_request:
jobs:
build:
name: Build on Java ${{ matrix.java-version }}
runs-on: macos-latest
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
java-version: [17]
steps:
- name: Clone repository
uses: actions/checkout@v4
- name: Set up Java
uses: actions/setup-java@v4
with:
distribution: zulu
java-version: ${{ matrix.java-version }}
cache: gradle
- name: Build xctest-runner
run: ./maestro-ios-xctest-runner/build-maestro-ios-runner.sh | xcbeautify
- name: Build Maestro CLI
run: ./gradlew :maestro-cli:distZip
- name: Upload zipped Maestro CLI artifact
uses: actions/upload-artifact@v4
with:
name: maestro-cli-jdk${{ matrix.java-version }}-run_id${{ github.run_id }}
path: maestro-cli/build/distributions/maestro.zip
retention-days: 1
- name: Upload build/Products to artifacts
uses: actions/upload-artifact@v4
with:
name: build__Products-jdk${{ matrix.java-version }}
path: build/Products
retention-days: 1
test-android:
name: Test on Android
runs-on: ubuntu-latest
needs: build
timeout-minutes: 60
env:
ANDROID_HOME: /home/runner/androidsdk
ANDROID_SDK_ROOT: /home/runner/androidsdk
ANDROID_AVD_HOME: /home/runner/.config/.android/avd/
ANDROID_OS_IMAGE: system-images;android-32;google_apis;x86_64
ANDROID_PLATFORM: platforms;android-34
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: Clone repository (only needed for the e2e directory)
uses: actions/checkout@v4
- name: Set up Java
uses: actions/setup-java@v4
with:
distribution: zulu
java-version: 17
- name: Download Maestro build from previous job
uses: actions/download-artifact@v4
with:
name: maestro-cli-jdk17-run_id${{ github.run_id }}
- name: Add Maestro CLI executable to PATH
run: |
unzip maestro.zip -d maestro_extracted
echo "$PWD/maestro_extracted/maestro/bin" >> $GITHUB_PATH
- name: Check if Maestro CLI executable starts up
run: |
maestro --help
maestro --version
- name: Set up mobile-dev-inc/bartek-scripts (for install_android_sdk script)
run: |
git clone 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: |
# v13 - see https://stackoverflow.com/a/78890086/7009800
install_android_sdk https://dl.google.com/android/repository/commandlinetools-linux-12266719_latest.zip
echo "$ANDROID_HOME/cmdline-tools/latest/bin:$PATH" >> $GITHUB_PATH
- name: Set up Android SDK components
run: |
yes | sdkmanager --licenses
sdkmanager --install emulator
echo "$ANDROID_HOME/emulator" >> $GITHUB_PATH
sdkmanager --install "platform-tools"
echo "$ANDROID_HOME/platform-tools" >> $GITHUB_PATH
sdkmanager --install "$ANDROID_PLATFORM"
sdkmanager --install "$ANDROID_OS_IMAGE"
- name: Create AVD
run: |
avdmanager -s create avd \
--package "$ANDROID_OS_IMAGE" \
--name "MyAVD"
echo "DEBUG INFO"
avdmanager list avd
echo "ANDROID_PREFS_ROOT=$ANDROID_PREFS_ROOT"
echo "ANDROID_SDK_ROOT=$ANDROID_SDK_ROOT"
echo "ANDROID_HOME=$ANDROID_HOME"
echo "ANDROID_SDK_HOME=$ANDROID_SDK_HOME"
echo "ANDROID_AVD_HOME=$ANDROID_AVD_HOME"
echo "ANDROID_EMULATOR_HOME=$ANDROID_EMULATOR_HOME"
echo "HOME=$HOME"
cat << EOF >> ~/.config/.android/avd/MyAVD.avd/config.ini
hw.cpu.ncore=2
hw.gpu.enabled=yes
hw.gpu.mode=swiftshader_indirect
hw.ramSize=3072
disk.dataPartition.size=4G
vm.heapSize=576
hw.lcd.density=440
hw.lcd.height=2220
hw.lcd.width=1080
EOF
- name: Run AVD
run: |
emulator @MyAVD \
-verbose -no-snapshot -no-window -no-audio -no-boot-anim -accel on -camera-back none -qemu -m 3072 \
>~/emulator_stdout.log \
2>~/emulator_stderr.log &
- name: Wait for AVD to start up
run: |
adb wait-for-device && echo 'Emulator device online'
adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1; done;' && echo 'Emulator booted'
# This is also a prerequiste
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
- name: Download apps
working-directory: ${{ github.workspace }}/e2e
run: ./download_apps android
- name: Install apps
working-directory: ${{ github.workspace }}/e2e
run: ./install_apps android
- name: Start screen recording of AVD
run: |
adb shell screenrecord /sdcard/screenrecord.mp4 &
echo $! > ~/screenrecord.pid
- name: Run tests
working-directory: ${{ github.workspace }}/e2e
timeout-minutes: 20
run: ./run_tests android
- name: Stop screen recording of AVD
if: success() || failure()
run: |
kill -SIGINT "$(cat ~/screenrecord.pid)" || echo "failed to kill screenrecord: code $?" && exit 0
sleep 5 # prevent video file corruption
adb pull /sdcard/screenrecord.mp4 ~/screenrecord.mp4
- name: Upload ~/.maestro artifacts
uses: actions/upload-artifact@v4
if: success() || failure()
with:
name: maestro-root-dir-android
path: ~/.maestro
retention-days: 7
include-hidden-files: true
- name: Upload screen recording of AVD
uses: actions/upload-artifact@v4
if: success() || failure()
with:
name: maestro-screenrecord-android.mp4
path: ~/screenrecord.mp4
retention-days: 7
test-ios:
name: Test on iOS
runs-on: macos-latest
needs: build
timeout-minutes: 120
if: ${{ false }}
env:
MAESTRO_DRIVER_STARTUP_TIMEOUT: 240000 # 240s
MAESTRO_CLI_LOG_PATTERN_CONSOLE: '%d{HH:mm:ss.SSS} [%5level] %logger.%method: %msg%n'
steps:
- name: Clone repository (only needed for the e2e directory)
uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: zulu
java-version: 8
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: maestro-cli-jdk17-run_id${{ github.run_id }}
- name: Add Maestro CLI executable to PATH
run: |
unzip maestro.zip -d maestro_extracted
echo "$PWD/maestro_extracted/maestro/bin" >> $GITHUB_PATH
- name: Check if Maestro CLI executable starts up
run: |
maestro --help
maestro --version
- name: Run simulator
run: xcrun simctl boot iPhone\ 15
- name: Wait for simulator to boot
run: xcrun simctl bootstatus iPhone\ 15
- name: Download apps
working-directory: ${{ github.workspace }}/e2e
run: ./download_apps ios
- name: Install apps
working-directory: ${{ github.workspace }}/e2e
run: ./install_apps ios
- name: Start screen recording
run: |
xcrun simctl io booted recordVideo --codec h264 ~/screenrecord.mp4 &
echo $! > ~/screenrecord.pid
- name: Run tests
working-directory: ${{ github.workspace }}/e2e
timeout-minutes: 120
run: ./run_tests ios
- name: Stop screen recording
if: success() || failure()
run: kill -SIGINT "$(cat ~/screenrecord.pid)"
- name: Upload ~/.maestro artifacts
uses: actions/upload-artifact@v4
if: success() || failure()
with:
name: maestro-root-dir-ios
path: ~/.maestro
retention-days: 7
include-hidden-files: true
- name: Upload xc test runner logs
uses: actions/upload-artifact@v4
if: success() || failure()
with:
name: xctest_runner_logs
path: ~/Library/Logs/maestro/xctest_runner_logs
retention-days: 7
include-hidden-files: true
- name: Upload screen recording of AVD
uses: actions/upload-artifact@v4
if: success() || failure()
with:
name: maestro-screenrecord-ios.mp4
path: ~/screenrecord.mp4
retention-days: 7
test-ios-xctest-runner:
name: Test on iOS (XCTest Runner only)
if: false # Disabled: This needs be fixed, not working yet.
runs-on: macos-latest
needs: build
timeout-minutes: 30
steps:
- name: Clone repository (only needed for the e2e directory)
uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: zulu
java-version: 8
- name: Download Maestro artifact
uses: actions/download-artifact@v4
with:
name: maestro-cli-jdk17-run_id${{ github.run_id }}
- name: Download build/Products artifact
uses: actions/download-artifact@v4
with:
name: build__Products-jdk11
path: build/Products
- name: Add Maestro CLI executable to PATH
run: |
unzip maestro.zip -d maestro_extracted
echo "$PWD/maestro_extracted/maestro/bin" >> $GITHUB_PATH
- name: Check if Maestro CLI executable starts up
run: |
maestro --help
maestro --version
- name: Run simulator
run: xcrun simctl boot iPhone\ 15
- name: Wait for simulator to boot
run: xcrun simctl bootstatus iPhone\ 15
- name: Run tests
timeout-minutes: 15
run: ./maestro-ios-xctest-runner/test-maestro-ios-runner.sh
- name: Upload xc test runner logs
uses: actions/upload-artifact@v4
if: success() || failure()
with:
name: test-ios-xctest-runner__xctest_runner_logs
path: ~/Library/Logs/maestro/xctest_runner_logs
retention-days: 7
include-hidden-files: true