Skip to content

2.0.0-alpha/MOB-9674-last-working #588

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 13 commits into
base: 2.0.0-alpha/MOB-9673-fix-unit-tests
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .codeclimate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ version: "2"
exclude_patterns:
- ".*/"
- "docs/"
- "integration-testing/"
- "**/node_modules/"
- "scripts/"
- "**/__mocks__/"
Expand Down
248 changes: 248 additions & 0 deletions .github/workflows/e2e-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,248 @@
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-14

steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Setup
uses: ./.github/actions/setup

- 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

- 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-14

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

- 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

- 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
38 changes: 0 additions & 38 deletions .github/workflows/integration-test.yml

This file was deleted.

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,5 @@ android/generated
.env
.xcode.env.local
coverage/
.watchman-*
artifacts/
2 changes: 0 additions & 2 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
SampleApp
integration-testing
jest.config.js
node_modules
package-lock.json
Expand Down
84 changes: 84 additions & 0 deletions example/.detoxrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/** @type {Detox.DetoxConfig} */
module.exports = {
testRunner: {
args: {
'$0': 'jest',
config: 'e2e/jest.config.js'
},
jest: {
setupTimeout: 120000
}
},
apps: {
'ios.debug': {
type: 'ios.app',
binaryPath: 'ios/build/Build/Products/Debug-iphonesimulator/ReactNativeSdkExample.app',
build: 'xcodebuild -workspace ios/ReactNativeSdkExample.xcworkspace -scheme ReactNativeSdkExample -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build'
},
'ios.release': {
type: 'ios.app',
binaryPath: 'ios/build/Build/Products/Release-iphonesimulator/ReactNativeSdkExample.app',
build: 'xcodebuild -workspace ios/ReactNativeSdkExample.xcworkspace -scheme ReactNativeSdkExample -configuration Release -sdk iphonesimulator -derivedDataPath ios/build'
},
'android.debug': {
type: 'android.apk',
binaryPath: 'android/app/build/outputs/apk/debug/app-debug.apk',
build: 'cd android && ./gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug',
reversePorts: [
8081
]
},
'android.release': {
type: 'android.apk',
binaryPath: 'android/app/build/outputs/apk/release/app-release.apk',
build: 'cd android && ./gradlew assembleRelease assembleAndroidTest -DtestBuildType=release'
}
},
devices: {
simulator: {
type: 'ios.simulator',
device: {
type: 'iPhone SE (3rd generation)'
// type: 'iPhone 11'
}
},
attached: {
type: 'android.attached',
device: {
adbName: '.*'
}
},
emulator: {
type: 'android.emulator',
device: {
avdName: 'Pixel_3a_API_34'
}
}
},
configurations: {
'ios.sim.debug': {
device: 'simulator',
app: 'ios.debug'
},
'ios.sim.release': {
device: 'simulator',
app: 'ios.release'
},
'android.att.debug': {
device: 'attached',
app: 'android.debug'
},
'android.att.release': {
device: 'attached',
app: 'android.release'
},
'android.emu.debug': {
device: 'emulator',
app: 'android.debug'
},
'android.emu.release': {
device: 'emulator',
app: 'android.release'
}
}
};
Loading
Loading