-
-
Notifications
You must be signed in to change notification settings - Fork 344
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
internal(sample-rn): Add Detox for integration/e2e tests of the rn sample (#4535) #4614
Closed
+849
−18
Closed
Changes from 2 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
ab5cdfe
internal(sample-rn): Add Detox for integration/e2e tests of the rn sa…
krystofwoldrich 05dac0e
removed unused build config property
krystofwoldrich ec20ae4
fix(appStart): Attach App Start spans to the first created not the fi…
krystofwoldrich c24a5f3
fix(appStart): Attach App Start spans to the first created not the fi…
krystofwoldrich cdec5f5
Merge branch 'fix-attach-app-start-to-the-first-started-root-span' in…
krystofwoldrich daab748
add jest driven maestro tests
krystofwoldrich 158bcac
Add test scripts
krystofwoldrich File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
|
@@ -14,6 +14,12 @@ concurrency: | |
env: | ||
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} | ||
RN_SENTRY_POD_NAME: RNSentry | ||
IOS_APP_ARCHIVE_PATH: sentry-react-native-sample.app.zip | ||
ANDROID_APP_ARCHIVE_PATH: sentry-react-native-sample.apk.zip | ||
REACT_NATIVE_SAMPLE_PATH: samples/react-native | ||
IOS_DEVICE: 'iPhone 16' | ||
IOS_VERSION: '18.1' | ||
ANDROID_API_LEVEL: '30' | ||
|
||
jobs: | ||
diff_check: | ||
|
@@ -66,7 +72,7 @@ jobs: | |
- uses: ruby/setup-ruby@v1 | ||
if: ${{ matrix.platform == 'ios' || matrix.platform == 'macos' }} | ||
with: | ||
working-directory: ${{ matrix.platform == 'ios' && ' samples/react-native' || ' samples/react-native-macos' }} | ||
working-directory: ${{ matrix.platform == 'ios' && env.REACT_NATIVE_SAMPLE_PATH || ' samples/react-native-macos' }} | ||
ruby-version: '3.3.0' # based on what is used in the sample | ||
bundler-cache: true # runs 'bundle install' and caches installed gems automatically | ||
cache-version: 1 # cache the installed gems | ||
|
@@ -106,7 +112,7 @@ jobs: | |
- name: Build Android App | ||
if: ${{ matrix.platform == 'android' }} | ||
working-directory: samples/react-native/android | ||
working-directory: ${{ env.REACT_NATIVE_SAMPLE_PATH }}/android | ||
run: | | ||
if [[ ${{ matrix.rn-architecture }} == 'new' ]]; then | ||
perl -i -pe's/newArchEnabled=false/newArchEnabled=true/g' gradle.properties | ||
|
@@ -119,11 +125,14 @@ jobs: | |
fi | ||
[[ "${{ matrix.build-type }}" == "production" ]] && CONFIG='Release' || CONFIG='Debug' | ||
echo "Building $CONFIG" | ||
./gradlew ":app:assemble$CONFIG" -PreactNativeArchitectures=x86 | ||
[[ "${{ matrix.build-type }}" == "production" ]] && TEST_TYPE='release' || TEST_TYPE='debug' | ||
echo "Building $TEST_TYPE" | ||
./gradlew ":app:assemble$CONFIG" app:assembleAndroidTest -DtestBuildType=$TEST_TYPE -PreactNativeArchitectures=x86 | ||
- name: Build iOS App | ||
if: ${{ matrix.platform == 'ios' }} | ||
working-directory: samples/react-native/ios | ||
working-directory: ${{ env.REACT_NATIVE_SAMPLE_PATH }}/ios | ||
run: | | ||
[[ "${{ matrix.build-type }}" == "production" ]] && CONFIG='Release' || CONFIG='Debug' | ||
echo "Building $CONFIG" | ||
|
@@ -160,9 +169,162 @@ jobs: | |
| tee xcodebuild.log \ | ||
| xcbeautify --quieter --is-ci --disable-colored-output | ||
- name: Archive iOS App | ||
if: ${{ matrix.platform == 'ios' && matrix.rn-architecture == 'new' && matrix.build-type == 'production' && matrix.ios-use-frameworks == 'no-frameworks' }} | ||
run: | | ||
cd ${{ env.REACT_NATIVE_SAMPLE_PATH }}/ios/DerivedData/Build/Products/Release-iphonesimulator | ||
zip -r \ | ||
${{ github.workspace }}/${{ env.IOS_APP_ARCHIVE_PATH }} \ | ||
sentryreactnativesample.app | ||
- name: Archive Android App | ||
if: ${{ matrix.platform == 'android' && matrix.rn-architecture == 'new' && matrix.build-type == 'production' }} | ||
run: | | ||
mv ${{ env.REACT_NATIVE_SAMPLE_PATH }}/android/app/build/outputs/apk/release/app-release.apk app.apk | ||
mv ${{ env.REACT_NATIVE_SAMPLE_PATH }}/android/app/build/outputs/apk/androidTest/release/app-release-androidTest.apk app-androidTest.apk | ||
zip -j \ | ||
${{ env.ANDROID_APP_ARCHIVE_PATH }} \ | ||
app.apk \ | ||
app-androidTest.apk | ||
- name: Upload iOS APP | ||
if: ${{ matrix.platform == 'ios' && matrix.rn-architecture == 'new' && matrix.build-type == 'production' && matrix.ios-use-frameworks == 'no-frameworks' }} | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: sample-rn-${{ matrix.rn-architecture }}-${{ matrix.build-type }}-${{ matrix.ios-use-frameworks}}-${{ matrix.platform }} | ||
path: ${{ env.IOS_APP_ARCHIVE_PATH }} | ||
retention-days: 1 | ||
|
||
- name: Upload Android APK | ||
if: ${{ matrix.platform == 'android' && matrix.rn-architecture == 'new' && matrix.build-type == 'production' }} | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: sample-rn-${{ matrix.rn-architecture }}-${{ matrix.build-type }}-${{ matrix.platform }} | ||
path: ${{ env.ANDROID_APP_ARCHIVE_PATH }} | ||
retention-days: 1 | ||
|
||
- name: Upload logs | ||
if: ${{ always() }} | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: build-sample-${{ matrix.rn-architecture }}-${{ matrix.platform }}-${{ matrix.build-type }}-${{ matrix.ios-use-frameworks}}-logs | ||
path: samples/react-native/${{ matrix.platform }}/*.log | ||
path: ${{ env.REACT_NATIVE_SAMPLE_PATH }}/${{ matrix.platform }}/*.log | ||
|
||
test: | ||
name: Test ${{ matrix.platform }} ${{ matrix.build-type }} | ||
runs-on: ${{ matrix.runs-on }} | ||
needs: [diff_check, build] | ||
if: ${{ needs.diff_check.outputs.skip_ci != 'true' }} | ||
strategy: | ||
# we want that the matrix keeps running, default is to cancel them if it fails. | ||
fail-fast: false | ||
matrix: | ||
include: | ||
- platform: ios | ||
runs-on: macos-15 | ||
rn-architecture: 'new' | ||
ios-use-frameworks: 'no-frameworks' | ||
build-type: 'production' | ||
|
||
- platform: android | ||
runs-on: ubuntu-latest | ||
rn-architecture: 'new' | ||
build-type: 'production' | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Download iOS App Archive | ||
if: ${{ matrix.platform == 'ios' }} | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: sample-rn-${{ matrix.rn-architecture }}-${{ matrix.build-type }}-${{ matrix.ios-use-frameworks}}-${{ matrix.platform }} | ||
path: ${{ env.REACT_NATIVE_SAMPLE_PATH }} | ||
|
||
- name: Download Android APK | ||
if: ${{ matrix.platform == 'android' }} | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: sample-rn-${{ matrix.rn-architecture }}-${{ matrix.build-type }}-${{ matrix.platform }} | ||
path: ${{ env.REACT_NATIVE_SAMPLE_PATH }} | ||
|
||
- name: Unzip iOS App Archive | ||
if: ${{ matrix.platform == 'ios' }} | ||
working-directory: ${{ env.REACT_NATIVE_SAMPLE_PATH }} | ||
run: unzip ${{ env.IOS_APP_ARCHIVE_PATH }} | ||
|
||
- name: Unzip Android APK | ||
if: ${{ matrix.platform == 'android' }} | ||
working-directory: ${{ env.REACT_NATIVE_SAMPLE_PATH }} | ||
run: unzip ${{ env.ANDROID_APP_ARCHIVE_PATH }} | ||
|
||
- name: Enable Corepack | ||
run: | | ||
npm install -g [email protected] | ||
corepack enable | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 18 | ||
cache: 'yarn' | ||
cache-dependency-path: yarn.lock | ||
|
||
- name: Install JS Dependencies | ||
run: yarn install | ||
|
||
- name: Install Detox | ||
run: npm install -g [email protected] | ||
|
||
- name: Install Apple Simulator Utilities | ||
if: ${{ matrix.platform == 'ios' }} | ||
run: | | ||
brew tap wix/brew | ||
brew install applesimutils | ||
- name: Setup KVM | ||
if: ${{ matrix.platform == 'android' }} | ||
shell: bash | ||
run: | | ||
# check if virtualization is supported... | ||
sudo apt install -y --no-install-recommends cpu-checker coreutils && echo "CPUs=$(nproc --all)" && kvm-ok | ||
# allow access to KVM to run the emulator | ||
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 | ||
- uses: futureware-tech/simulator-action@dab10d813144ef59b48d401cd95da151222ef8cd # pin@v4 | ||
if: ${{ matrix.platform == 'ios' }} | ||
with: | ||
# the same envs are used by Detox ci.sim configuration | ||
model: ${{ env.IOS_DEVICE }} | ||
os_version: ${{ env.IOS_VERSION }} | ||
|
||
- name: Run Detox iOS Tests | ||
if: ${{ matrix.platform == 'ios' }} | ||
working-directory: ${{ env.REACT_NATIVE_SAMPLE_PATH }} | ||
run: detox test --configuration ci.sim | ||
|
||
- name: Run tests on Android | ||
if: ${{ matrix.platform == 'android' }} | ||
env: | ||
# used by Detox ci.android configuration | ||
ANDROID_AVD_NAME: 'test' # test is default reactivecircus/android-emulator-runner name | ||
uses: reactivecircus/android-emulator-runner@62dbb605bba737720e10b196cb4220d374026a6d # [email protected] | ||
with: | ||
api-level: ${{ env.ANDROID_API_LEVEL }} | ||
force-avd-creation: false | ||
disable-animations: true | ||
disable-spellchecker: true | ||
target: 'aosp_atd' | ||
channel: canary # Necessary for ATDs | ||
emulator-options: > | ||
-no-window | ||
-no-snapshot-save | ||
-gpu swiftshader_indirect | ||
-noaudio | ||
-no-boot-anim | ||
-camera-back none | ||
-camera-front none | ||
-timezone US/Pacific | ||
working-directory: ${{ env.REACT_NATIVE_SAMPLE_PATH }} | ||
script: detox test --configuration ci.android |
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,119 @@ | ||
const process = require('process'); | ||
|
||
/** @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/sentryreactnativesample.app', | ||
build: | ||
'xcodebuild -workspace ios/sentryreactnativesample.xcworkspace -scheme sentryreactnativesample -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build', | ||
}, | ||
'ios.release': { | ||
type: 'ios.app', | ||
binaryPath: | ||
'ios/build/Build/Products/Release-iphonesimulator/sentryreactnativesample.app', | ||
build: | ||
'xcodebuild -workspace ios/sentryreactnativesample.xcworkspace -scheme sentryreactnativesample -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 app:assembleDebug app:assembleAndroidTest -DtestBuildType=debug', | ||
reversePorts: [8081], | ||
}, | ||
'android.release': { | ||
type: 'android.apk', | ||
binaryPath: 'android/app/build/outputs/apk/release/app-release.apk', | ||
build: | ||
'cd android && ./gradlew app:assembleRelease app:assembleAndroidTest -DtestBuildType=release', | ||
}, | ||
'ci.android': { | ||
type: 'android.apk', | ||
binaryPath: 'app.apk', | ||
testBinaryPath: 'app-androidTest.apk', | ||
}, | ||
'ci.ios': { | ||
type: 'ios.app', | ||
binaryPath: 'sentryreactnativesample.app', | ||
}, | ||
}, | ||
devices: { | ||
simulator: { | ||
type: 'ios.simulator', | ||
device: { | ||
type: 'iPhone 16', | ||
}, | ||
}, | ||
attached: { | ||
type: 'android.attached', | ||
device: { | ||
adbName: '.*', | ||
}, | ||
}, | ||
emulator: { | ||
type: 'android.emulator', | ||
device: { | ||
avdName: 'Pixel_9_API_35', | ||
}, | ||
}, | ||
'ci.emulator': { | ||
type: 'android.emulator', | ||
device: { | ||
avdName: process.env.ANDROID_AVD_NAME, | ||
}, | ||
}, | ||
'ci.simulator': { | ||
type: 'ios.simulator', | ||
device: { | ||
type: process.env.IOS_DEVICE, | ||
os: process.env.IOS_VERSION, | ||
}, | ||
}, | ||
}, | ||
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', | ||
}, | ||
'ci.android': { | ||
device: 'ci.emulator', | ||
app: 'ci.android', | ||
}, | ||
'ci.sim': { | ||
device: 'ci.simulator', | ||
app: 'ci.ios', | ||
}, | ||
}, | ||
}; |
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
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
28 changes: 28 additions & 0 deletions
28
...react-native/android/app/src/androidTest/java/io/sentry/reactnative/sample/DetoxTest.java
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,28 @@ | ||
package io.sentry.reactnative.sample; | ||
|
||
import androidx.test.ext.junit.runners.AndroidJUnit4; | ||
import androidx.test.filters.LargeTest; | ||
import androidx.test.rule.ActivityTestRule; | ||
import com.wix.detox.Detox; | ||
import com.wix.detox.config.DetoxConfig; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
@RunWith(AndroidJUnit4.class) | ||
@LargeTest | ||
public class DetoxTest { | ||
@Rule | ||
public ActivityTestRule<MainActivity> mActivityRule = | ||
new ActivityTestRule<>(MainActivity.class, false, false); | ||
|
||
@Test | ||
public void runDetoxTests() { | ||
DetoxConfig detoxConfig = new DetoxConfig(); | ||
detoxConfig.idlePolicyConfig.masterTimeoutSec = 90; | ||
detoxConfig.idlePolicyConfig.idleResourceTimeoutSec = 60; | ||
detoxConfig.rnContextLoadTimeoutSec = (BuildConfig.DEBUG ? 180 : 60); | ||
|
||
Detox.runTests(mActivityRule, detoxConfig); | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are there any issues with latest?