-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add E2E workflow for iOS and Android with Detox test integration
- Loading branch information
Showing
1 changed file
with
257 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,257 @@ | ||
name: E2E Tests | ||
on: [pull_request] | ||
|
||
jobs: | ||
find-test-files: | ||
name: Find Detox test files | ||
runs-on: macos-latest | ||
outputs: | ||
test-files: ${{ steps.set-test-files.outputs.test-files }} | ||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Find test files | ||
id: set-test-files | ||
run: | | ||
TEST_FILES=$(find example/e2e -name '*.test.js' | sed 's|example/e2e/||g' | jq -R -s -c 'split("\n")[:-1]') | ||
echo "test-files=$TEST_FILES" >> $GITHUB_OUTPUT | ||
build-ios: | ||
name: iOS - Build app for Detox tests | ||
runs-on: macos-latest | ||
|
||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 1 | ||
|
||
- name: Setup | ||
uses: ./.github/actions/setup | ||
with: | ||
setup-config: ios | ||
|
||
- name: Setup Ruby (bundle) | ||
uses: ruby/setup-ruby@v1 | ||
with: | ||
ruby-version: 2.6.10 | ||
bundler-cache: true | ||
|
||
- name: Install ios-deploy, detox, react-native-cli | ||
run: npm install -g ios-deploy detox-cli react-native-cli | ||
|
||
- name: Install Applesimutils | ||
run: | | ||
brew tap wix/brew | ||
brew install applesimutils | ||
- name: Example App Yarn install | ||
run: | | ||
cd example | ||
yarn install --frozen-lockfile | ||
cd .. | ||
- uses: actions/cache@v4 | ||
id: cache | ||
with: | ||
path: | | ||
example/ios/Pods | ||
~/Library/Caches/CocoaPods | ||
~/.cocoapods | ||
key: ${{ runner.os }}-pods-${{ hashFiles('example/ios/Podfile.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-pods- | ||
- name: Pod install | ||
run: | | ||
cd example/ios | ||
pod install | ||
cd ../.. | ||
- name: Build Detox | ||
run: yarn example detox:ios:build | ||
|
||
- name: Upload iOS app | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: ios-app-artifact | ||
path: example/ios/build/Build/Products/Debug-iphonesimulator/ReactNativeSdkExample.app | ||
retention-days: 1 | ||
|
||
build-android: | ||
name: Android - Build app for Detox tests | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 1 | ||
|
||
- name: Free Disk Space (Ubuntu) | ||
uses: jlumbroso/free-disk-space@main | ||
with: | ||
tool-cache: true | ||
android: false | ||
|
||
- name: Setup | ||
uses: ./.github/actions/setup | ||
with: | ||
setup-config: android | ||
|
||
- name: Setup Java | ||
uses: actions/setup-java@v4 | ||
with: | ||
distribution: zulu | ||
java-version: 17 | ||
|
||
- name: Setup Gradle | ||
uses: gradle/actions/setup-gradle@v3 | ||
with: | ||
gradle-version: wrapper | ||
cache-read-only: false | ||
|
||
- name: Example App Yarn install | ||
run: | | ||
cd example | ||
yarn install | ||
cd .. | ||
- name: Build Detox | ||
run: yarn example detox:android:build | ||
|
||
- name: Upload Android app | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: android-app-artifact | ||
path: example/android/app/build/outputs/apk | ||
retention-days: 1 | ||
|
||
run-ios-detox-tests: | ||
needs: [build-ios, find-test-files] | ||
name: iOS - Run Detox tests | ||
runs-on: macos-latest | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
test-file: ${{ fromJson(needs.find-test-files.outputs.test-files) }} | ||
|
||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 1 | ||
|
||
- name: Download iOS app | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: ios-app-artifact | ||
path: example/ios/build/Build/Products/Debug-iphonesimulator/ReactNativeSdkExample.app | ||
|
||
- name: Setup | ||
uses: ./.github/actions/setup | ||
with: | ||
setup-config: ios | ||
|
||
- name: Install ios-deploy, detox, react-native-cli | ||
run: npm install -g ios-deploy detox-cli react-native-cli | ||
|
||
- name: Install Applesimutils | ||
run: | | ||
brew tap wix/brew | ||
brew install applesimutils | ||
- name: Rebuild Detox | ||
run: | | ||
cd example | ||
yarn detox rebuild-framework-cache | ||
cd .. | ||
- name: Start Metro Server | ||
env: | ||
ITBL_API_KEY: ${{secrets.ITERABLE_API_KEY}} | ||
ITBL_ID: ${{secrets.ITBL_ID}} | ||
run: cd example && yarn detox:start & | ||
|
||
- name: Run Detox tests | ||
env: | ||
ITBL_API_KEY: ${{secrets.ITERABLE_API_KEY}} | ||
ITBL_ID: ${{secrets.ITBL_ID}} | ||
run: yarn detox:ios:test:ci -- ${{ matrix.test-file }} | ||
|
||
- name: Upload Test Artifact - GitHub Action | ||
if: failure() | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: detox-ios-artifacts-${{ matrix.test-file }} | ||
path: example/artifacts | ||
retention-days: 1 | ||
|
||
run-android-detox-tests: | ||
needs: [build-android, find-test-files] | ||
name: Android - Run Detox tests | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
test-file: ${{ fromJson(needs.find-test-files.outputs.test-files) }} | ||
|
||
steps: | ||
- name: Free Disk Space (Ubuntu) | ||
uses: jlumbroso/free-disk-space@main | ||
with: | ||
tool-cache: true | ||
android: false | ||
|
||
- name: Checkout Code | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 1 | ||
|
||
- name: Download Android app | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: android-app-artifact | ||
path: example/android/app/build/outputs/apk | ||
|
||
- name: Setup | ||
uses: ./.github/actions/setup | ||
with: | ||
setup-config: android | ||
|
||
- name: Start Metro Server | ||
env: | ||
ITBL_API_KEY: ${{secrets.ITERABLE_API_KEY}} | ||
ITBL_ID: ${{secrets.ITBL_ID}} | ||
run: yarn detox:start & | ||
|
||
- name: Enable KVM | ||
run: | | ||
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules | ||
sudo udevadm control --reload-rules | ||
sudo udevadm trigger --name-match=kvm | ||
- name: Run Detox tests | ||
uses: reactivecircus/android-emulator-runner@v2 | ||
env: | ||
ITBL_API_KEY: ${{secrets.ITERABLE_API_KEY}} | ||
ITBL_ID: ${{secrets.ITBL_ID}} | ||
with: | ||
api-level: 31 | ||
arch: x86_64 | ||
avd-name: Pixel_3a_API_34 | ||
force-avd-creation: false | ||
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none -no-metrics | ||
disable-animations: false | ||
script: yarn detox:android:test:ci -- ${{ matrix.test-file }} | ||
|
||
- name: Upload Test Artifact - GitHub Action | ||
if: failure() | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: detox-android-artifacts-${{ matrix.test-file }} | ||
path: example/artifacts | ||
retention-days: 1 |