add CI/CD setup #21
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: React Native Maestro Tests | |
on: | |
push: | |
branches: [ main, develop ] | |
pull_request: | |
branches: [ main, develop ] | |
workflow_dispatch: | |
jobs: | |
test-android-emulator: | |
name: Test Android Emulator Setup | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '18' | |
cache: 'yarn' | |
- name: Install dependencies | |
run: yarn install --frozen-lockfile | |
- name: Setup Java | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'zulu' | |
java-version: '17' | |
- name: Setup Android SDK and emulator | |
uses: reactivecircus/android-emulator-runner@v2 | |
with: | |
api-level: 29 | |
arch: x86_64 | |
profile: Nexus 6 | |
script: | | |
echo "Checking Android SDK installation..." | |
ls -l $ANDROID_HOME | |
echo "ANDROID_HOME is set to: $ANDROID_HOME" | |
echo "Updating SDK tools..." | |
yes | sdkmanager --update | |
echo "Installing required SDK components..." | |
yes | sdkmanager "platform-tools" "platforms;android-29" "system-images;android-29;default;x86_64" | |
echo "Configuring emulator..." | |
$ANDROID_HOME/cmdline-tools/latest/bin/avdmanager create avd -n test_avd -k "system-images;android-29;default;x86_64" --force | |
echo "Starting emulator..." | |
$ANDROID_HOME/emulator/emulator -avd test_avd -no-audio -no-boot-anim & | |
$ANDROID_HOME/platform-tools/adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1; done' | |
echo "Emulator started." | |
echo "Running diagnostics..." | |
adb devices | |
echo "Emulator CPU architecture:" | |
adb shell getprop ro.product.cpu.abi | |
echo "Emulator API level:" | |
adb shell getprop ro.build.version.sdk | |
echo "Installing Maestro..." | |
curl -Ls "https://get.maestro.mobile.dev" | bash | |
export PATH="$PATH":"$HOME/.maestro/bin" | |
echo "Building and starting React Native app..." | |
yarn android | |
echo "Waiting for app to start..." | |
sleep 60 # Adjust this time based on how long your app typically takes to start | |
echo "Running Maestro tests..." | |
maestro --verbose test e2e/main-flow-android.yaml | |
- name: Upload Maestro logs | |
if: always() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: maestro-android-logs | |
path: | | |
~/.maestro/logs | |
./e2e/main-flow-android.yaml | |
test-ios-simulator: | |
name: Test iOS Simulator Setup | |
runs-on: macos-13 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '18' | |
cache: 'yarn' | |
- name: Install dependencies | |
run: yarn install --frozen-lockfile | |
- name: Setup Xcode | |
uses: maxim-lobanov/setup-xcode@v1 | |
with: | |
xcode-version: latest-stable | |
- name: Install iOS dependencies | |
run: | | |
cd ios | |
pod install | |
- name: Create and boot iOS simulator | |
run: | | |
echo "Available iOS runtimes:" | |
xcrun simctl list runtimes | |
UDID=$(xcrun simctl create "iPhone 14" com.apple.CoreSimulator.SimDeviceType.iPhone-14 com.apple.CoreSimulator.SimRuntime.iOS-17-0) | |
xcrun simctl boot $UDID | |
# Wait for simulator to be ready | |
MAX_RETRY=30 | |
COUNT=0 | |
while [ $COUNT -lt $MAX_RETRY ]; do | |
xcrun simctl list devices | grep "(Booted)" && break | |
echo "Waiting for simulator to boot..." | |
sleep 10 | |
COUNT=$((COUNT+1)) | |
done | |
if [ $COUNT -eq $MAX_RETRY ]; then | |
echo "Simulator failed to boot in time" | |
exit 1 | |
fi | |
echo "Simulator is ready" | |
- name: Build and run React Native app | |
run: | | |
yarn ios | |
echo "Waiting for app to start..." | |
sleep 60 # Adjust this time based on how long your app typically takes to start | |
- name: Install and run Maestro | |
run: | | |
set -x | |
curl -Ls "https://get.maestro.mobile.dev" | bash | |
export PATH="$PATH":"$HOME/.maestro/bin" | |
echo "Running diagnostics..." | |
xcrun simctl list | |
echo "Running Maestro tests..." | |
maestro --verbose test e2e/main-flow-ios.yaml | |
- name: Upload Maestro logs | |
if: always() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: maestro-ios-logs | |
path: | | |
~/.maestro/logs | |
./e2e/main-flow-ios.yaml |