Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch from Detox to Maestro? #106

Open
karlhorky opened this issue Dec 8, 2022 · 2 comments
Open

Switch from Detox to Maestro? #106

karlhorky opened this issue Dec 8, 2022 · 2 comments

Comments

@karlhorky
Copy link
Member

karlhorky commented Dec 8, 2022

Alternative to #107

Detox causes timeouts and failed with code null test failures a lot, because of the test timeouts:

One alternative to Detox is Maestro, which seems to have some different retry capabilities:

This may allow us a way to avoid the problems with Detox.

@karlhorky
Copy link
Member Author

Looks like this may be a nice example of running Maestro locally (without Maestro Cloud):

# 🔗 Links:
# Source file: https://github.com/obytes/react-native-template-obytes/blob/master/.github/workflows/e2e-android-eas-build.yml
# End to end testing: https://starter.obytes.com/testing/end-to-end-testing/

# ✍️ Description:
# This workflow is used to run end-to-end tests for EAS build on Android.
# It uses Maestro Cloud to run tests on Android emulator.
# It downloads the APK from EAS build and trigger the tests on Maestro Cloud with the downloaded APK.

# 🚨 GTHUB SECRETS REQUIRED:
# MAESTRO_CLOUD_API_KEY: API key for Maestro Cloud. You can get it from https://cloud.mobile.dev/ci-integration/github-actions#add-your-api-key-secret

name: E2E Tests EAS Build Android (Maestro + Github Action)

on:
  workflow_dispatch:
    inputs:
      apk-url:
        type: string
        description: 'EAS APK URL'
        required: true
        default: ''

jobs:
  download-eas-apk:
    if: github.event_name != 'pull_request'  && github.event.inputs.apk-url != ''
    name: Download Test APK From EAS Url (wget)
    runs-on: ubuntu-latest

    steps:
      - name: 📦 Download EAS APK
        run: wget ${{ github.event.inputs.apk-url }} -O ./app-release.apk

      - name: Upload Test APK
        uses: actions/upload-artifact@v3
        with:
          name: test-apk
          path: ./app-release.apk

  test-android:
    name: E2E Tests EAS Build Android (Maestro + Github Action)
    needs: download-eas-apk
    runs-on: macOS-latest

    steps:
      - name: 📦 Checkout project repo
        uses: actions/checkout@v3
        with:
          fetch-depth: 0

      - name: 📦 Install Maestro
        run: npm run install-maestro ## we use npm because we dont need to install deps again

      - name: Download Test APK
        uses: actions/download-artifact@v3
        with:
          name: test-apk
          path: ${{ github.workspace }}

      - name: Gradle cache
        uses: gradle/gradle-build-action@v2

      - name: AVD cache
        uses: actions/cache@v3
        id: avd-cache
        with:
          path: |
            ~/.android/avd/*
            ~/.android/adb*
          key: avd-cache

      - name: create AVD and generate snapshot for caching
        if: steps.avd-cache.outputs.cache-hit != 'true'
        uses: reactivecircus/android-emulator-runner@v2
        with:
          api-level: 29
          force-avd-creation: false
          emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
          disable-animations: false
          cores: 2
          ram-size: 4096M
          profile: Nexus 6
          script: echo "Generated AVD snapshot for caching."

      - name: Run tests with Maestro
        uses: reactivecircus/android-emulator-runner@v2
        with:
          api-level: 29
          force-avd-creation: false
          emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
          disable-animations: false
          cores: 2
          ram-size: 4096M
          profile: Nexus 6
          script: |
            adb install "${{ github.workspace }}/app-release.apk"
            $HOME/.maestro/bin/maestro test .maestro/ --env=APP_ID=com.obytes.staging  --format junit

      - name: Upload artifacts
        if: always()
        uses: actions/upload-artifact@v3
        with:
          name: e2e-test-logs
          path: ~/.maestro/tests/**/*

      - name: Store tests result
        uses: actions/upload-artifact@v3
        with:
          name: e2e_android_report
          path: |
            report.xml

@karlhorky
Copy link
Member Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant