Skip to content

@kacperzolkiewski/add e2e ci maestro-runner #53

@kacperzolkiewski/add e2e ci maestro-runner

@kacperzolkiewski/add e2e ci maestro-runner #53

Workflow file for this run

name: E2E Tests
on:
push:
branches:
- main
pull_request:
branches:
- main
merge_group:
types:
- checks_requested
jobs:
changes:
runs-on: ubuntu-latest
outputs:
android: ${{ steps.filter.outputs.android }}
ios: ${{ steps.filter.outputs.ios }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Check file changes
uses: dorny/paths-filter@v3
id: filter
with:
filters: |
android:
- 'android/**'
- 'apps/example/android/**'
- 'apps/example/src/**'
- 'src/**'
- 'cpp/**'
- 'package.json'
- 'apps/example/package.json'
- 'react-native.config.js'
- 'babel.config.js'
- '.maestro/**'
ios:
- 'ios/**'
- 'apps/example/ios/**'
- 'apps/example/src/**'
- 'src/**'
- 'cpp/**'
- '*.podspec'
- 'package.json'
- 'apps/example/package.json'
- 'react-native.config.js'
- 'babel.config.js'
- '.maestro/**'
e2e-ios:
needs: [changes]
if: needs.changes.outputs.ios == 'true'
runs-on: macos-latest
timeout-minutes: 60
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup
uses: ./.github/actions/setup
- name: Set up Xcode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest-stable
- name: Restore cocoapods
id: cocoapods-cache
uses: actions/cache/restore@v4
with:
path: |
**/ios/Pods
key: ${{ runner.os }}-cocoapods-${{ hashFiles('apps/example/ios/Podfile.lock') }}
restore-keys: |
${{ runner.os }}-cocoapods-
- name: Install cocoapods
if: steps.cocoapods-cache.outputs.cache-hit != 'true'
run: |
cd apps/example/ios
pod install
env:
NO_FLIPPER: 1
- name: Cache cocoapods
if: steps.cocoapods-cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: |
**/ios/Pods
key: ${{ steps.cocoapods-cache.outputs.cache-key }}
- name: Restore Xcode DerivedData
uses: actions/cache/restore@v4
id: derived-data-cache
with:
path: ~/Library/Developer/Xcode/DerivedData
key: ${{ runner.os }}-derived-data-${{ hashFiles('ios/**', 'apps/example/ios/**', 'cpp/**', 'src/**') }}
restore-keys: |
${{ runner.os }}-derived-data-
- name: Install maestro-runner
run: |
curl -fsSL https://open.devicelab.dev/install/maestro-runner | bash
echo "$HOME/.maestro-runner/bin" >> $GITHUB_PATH
- name: Start Metro
run: yarn example start &
- name: Run E2E tests
run: yarn test:e2e:ios
- name: Cache Xcode DerivedData
if: steps.derived-data-cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: ~/Library/Developer/Xcode/DerivedData
key: ${{ steps.derived-data-cache.outputs.cache-primary-key }}
- name: Upload test artifacts
if: failure()
uses: actions/upload-artifact@v4
with:
name: e2e-ios-artifacts
path: |
reports/
.maestro/enrichedInput/screenshots/android/*_diff.png
.maestro/enrichedText/screenshots/android/*_diff.png
e2e-android:
needs: [changes]
if: needs.changes.outputs.android == 'true'
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup
uses: ./.github/actions/setup
- name: Enable KVM
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: Install JDK
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '17'
- name: Install maestro-runner
run: |
curl -fsSL https://open.devicelab.dev/install/maestro-runner | bash
echo "$HOME/.maestro-runner/bin" >> $GITHUB_PATH
- name: Cache Gradle
uses: actions/cache@v4
with:
path: |
~/.gradle/wrapper
~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('apps/example/android/gradle/wrapper/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: AVD cache
uses: actions/cache@v4
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-api-36-x86_64
- 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: 36
target: google_apis_playstore
arch: x86_64
profile: pixel_7
force-avd-creation: false
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim
disable-animations: false
enable-hw-keyboard: true
script: echo "Generated AVD snapshot for caching."
- name: Start Metro
run: yarn example start &
- name: Run E2E tests
id: e2e-tests
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 36
target: google_apis_playstore
arch: x86_64
profile: pixel_7
force-avd-creation: false
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim
disable-animations: true
disable-spellchecker: true
enable-hw-keyboard: true
script: EMULATOR_SERIAL=emulator-5554 .maestro/scripts/run-tests-ci-android.sh
env:
JAVA_OPTS: '-XX:MaxHeapSize=6g'
- name: Upload test artifacts
if: ${{ !cancelled() && (steps.e2e-tests.outcome == 'success' || steps.e2e-tests.outcome == 'failure') }}
uses: actions/upload-artifact@v4
with:
name: e2e-android-artifacts
if-no-files-found: warn
path: |
reports/
.maestro/enrichedInput/screenshots/android/*_diff.png
.maestro/enrichedText/screenshots/android/*_diff.png