add CI/CD setup #64
This file contains hidden or 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 iOS E2E Tests | |
on: | |
pull_request: | |
branches: [ main, develop ] | |
push: | |
branches: [ main, develop ] | |
workflow_dispatch: | |
jobs: | |
test-ios: | |
name: e2e-ios-test | |
runs-on: macos-latest-xlarge | |
env: | |
DEVELOPER_DIR: /Applications/Xcode_15.0.app/Contents/Developer | |
MAESTRO_ENVIRONMENT: ios | |
NODE_ENV: production | |
WEATHER_API_KEY: ${{ secrets.WEATHER_API_KEY }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Setup Ruby | |
uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: '3.0' | |
bundler-cache: true | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '18' | |
cache: 'yarn' | |
- name: Install dependencies | |
run: | | |
yarn install | |
cd apps/mobile/ios && bundle install && cd ../../.. | |
- name: Cache CocoaPods | |
id: pods-cache | |
uses: actions/cache@v3 | |
with: | |
path: | | |
apps/mobile/ios/Pods | |
~/Library/Caches/CocoaPods | |
key: ${{ runner.os }}-pods-${{ hashFiles('apps/mobile/ios/Podfile.lock') }} | |
restore-keys: | | |
${{ runner.os }}-pods- | |
- name: Install CocoaPods | |
if: steps.pods-cache.outputs.cache-hit != 'true' | |
run: | | |
cd apps/mobile/ios | |
pod install | |
cd ../../.. | |
- name: Clean Xcode caches | |
run: | | |
cd apps/mobile/ios | |
rm -rf ~/Library/Developer/Xcode/ModuleCache.noindex/* | |
xcodebuild clean -workspace weatherApp.xcworkspace -scheme weatherApp | |
cd ../../.. | |
- name: Install Maestro CLI | |
run: | | |
curl -Ls "https://get.maestro.mobile.dev" | bash | |
brew tap facebook/fb | |
brew install facebook/fb/idb-companion | |
echo "${HOME}/.maestro/bin" >> $GITHUB_PATH | |
- name: Build iOS App | |
run: | | |
cd apps/mobile/ios | |
# First build to generate module maps | |
xcodebuild \ | |
-workspace weatherApp.xcworkspace \ | |
-scheme weatherApp \ | |
-configuration Release \ | |
-destination 'platform=iOS Simulator,name=iPhone 15' \ | |
build \ | |
COMPILER_INDEX_STORE_ENABLE=NO \ | |
| xcpretty | |
cd ../../.. | |
- name: Start Metro and Run App | |
run: | | |
cd apps/mobile | |
# Start metro in background | |
yarn start > metro.log 2>&1 & | |
METRO_PID=$! | |
echo "Waiting for Metro to be ready..." | |
while ! grep -q "Metro waiting on" metro.log; do | |
if ! kill -0 $METRO_PID 2>/dev/null; then | |
echo "Metro process died" | |
cat metro.log | |
exit 1 | |
fi | |
sleep 1 | |
done | |
# Run the app | |
npx react-native run-ios --mode=Release --simulator="iPhone 15" --verbose --no-packager | |
sleep 90 | |
cd ../.. | |
- name: Run Maestro tests | |
run: | | |
cd apps/mobile | |
export MAESTRO_DRIVER_STARTUP_TIMEOUT=240000 | |
export MAESTRO_CLI_NO_ANALYTICS=1 | |
$HOME/.maestro/bin/maestro test e2e/main-flow-ios.yaml | |
cd ../.. | |
- name: Upload logs and artifacts | |
if: always() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: test-artifacts | |
path: | | |
apps/mobile/metro.log | |
apps/mobile/.maestro/logs/** | |
apps/mobile/.maestro/tests/**/*.png | |
apps/mobile/ios/build |