Skip to content

add CI/CD setup

add CI/CD setup #8

Workflow file for this run

name: React Native E2E Tests
on:
pull_request:
branches: [ main, develop ]
push:
branches: [ main, develop ]
workflow_dispatch:
jobs:
android-e2e-tests:
name: Android E2E Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '17'
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.0'
bundler-cache: false
- name: Update Gemfile.lock and install dependencies
run: |
bundle update --bundler
bundle install
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'yarn'
- name: Install dependencies
run: |
yarn install --frozen-lockfile
cd android && bundle install
- name: Create Fastfile if not exists
run: |
mkdir -p android/fastlane
echo '
default_platform(:android)
platform :android do
desc "Build and install the app"
lane :build_and_install do
gradle(task: "clean assembleDebug")
gradle(task: "installDebug")
end
end
' > android/fastlane/Fastfile
- name: Create .env.ci file
run: |
echo "FASTLANE_DISABLE_INTERACTIVE=1" > android/fastlane/.env.ci
- name: Check Fastlane files
run: |
ls -la android/fastlane
cat android/fastlane/Fastfile
- name: Build and run Android app
uses: reactivecircus/android-emulator-runner@v2
env:
FASTLANE_DISABLE_COLORS: 1
FASTLANE_SKIP_UPDATE_CHECK: 1
LC_ALL: en_US.UTF-8
LANG: en_US.UTF-8
with:
api-level: 29
arch: x86_64
profile: Nexus 6
script: |
cd android
echo "Current directory: $(pwd)"
echo "Contents of current directory:"
ls -la
bundle exec fastlane --verbose android build_and_install --env ci
cd ..
echo "Installing Maestro..."
curl -Ls "https://get.maestro.mobile.dev" | bash
export PATH="$PATH":"$HOME/.maestro/bin"
echo "Running Maestro tests..."
maestro --verbose test -e APP_ID=com.weatherApp.callstack e2e/main-flow-android.yaml
- name: Upload Maestro logs
if: always()
uses: actions/upload-artifact@v4
with:
name: maestro-android-logs
path: ~/.maestro/logs
ios-e2e-tests:
name: iOS E2E Tests
runs-on: macos-13
env:
DEVELOPER_DIR: /Applications/Xcode_15.0.app/Contents/Developer
steps:
- uses: actions/checkout@v4
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.0'
bundler-cache: false
- name: Update Gemfile.lock and install dependencies
run: |
bundle update --bundler
bundle install
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'yarn'
- name: Install dependencies
run: |
yarn install --frozen-lockfile
cd ios && bundle install
- name: Create Fastfile if not exists
run: |
mkdir -p ios/fastlane
echo '
default_platform(:ios)
platform :ios do
desc "Build and test the app"
lane :build_and_test do
cocoapods
gym(
scheme: "weatherApp",
workspace: "weatherApp.xcworkspace",
configuration: "Debug",
destination: "generic/platform=iOS Simulator",
output_directory: "./build",
output_name: "weatherApp.app",
skip_package_ipa: true
)
end
end
' > ios/fastlane/Fastfile
- name: Create .env.ci file
run: |
echo "FASTLANE_DISABLE_INTERACTIVE=1" > ios/fastlane/.env.ci
- name: Check Fastlane files
run: |
ls -la ios/fastlane
cat ios/fastlane/Fastfile
- name: Install CocoaPods
run: |
cd ios
pod install --repo-update
- name: Build and run iOS app
env:
FASTLANE_DISABLE_COLORS: 1
FASTLANE_SKIP_UPDATE_CHECK: 1
run: |
cd ios
echo "Current directory: $(pwd)"
echo "Contents of current directory:"
ls -la
bundle exec fastlane --verbose ios build_and_test --env ci
- name: List build artifacts
run: |
ls -R ios/build
- name: Run Maestro tests
run: |
echo "Installing Maestro..."
curl -Ls "https://get.maestro.mobile.dev" | bash
echo "$HOME/.maestro/bin" >> $GITHUB_PATH
export PATH="$PATH:$HOME/.maestro/bin"
echo "Running Maestro tests..."
maestro --verbose test -e APP_ID=com.weatherApp.callstack e2e/main-flow-ios.yaml
- name: Upload Maestro logs
if: always()
uses: actions/upload-artifact@v4
with:
name: maestro-ios-logs
path: |
~/.maestro/logs
ios/build