Skip to content

feat: add Maestro E2E tests #4

feat: add Maestro E2E tests

feat: add Maestro E2E tests #4

Workflow file for this run

name: E2E
on:
workflow_dispatch:
pull_request:
branches:
- main
push:
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
android:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- name: Setup
uses: ./.github/actions/setup
- name: Install JDK
uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1
with:
distribution: 'zulu'
java-version: '17'
- name: Finalize Android SDK
run: |
/bin/bash -c "yes | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --licenses > /dev/null"
- name: Cache Gradle
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
with:
path: |
~/.gradle/wrapper
~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('example/bare/android/gradle/wrapper/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Build example for Android
env:
JAVA_OPTS: "-XX:MaxHeapSize=6g"
run: |
cd example/bare
npx react-native build-android --mode release --extra-params "--no-daemon --console=plain -PreactNativeArchitectures=x86_64"
- name: Install Maestro
run: |
curl -Ls "https://get.maestro.mobile.dev" | bash
echo "$HOME/.maestro/bin" >> $GITHUB_PATH
- name: Enable KVM
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
- name: Run Maestro tests
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 31
arch: x86_64
script: |
adb install example/bare/android/app/build/outputs/apk/release/app-release.apk
maestro test .maestro/ --format junit --output report.xml
- name: Upload test report
if: always()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: e2e-android-report
path: report.xml
ios:
runs-on: macos-latest
env:
XCODE_VERSION: latest-stable
RCT_USE_RN_DEP: 1
RCT_USE_PREBUILT_RNCORE: 1
steps:
- name: Checkout
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- name: Setup
uses: ./.github/actions/setup
- name: Use appropriate Xcode version
uses: maxim-lobanov/setup-xcode@60606e260d2fc5762a71e64e74b2174e8ea3c8bd # v1.6.0
with:
xcode-version: ${{ env.XCODE_VERSION }}
- name: Cache iOS build
id: ios-cache
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
with:
path: |
~/Library/Caches/ccache
~/Library/Developer/Xcode/DerivedData
example/bare/ios/Pods
key: ${{ runner.os }}-ios-${{ hashFiles('example/bare/ios/Podfile.lock') }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-ios-${{ hashFiles('example/bare/ios/Podfile.lock') }}-
${{ runner.os }}-ios-
- name: Install ccache
run: brew install ccache
- name: Install cocoapods
if: steps.ios-cache.outputs.cache-hit != 'true'
run: |
cd example/bare
bundle install
bundle exec pod install --project-directory=ios
- name: Build example for iOS
run: |
cd example/bare
npx react-native build-ios --mode Release
- name: Install Maestro
run: |
curl -Ls "https://get.maestro.mobile.dev" | bash
echo "$HOME/.maestro/bin" >> $GITHUB_PATH
- name: Boot iOS Simulator
run: |
DEVICE=$(xcrun simctl list devices available -j | jq -r '[.devices[] | .[] | select(.name | contains("iPhone"))][0].udid')
xcrun simctl boot "$DEVICE"
- name: Install app on Simulator
run: |
APP_PATH=$(find ~/Library/Developer/Xcode/DerivedData -name "TrueSheetExample.app" -path "*/Release-iphonesimulator/*" | head -1)
xcrun simctl install booted "$APP_PATH"
- name: Run Maestro tests
run: maestro test .maestro/ --format junit --output report.xml
- name: Upload test report
if: always()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: e2e-ios-report
path: report.xml