Skip to content

maestro-utils: convert to KTS #165

maestro-utils: convert to KTS

maestro-utils: convert to KTS #165

Workflow file for this run

name: Test E2E
on:
workflow_dispatch:
pull_request:
jobs:
build:
runs-on: macos-latest
if: github.repository == 'mobile-dev-inc/maestro'
steps:
- name: Clone repository
uses: actions/checkout@v4
- name: Set up Java
uses: actions/setup-java@v4
with:
distribution: zulu
java-version: 11
- name: Set up Gradle
uses: gradle/actions/setup-gradle@v3
- name: Build xctest-runner
run: ./maestro-ios-xctest-runner/build-maestro-ios-runner.sh
- name: Build Maestro CLI
run: ./gradlew :maestro-cli:distZip
- uses: actions/upload-artifact@v4
with:
name: maestro-cli
path: maestro-cli/build/distributions/maestro.zip
retention-days: 1
test-local-android:
name: Test on Android
runs-on: ubuntu-latest
if: github.repository == 'mobile-dev-inc/maestro'
needs: build
env:
ANDROID_HOME: /home/runner/androidsdk
ANDROID_SDK_ROOT: /home/runner/androidsdk
ANDROID_OS_IMAGE: system-images;android-28;google_apis;x86_64
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: 8
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: maestro-cli
- 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 bartekpacia/scripts (for install_android_sdk script)
run: |
git clone https://github.com/bartekpacia/scripts.git $HOME/scripts
echo "$HOME/scripts/bin" >> $GITHUB_PATH
- name: Set up android-wait-for-emulator script
run: |
curl -fsSl -O https://raw.githubusercontent.com/travis-ci/travis-cookbooks/master/community-cookbooks/android-sdk/files/default/android-wait-for-emulator
chmod +x ./android-wait-for-emulator
mv ./android-wait-for-emulator $HOME/scripts/bin
- name: Set up Android Command-line Tools
run: |
# v8, latest working on Java 8. Source: https://stackoverflow.com/a/78890086/7009800
install_android_sdk https://dl.google.com/android/repository/commandlinetools-linux-9123335_latest.zip
echo "$ANDROID_HOME/cmdline-tools/latest/bin:$PATH" >> $GITHUB_PATH
- name: Set up Android SDK components
run: |
yes | sdkmanager --install emulator
echo "$ANDROID_HOME/emulator" >> $GITHUB_PATH
yes | sdkmanager --install "platform-tools"
echo "$ANDROID_HOME/platform-tools" >> $GITHUB_PATH
yes | sdkmanager --install "platforms;android-34"
yes | sdkmanager --install "$ANDROID_OS_IMAGE"
- name: Create AVD
run: |
avdmanager -s create avd \
--package "$ANDROID_OS_IMAGE" \
--name "MyAVD"
cat << EOF >> ~/.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-save -no-window -noaudio -no-boot-anim -accel on -camera-back none \
>~/emulator_stdout.log \
2>~/emulator_stderr.log &
- name: Wait for AVD to start up
run: |
android-wait-for-emulator
# 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
- name: Install apps
working-directory: ${{ github.workspace }}/e2e
run: ./install_apps
- name: Run tests
working-directory: ${{ github.workspace }}/e2e
run: ./run_tests
- name: Upload ~/.maestro artifacts
uses: actions/upload-artifact@v4
if: failure()
with:
name: maestro-e2e-output
path: ~/.maestro
retention-days: 3