|
| 1 | +name: Mobile E2E Tests |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + paths: |
| 7 | + - 'mobile/**' |
| 8 | + pull_request: |
| 9 | + branches: [main] |
| 10 | + paths: |
| 11 | + - 'mobile/**' |
| 12 | + workflow_dispatch: |
| 13 | + # Weekly run to catch regressions |
| 14 | + schedule: |
| 15 | + - cron: '0 9 * * 1' # Monday 9am UTC |
| 16 | + |
| 17 | +jobs: |
| 18 | + maestro-ios: |
| 19 | + runs-on: macos-14 |
| 20 | + timeout-minutes: 45 |
| 21 | + |
| 22 | + steps: |
| 23 | + - uses: actions/checkout@v4 |
| 24 | + |
| 25 | + - name: Set up Bun |
| 26 | + uses: oven-sh/setup-bun@v2 |
| 27 | + with: |
| 28 | + bun-version: latest |
| 29 | + |
| 30 | + - name: Cache bun dependencies |
| 31 | + uses: actions/cache@v4 |
| 32 | + with: |
| 33 | + path: | |
| 34 | + ~/.bun/install/cache |
| 35 | + mobile/node_modules |
| 36 | + key: ${{ runner.os }}-bun-mobile-${{ hashFiles('mobile/bun.lock') }} |
| 37 | + restore-keys: | |
| 38 | + ${{ runner.os }}-bun-mobile- |
| 39 | +
|
| 40 | + - name: Install dependencies |
| 41 | + working-directory: mobile |
| 42 | + run: bun install |
| 43 | + |
| 44 | + - name: Select Xcode version |
| 45 | + run: | |
| 46 | + # Try Xcode 16.2 first, fall back to 16.1 if not available |
| 47 | + if [ -d "/Applications/Xcode_16.2.app" ]; then |
| 48 | + sudo xcode-select -s /Applications/Xcode_16.2.app |
| 49 | + elif [ -d "/Applications/Xcode_16.1.app" ]; then |
| 50 | + sudo xcode-select -s /Applications/Xcode_16.1.app |
| 51 | + elif [ -d "/Applications/Xcode_16.app" ]; then |
| 52 | + sudo xcode-select -s /Applications/Xcode_16.app |
| 53 | + else |
| 54 | + echo "Available Xcode versions:" |
| 55 | + ls -d /Applications/Xcode*.app 2>/dev/null || echo "No Xcode found" |
| 56 | + exit 1 |
| 57 | + fi |
| 58 | + xcodebuild -version |
| 59 | +
|
| 60 | + - name: Generate iOS native code |
| 61 | + working-directory: mobile |
| 62 | + run: bunx expo prebuild --platform ios --clean |
| 63 | + |
| 64 | + - name: Cache CocoaPods |
| 65 | + uses: actions/cache@v4 |
| 66 | + with: |
| 67 | + path: mobile/ios/Pods |
| 68 | + key: ${{ runner.os }}-pods-${{ hashFiles('mobile/ios/Podfile.lock') }} |
| 69 | + restore-keys: | |
| 70 | + ${{ runner.os }}-pods- |
| 71 | +
|
| 72 | + - name: Install CocoaPods dependencies |
| 73 | + working-directory: mobile/ios |
| 74 | + run: pod install |
| 75 | + |
| 76 | + - name: List available simulators |
| 77 | + run: xcrun simctl list devices available |
| 78 | + |
| 79 | + - name: Boot iOS Simulator |
| 80 | + run: | |
| 81 | + DEVICE_ID=$(xcrun simctl list devices available | grep "iPhone 16" | head -1 | grep -oE '[A-F0-9-]{36}') |
| 82 | + if [ -z "$DEVICE_ID" ]; then |
| 83 | + DEVICE_ID=$(xcrun simctl list devices available | grep "iPhone 15" | head -1 | grep -oE '[A-F0-9-]{36}') |
| 84 | + fi |
| 85 | + if [ -z "$DEVICE_ID" ]; then |
| 86 | + DEVICE_ID=$(xcrun simctl list devices available | grep "iPhone" | head -1 | grep -oE '[A-F0-9-]{36}') |
| 87 | + fi |
| 88 | + echo "DEVICE_ID=$DEVICE_ID" >> $GITHUB_ENV |
| 89 | + xcrun simctl boot "$DEVICE_ID" || true |
| 90 | + xcrun simctl bootstatus "$DEVICE_ID" -b |
| 91 | +
|
| 92 | + - name: Cache Xcode build |
| 93 | + uses: actions/cache@v4 |
| 94 | + with: |
| 95 | + path: mobile/ios/build |
| 96 | + key: ${{ runner.os }}-xcode-${{ hashFiles('mobile/ios/Podfile.lock', 'mobile/src/**/*.ts', 'mobile/src/**/*.tsx') }} |
| 97 | + restore-keys: | |
| 98 | + ${{ runner.os }}-xcode- |
| 99 | +
|
| 100 | + - name: Build iOS app for simulator |
| 101 | + working-directory: mobile/ios |
| 102 | + run: | |
| 103 | + xcodebuild -workspace Perry.xcworkspace \ |
| 104 | + -scheme Perry \ |
| 105 | + -configuration Release \ |
| 106 | + -sdk iphonesimulator \ |
| 107 | + -destination "id=${{ env.DEVICE_ID }}" \ |
| 108 | + -derivedDataPath build \ |
| 109 | + build |
| 110 | +
|
| 111 | + - name: Install app on simulator |
| 112 | + run: | |
| 113 | + APP_PATH=$(find mobile/ios/build -name "*.app" -type d | head -1) |
| 114 | + xcrun simctl install "${{ env.DEVICE_ID }}" "$APP_PATH" |
| 115 | +
|
| 116 | + - name: Install Maestro |
| 117 | + run: | |
| 118 | + curl -Ls "https://get.maestro.mobile.dev" | bash |
| 119 | + echo "$HOME/.maestro/bin" >> $GITHUB_PATH |
| 120 | +
|
| 121 | + - name: Launch app and take debug screenshot |
| 122 | + run: | |
| 123 | + export PATH="$HOME/.maestro/bin:$PATH" |
| 124 | + xcrun simctl launch "${{ env.DEVICE_ID }}" com.gricha.perry || true |
| 125 | + sleep 5 |
| 126 | + xcrun simctl io "${{ env.DEVICE_ID }}" screenshot /tmp/app-launch-debug.png || true |
| 127 | +
|
| 128 | + - name: Run Maestro tests |
| 129 | + working-directory: mobile |
| 130 | + run: | |
| 131 | + export PATH="$HOME/.maestro/bin:$PATH" |
| 132 | + maestro test .maestro/flows/ --format junit --output maestro-report.xml |
| 133 | + env: |
| 134 | + MAESTRO_DRIVER_STARTUP_TIMEOUT: 120000 |
| 135 | + |
| 136 | + - name: Upload debug screenshot |
| 137 | + uses: actions/upload-artifact@v4 |
| 138 | + if: failure() |
| 139 | + with: |
| 140 | + name: debug-screenshot |
| 141 | + path: /tmp/app-launch-debug.png |
| 142 | + retention-days: 7 |
| 143 | + |
| 144 | + - name: Upload Maestro report |
| 145 | + uses: actions/upload-artifact@v4 |
| 146 | + if: always() |
| 147 | + with: |
| 148 | + name: maestro-report |
| 149 | + path: mobile/maestro-report.xml |
| 150 | + retention-days: 7 |
| 151 | + |
| 152 | + - name: Upload Maestro screenshots |
| 153 | + uses: actions/upload-artifact@v4 |
| 154 | + if: failure() |
| 155 | + with: |
| 156 | + name: maestro-screenshots |
| 157 | + path: ~/.maestro/tests/ |
| 158 | + retention-days: 7 |
0 commit comments