|
| 1 | +name: E2E Tests |
| 2 | +on: [pull_request] |
| 3 | + |
| 4 | +jobs: |
| 5 | + find-test-files: |
| 6 | + name: Find Detox test files |
| 7 | + runs-on: macos-latest |
| 8 | + outputs: |
| 9 | + test-files: ${{ steps.set-test-files.outputs.test-files }} |
| 10 | + steps: |
| 11 | + - name: Checkout Code |
| 12 | + uses: actions/checkout@v4 |
| 13 | + |
| 14 | + - name: Find test files |
| 15 | + id: set-test-files |
| 16 | + run: | |
| 17 | + TEST_FILES=$(find example/e2e -name '*.test.js' | sed 's|example/e2e/||g' | jq -R -s -c 'split("\n")[:-1]') |
| 18 | + echo "test-files=$TEST_FILES" >> $GITHUB_OUTPUT |
| 19 | +
|
| 20 | + build-ios: |
| 21 | + name: iOS - Build app for Detox tests |
| 22 | + runs-on: macos-latest |
| 23 | + |
| 24 | + steps: |
| 25 | + - name: Checkout Code |
| 26 | + uses: actions/checkout@v4 |
| 27 | + with: |
| 28 | + fetch-depth: 1 |
| 29 | + |
| 30 | + - name: Setup |
| 31 | + uses: ./.github/actions/setup |
| 32 | + with: |
| 33 | + setup-config: ios |
| 34 | + |
| 35 | + - name: Setup Ruby (bundle) |
| 36 | + uses: ruby/setup-ruby@v1 |
| 37 | + with: |
| 38 | + ruby-version: 2.6.10 |
| 39 | + bundler-cache: true |
| 40 | + |
| 41 | + - name: Install ios-deploy, detox, react-native-cli |
| 42 | + run: npm install -g ios-deploy detox-cli react-native-cli |
| 43 | + |
| 44 | + - name: Install Applesimutils |
| 45 | + run: | |
| 46 | + brew tap wix/brew |
| 47 | + brew install applesimutils |
| 48 | +
|
| 49 | + - name: Example App Yarn install |
| 50 | + run: | |
| 51 | + cd example |
| 52 | + yarn install --frozen-lockfile |
| 53 | + cd .. |
| 54 | +
|
| 55 | + - uses: actions/cache@v4 |
| 56 | + id: cache |
| 57 | + with: |
| 58 | + path: | |
| 59 | + example/ios/Pods |
| 60 | + ~/Library/Caches/CocoaPods |
| 61 | + ~/.cocoapods |
| 62 | + key: ${{ runner.os }}-pods-${{ hashFiles('example/ios/Podfile.lock') }} |
| 63 | + restore-keys: | |
| 64 | + ${{ runner.os }}-pods- |
| 65 | +
|
| 66 | + - name: Pod install |
| 67 | + run: | |
| 68 | + cd example/ios |
| 69 | + pod install |
| 70 | + cd ../.. |
| 71 | +
|
| 72 | + - name: Build Detox |
| 73 | + run: yarn example detox:ios:build |
| 74 | + |
| 75 | + - name: Upload iOS app |
| 76 | + uses: actions/upload-artifact@v4 |
| 77 | + with: |
| 78 | + name: ios-app-artifact |
| 79 | + path: example/ios/build/Build/Products/Debug-iphonesimulator/ReactNativeSdkExample.app |
| 80 | + retention-days: 1 |
| 81 | + |
| 82 | + build-android: |
| 83 | + name: Android - Build app for Detox tests |
| 84 | + runs-on: ubuntu-latest |
| 85 | + |
| 86 | + steps: |
| 87 | + - name: Checkout Code |
| 88 | + uses: actions/checkout@v4 |
| 89 | + with: |
| 90 | + fetch-depth: 1 |
| 91 | + |
| 92 | + - name: Free Disk Space (Ubuntu) |
| 93 | + uses: jlumbroso/free-disk-space@main |
| 94 | + with: |
| 95 | + tool-cache: true |
| 96 | + android: false |
| 97 | + |
| 98 | + - name: Setup |
| 99 | + uses: ./.github/actions/setup |
| 100 | + with: |
| 101 | + setup-config: android |
| 102 | + |
| 103 | + - name: Setup Java |
| 104 | + uses: actions/setup-java@v4 |
| 105 | + with: |
| 106 | + distribution: zulu |
| 107 | + java-version: 17 |
| 108 | + |
| 109 | + - name: Setup Gradle |
| 110 | + uses: gradle/actions/setup-gradle@v3 |
| 111 | + with: |
| 112 | + gradle-version: wrapper |
| 113 | + cache-read-only: false |
| 114 | + |
| 115 | + - name: Example App Yarn install |
| 116 | + run: | |
| 117 | + cd example |
| 118 | + yarn install |
| 119 | + cd .. |
| 120 | +
|
| 121 | + - name: Build Detox |
| 122 | + run: yarn example detox:android:build |
| 123 | + |
| 124 | + - name: Upload Android app |
| 125 | + uses: actions/upload-artifact@v4 |
| 126 | + with: |
| 127 | + name: android-app-artifact |
| 128 | + path: example/android/app/build/outputs/apk |
| 129 | + retention-days: 1 |
| 130 | + |
| 131 | + run-ios-detox-tests: |
| 132 | + needs: [build-ios, find-test-files] |
| 133 | + name: iOS - Run Detox tests |
| 134 | + runs-on: macos-latest |
| 135 | + |
| 136 | + strategy: |
| 137 | + fail-fast: false |
| 138 | + matrix: |
| 139 | + test-file: ${{ fromJson(needs.find-test-files.outputs.test-files) }} |
| 140 | + |
| 141 | + steps: |
| 142 | + - name: Checkout Code |
| 143 | + uses: actions/checkout@v4 |
| 144 | + with: |
| 145 | + fetch-depth: 1 |
| 146 | + |
| 147 | + - name: Download iOS app |
| 148 | + uses: actions/download-artifact@v4 |
| 149 | + with: |
| 150 | + name: ios-app-artifact |
| 151 | + path: example/ios/build/Build/Products/Debug-iphonesimulator/ReactNativeSdkExample.app |
| 152 | + |
| 153 | + - name: Setup |
| 154 | + uses: ./.github/actions/setup |
| 155 | + with: |
| 156 | + setup-config: ios |
| 157 | + |
| 158 | + - name: Install ios-deploy, detox, react-native-cli |
| 159 | + run: npm install -g ios-deploy detox-cli react-native-cli |
| 160 | + |
| 161 | + - name: Install Applesimutils |
| 162 | + run: | |
| 163 | + brew tap wix/brew |
| 164 | + brew install applesimutils |
| 165 | +
|
| 166 | + - name: Rebuild Detox |
| 167 | + run: | |
| 168 | + cd example |
| 169 | + yarn detox rebuild-framework-cache |
| 170 | + cd .. |
| 171 | +
|
| 172 | + - name: Start Metro Server |
| 173 | + env: |
| 174 | + ITBL_API_KEY: ${{secrets.ITERABLE_API_KEY}} |
| 175 | + ITBL_ID: ${{secrets.ITBL_ID}} |
| 176 | + run: cd example && yarn detox:start & |
| 177 | + |
| 178 | + - name: Run Detox tests |
| 179 | + env: |
| 180 | + ITBL_API_KEY: ${{secrets.ITERABLE_API_KEY}} |
| 181 | + ITBL_ID: ${{secrets.ITBL_ID}} |
| 182 | + run: yarn detox:ios:test:ci -- ${{ matrix.test-file }} |
| 183 | + |
| 184 | + - name: Upload Test Artifact - GitHub Action |
| 185 | + if: failure() |
| 186 | + uses: actions/upload-artifact@v4 |
| 187 | + with: |
| 188 | + name: detox-ios-artifacts-${{ matrix.test-file }} |
| 189 | + path: example/artifacts |
| 190 | + retention-days: 1 |
| 191 | + |
| 192 | + run-android-detox-tests: |
| 193 | + needs: [build-android, find-test-files] |
| 194 | + name: Android - Run Detox tests |
| 195 | + runs-on: ubuntu-latest |
| 196 | + |
| 197 | + strategy: |
| 198 | + fail-fast: false |
| 199 | + matrix: |
| 200 | + test-file: ${{ fromJson(needs.find-test-files.outputs.test-files) }} |
| 201 | + |
| 202 | + steps: |
| 203 | + - name: Free Disk Space (Ubuntu) |
| 204 | + uses: jlumbroso/free-disk-space@main |
| 205 | + with: |
| 206 | + tool-cache: true |
| 207 | + android: false |
| 208 | + |
| 209 | + - name: Checkout Code |
| 210 | + uses: actions/checkout@v4 |
| 211 | + with: |
| 212 | + fetch-depth: 1 |
| 213 | + |
| 214 | + - name: Download Android app |
| 215 | + uses: actions/download-artifact@v4 |
| 216 | + with: |
| 217 | + name: android-app-artifact |
| 218 | + path: example/android/app/build/outputs/apk |
| 219 | + |
| 220 | + - name: Setup |
| 221 | + uses: ./.github/actions/setup |
| 222 | + with: |
| 223 | + setup-config: android |
| 224 | + |
| 225 | + - name: Start Metro Server |
| 226 | + env: |
| 227 | + ITBL_API_KEY: ${{secrets.ITERABLE_API_KEY}} |
| 228 | + ITBL_ID: ${{secrets.ITBL_ID}} |
| 229 | + run: yarn detox:start & |
| 230 | + |
| 231 | + - name: Enable KVM |
| 232 | + run: | |
| 233 | + echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules |
| 234 | + sudo udevadm control --reload-rules |
| 235 | + sudo udevadm trigger --name-match=kvm |
| 236 | +
|
| 237 | + - name: Run Detox tests |
| 238 | + uses: reactivecircus/android-emulator-runner@v2 |
| 239 | + env: |
| 240 | + ITBL_API_KEY: ${{secrets.ITERABLE_API_KEY}} |
| 241 | + ITBL_ID: ${{secrets.ITBL_ID}} |
| 242 | + with: |
| 243 | + api-level: 31 |
| 244 | + arch: x86_64 |
| 245 | + avd-name: Pixel_3a_API_34 |
| 246 | + force-avd-creation: false |
| 247 | + emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none -no-metrics |
| 248 | + disable-animations: false |
| 249 | + script: yarn detox:android:test:ci -- ${{ matrix.test-file }} |
| 250 | + |
| 251 | + - name: Upload Test Artifact - GitHub Action |
| 252 | + if: failure() |
| 253 | + uses: actions/upload-artifact@v4 |
| 254 | + with: |
| 255 | + name: detox-android-artifacts-${{ matrix.test-file }} |
| 256 | + path: example/artifacts |
| 257 | + retention-days: 1 |
0 commit comments