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 e0e9fdd
Show file tree
Hide file tree
Showing 7 changed files with 228 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/**/*
95 changes: 95 additions & 0 deletions .github/workflows/android-genymotion-cloud.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
name: Android E2E (Genymotion Cloud)

on: [push, pull_request]

env:
GM_ANDROID_13 : 45017bce-d954-4b94-83d9-f9eac862f117
GM_ANDROID_12 : 49783077-9f15-4b94-99a4-c124a464fba3
GM_ANDROID_11 : 95016679-8f8d-4890-b026-e4ad889aadf1
GM_ANDROID_10 : 4c015ada-e64e-4f5d-a320-06cbf6e95648
GM_ANDROID_9 : 107d757e-463a-4a18-8667-b8dec6e4c87e
GM_ANDROID_8_1: 20ee73af-5c32-405c-8582-cd19ffd175c2
GM_ANDROID_8_0: 74ad0f8b-90f5-47c5-bc7a-9c05b04de4ca
GM_ANDROID_7_1: de849ff1-e051-4844-a92f-51b0181a6586
GM_ANDROID_7_0: b747b286-4729-46ef-9bfa-f05942b15588
GM_ANDROID_6 : 35d91457-dbfe-47ac-98fc-3271440753c4


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

strategy:
fail-fast: false
max-parallel: 2 # Trial & Pay as you Go - with 2 max simultaneous devices (see: https://docs.genymotion.com/saas/03_1_Pricing/#pay-as-you-go)
matrix:
android_api: [13, 12, 11, 10, 9, 8_1, 8_0]

env:
GMSAAS_INSTANCE_NAME: android-e2e-${{ github.run_number }}-${{ matrix.android_api }}

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 "$GM_ANDROID_${{ matrix.android_api }}" "${{ 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.android_api }}
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.android_api }}
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
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,33 @@
# Using-GitHub-Actions-to-run-your-Maestro-Flows


Nice to know:
- Samsung Remote Test Lab
- BrowserStack App Automate

TODO:
- [ ] Sauce Labs
- [ ] Firebase Test Lab
- [ ] AWS Device Farm
- [ ] Perfecto
- [ ] TestingBot
- [ ] CrossBrowserTesting
- [ ] LambdaTest
- [ ] TestingWhiz
- [ ] Kobiton
- [ ] Experitest
- [ ] HeadSpin
- [ ] pCloudy
- [ ] TestObject
- [ ] BitBar
- [ ] TestFairy
- [ ] Xamarin Test Cloud
- [ ] Testdroid
- [ ] SeeTest
- [ ] Ranorex
- [ ] Eggplant
- [ ] Telerik
- [ ] Katalon
- [ ] Ranorex
- [ ] TestComplete
- [ ] TestCraft
45 changes: 45 additions & 0 deletions run_android_e2e.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/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
echo "::group::Maestro hierarchy"
# ^^^^^^^^ see: https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#grouping-log-lines
$HOME/.maestro/bin/maestro hierarchy
echo "::endgroup::"


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

0 comments on commit e0e9fdd

Please sign in to comment.