Skip to content

Commit

Permalink
add Genymotion
Browse files Browse the repository at this point in the history
  • Loading branch information
retyui committed Aug 7, 2023
1 parent d144150 commit 0283fbd
Show file tree
Hide file tree
Showing 6 changed files with 180 additions and 26 deletions.
20 changes: 19 additions & 1 deletion .github/workflows/android-buildjet-ubuntu-amd64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,22 @@ jobs:
adb install app-release.apk
# Run e2e
$HOME/.maestro/bin/maestro test .maestro/ --env=APP_ID=com.retyui.myapp --output=report.xml --format=junit
./run_android_e2e.sh
# ^^^ Will debug files: report*.xml, video_record.mp4, last_img.png
- name: Upload report
if: always()
uses: actions/upload-artifact@v3
with:
name: e2e-report-${{ matrix.recipe_uuid }}
path: |
${{ github.workspace }}/*.mp4
${{ github.workspace }}/*.png
${{ github.workspace }}/report*.xml
- name: Upload debug logs
if: always()
uses: actions/upload-artifact@v3
with:
name: e2e-debug-logs-${{ matrix.recipe_uuid }}
path: ~/.maestro/tests/**/*
83 changes: 83 additions & 0 deletions .github/workflows/android-genymotion-cloud.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: Android E2E (Genymotion Cloud)

on: [push, pull_request]

env:
GMSAAS_INSTANCE_NAME: android-e2e-${{ github.run_number }}
ACTIONS_STEP_DEBUG: true

jobs:
run_android_e2e:
timeout-minutes: 45
runs-on: ubuntu-latest

strategy:
fail-fast: false
max-parallel: 10
matrix:
recipe_uuid: [95016679-8f8d-4890-b026-e4ad889aadf1]

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 1

- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 11

- name: Install Maestro
run: MAESTRO_VERSION=1.30.4 curl -Ls 'https://get.maestro.mobile.dev' | bash

- name: Install genymotion
run: |
pip3 install gmsaas
gmsaas config set android-sdk-path "$ANDROID_HOME"
- name: Auth genymotion
run: gmsaas auth login ${{ secrets.GMSAAS_EMAIL }} ${{ secrets.GMSAAS_PASSWORD }}

- name: Start an Instance
id: start_instance
run: |
gmsaas recipes list # List available recipes
INSTANCE_UUID=$(gmsaas instances start "${{ matrix.recipe_uuid }}" "${{ env.GMSAAS_INSTANCE_NAME }}")
echo "INSTANCE_UUID=$INSTANCE_UUID" >> "$GITHUB_OUTPUT"
- name: Connect an Instance to ADB
run: |
gmsaas instances adbconnect "${{ steps.start_instance.outputs.INSTANCE_UUID }}"
$ANDROID_HOME/platform-tools/adb devices
- name: Run Android E2E
run: |
$ANDROID_HOME/platform-tools/adb install app-release.apk
./run_android_e2e.sh
- name: Stop an Instance
if: always()
continue-on-error: true
run: |
gmsaas instances stop --no-wait "${{ steps.start_instance.outputs.INSTANCE_UUID }}"
gmsaas instances list
- name: Upload report
if: always()
uses: actions/upload-artifact@v3
with:
name: e2e-report-${{ matrix.recipe_uuid }}
path: |
${{ github.workspace }}/*.mp4
${{ github.workspace }}/*.png
${{ github.workspace }}/report*.xml
- name: Upload debug logs
if: always()
uses: actions/upload-artifact@v3
with:
name: e2e-debug-logs-${{ matrix.recipe_uuid }}
path: ~/.maestro/tests/**/*
31 changes: 19 additions & 12 deletions .github/workflows/android-github-actions-macos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -117,17 +117,24 @@ jobs:
adb install app-release.apk # install app
# Run e2e (3 attempts with different timeouts)
(echo "-Attempt:1-" && $HOME/.maestro/bin/maestro test .maestro/ --env=APP_ID=com.retyui.myapp --output=report1.xml --format=junit) || (echo "-Attempt:2-" && sleep 20 && $HOME/.maestro/bin/maestro test .maestro/ --env=APP_ID=com.retyui.myapp --output=report2.xml --format=junit) || (echo "-Attempt:3-" && sleep 60 && $HOME/.maestro/bin/maestro test .maestro/ --env=APP_ID=com.retyui.myapp --output=report3.xml --format=junit) || (echo "-Failed-" && exit 1)
# ^^^ I can't multiline operator `\` in `script` section as each line will be executed in a separate shell
# Run e2e
./run_android_e2e.sh
# ^^^ Will debug files: report*.xml, video_record.mp4, last_img.png
- name: Upload report
if: always()
uses: actions/upload-artifact@v3
with:
name: e2e-report-${{ matrix.recipe_uuid }}
path: |
${{ github.workspace }}/*.mp4
${{ github.workspace }}/*.png
${{ github.workspace }}/report*.xml
- name: Upload debug logs
if: always()
uses: actions/upload-artifact@v3
with:
name: e2e-debug-logs-${{ matrix.recipe_uuid }}
path: ~/.maestro/tests/**/*

# - name: Upload artifacts
# if: always() # when prev. step failed, this step won't be skipped
# uses: actions/upload-artifact@v3
# with:
# name: e2e-report
# path: |
# *.mp4
# report*.xml
28 changes: 15 additions & 13 deletions .github/workflows/android-github-actions-ubuntu.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -92,24 +92,26 @@ jobs:
adb install app-release.apk # install app
# Run e2e (3 attempts with different timeouts)
(echo "-Attempt:1-" && $HOME/.maestro/bin/maestro test .maestro/ --env=APP_ID=com.retyui.myapp --output=report1.xml --format=junit) || (echo "-Attempt:2-" && sleep 20 && $HOME/.maestro/bin/maestro test .maestro/ --env=APP_ID=com.retyui.myapp --output=report2.xml --format=junit) || (echo "-Attempt:3-" && sleep 60 && $HOME/.maestro/bin/maestro test .maestro/ --env=APP_ID=com.retyui.myapp --output=report3.xml --format=junit) || (echo "-Failed-" && exit 1)
# Run e2e
./run_android_e2e.sh
# ^^^ Will debug files: report*.xml, video_record.mp4, last_img.png
# ^^^ I can't multiline operator `\` in `script` section as each line will be executed in a separate shell
- name: Upload artifacts
if: always() # when prev. step failed, this step won't be skipped
- name: Upload report
if: always()
uses: actions/upload-artifact@v3
with:
name: e2e-report-${{ matrix.api-level }}-${{ matrix.arch }}-${{ matrix.target }}
path: ~/.maestro/tests/**/*

- name: Upload artifacts 2
if: always() # when prev. step failed, this step won't be skipped
uses: actions/upload-artifact@v3
with:
name: 2-e2e-report-${{ matrix.api-level }}-${{ matrix.arch }}-${{ matrix.target }}
name: e2e-report-${{ matrix.recipe_uuid }}
path: |
${{ github.workspace }}/*.mp4
${{ github.workspace }}/*.png
${{ github.workspace }}/report*.xml
- name: Upload debug logs
if: always()
uses: actions/upload-artifact@v3
with:
name: e2e-debug-logs-${{ matrix.recipe_uuid }}
path: ~/.maestro/tests/**/*

3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
# Maestor e2e report
/*.mp4
/*.png
/*.xml
41 changes: 41 additions & 0 deletions run_android_e2e.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/bash

set -x # all executed commands are printed to the terminal

TMP_FILE=_fail_proccess

# Start video record
$ANDROID_HOME/platform-tools/adb shell screenrecord /sdcard/video_record.mp4 & echo $! > video_record.pid
sleep 3

APP_ID=com.retyui.myapp

# Retry 3 times before the steps actually fails
(echo "===== Run E2E Attempt: 1 ====" && $HOME/.maestro/bin/maestro test .maestro/ --env=APP_ID="$APP_ID" --format=junit --output report1.xml) || \
(echo "===== Run E2E Attempt: 2 ====" && sleep 20 && $HOME/.maestro/bin/maestro test .maestro/ --env=APP_ID="$APP_ID" --format=junit --output report2.xml) || \
(echo "===== Run E2E Attempt: 3 ====" && sleep 60 && $HOME/.maestro/bin/maestro test .maestro/ --env=APP_ID="$APP_ID" --format=junit --output report3.xml) || \
(echo "===== Run E2E Step Failed ====" && touch "$TMP_FILE")

# Stop video record process
kill -SIGINT "$(cat video_record.pid)"
sleep 3
rm -rf video_record.pid

# Take screenshot
$ANDROID_HOME/platform-tools/adb shell screencap -p /sdcard/last_img.png
$ANDROID_HOME/platform-tools/adb pull /sdcard/last_img.png

# Move the video from Emulator to Host filesystem
$ANDROID_HOME/platform-tools/adb pull /sdcard/video_record.mp4
$ANDROID_HOME/platform-tools/adb shell rm /sdcard/video_record.mp4

# Debug
$HOME/.maestro/bin/maestro hierarchy

if [ -f "$TMP_FILE" ]; then
rm -rf "$TMP_FILE"
echo "3 tries have failed..."
exit 1
esle
echo "Success..."
fi

0 comments on commit 0283fbd

Please sign in to comment.