Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
470c19c
misc(sample): Change RN Sample to use native file init by default
krystofwoldrich Feb 10, 2025
21e54c8
wip: Add detox, add mocked sentry server
krystofwoldrich Feb 11, 2025
329783d
wip: partial tests
krystofwoldrich Feb 11, 2025
e5bf161
polish tests and mocked server
krystofwoldrich Feb 11, 2025
e0d5be7
NEW_PR: Remove duplicate options
krystofwoldrich Feb 11, 2025
02dfa19
split test to envelope header and capture message
krystofwoldrich Feb 11, 2025
9acb02d
detox android setup
krystofwoldrich Feb 12, 2025
02476f7
fix envelope parsing and split test to android and ios
krystofwoldrich Feb 12, 2025
d8ef6b7
run detox in CI
krystofwoldrich Feb 13, 2025
b1dff5f
fix ios path, add retention days
krystofwoldrich Feb 13, 2025
1e1b4a3
revers download archive merge into one step
krystofwoldrich Feb 13, 2025
0b1a4e9
TMP: download already built artifacts for faster development
krystofwoldrich Feb 13, 2025
9a6b0ac
add missing install JS dependencies
krystofwoldrich Feb 13, 2025
e57997f
Merge commit 'a7ffa1fdde67e7d5cc259053bb0cb688f25eea83' into kw/snaps…
krystofwoldrich Feb 13, 2025
9310436
fix artifacts not being unzipped
krystofwoldrich Feb 13, 2025
9b94228
fix ios app path
krystofwoldrich Feb 13, 2025
377d2b9
fix missing kotlin classes
krystofwoldrich Feb 13, 2025
d1bb750
extend timeout to 10 minutes
krystofwoldrich Feb 13, 2025
b862a2a
add comment
krystofwoldrich Feb 13, 2025
aef1f32
update timeout for CI
krystofwoldrich Feb 13, 2025
c99db0a
Revert "TMP: download already built artifacts for faster development"
krystofwoldrich Feb 13, 2025
803a5a2
set correct mock dsn for tests
krystofwoldrich Feb 13, 2025
858f71c
remove unnecessary timeout
krystofwoldrich Feb 13, 2025
d79a200
restore original dsn
krystofwoldrich Feb 13, 2025
68558db
fix the scripts path
krystofwoldrich Feb 13, 2025
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
164 changes: 159 additions & 5 deletions .github/workflows/sample-application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -106,8 +112,10 @@ jobs:

- name: Build Android App
if: ${{ matrix.platform == 'android' }}
working-directory: samples/react-native/android
working-directory: ${{ env.REACT_NATIVE_SAMPLE_PATH }}/android
run: |
../scripts/set-aos-dsn.mjs

if [[ ${{ matrix.rn-architecture }} == 'new' ]]; then
perl -i -pe's/newArchEnabled=false/newArchEnabled=true/g' gradle.properties
echo 'New Architecture enabled'
Expand All @@ -119,12 +127,17 @@ 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: |
../scripts/set-ios-dsn.mjs

[[ "${{ matrix.build-type }}" == "production" ]] && CONFIG='Release' || CONFIG='Debug'
echo "Building $CONFIG"
mkdir -p "DerivedData"
Expand Down Expand Up @@ -160,9 +173,150 @@ 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

- 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
141 changes: 141 additions & 0 deletions samples/react-native/.detoxrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
const process = require('process');

const TEST_TIMEOUT = 2 * 60 * 1000; // 2 minutes

/** @type {Detox.DetoxConfig} */
const testRunnerIos = {
args: {
$0: 'jest',
config: 'e2e/jest.config.ios.js',
},
jest: {
setupTimeout: TEST_TIMEOUT,
},
};

const testRunnerAos = {
args: {
$0: 'jest',
config: 'e2e/jest.config.android.js',
},
jest: {
setupTimeout: TEST_TIMEOUT,
},
};

module.exports = {
testRunner: {},
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',
testRunner: testRunnerIos,
},
'ios.sim.release': {
device: 'simulator',
app: 'ios.release',
testRunner: testRunnerIos,
},
'android.att.debug': {
device: 'attached',
app: 'android.debug',
testRunner: testRunnerAos,
},
'android.att.release': {
device: 'attached',
app: 'android.release',
testRunner: testRunnerAos,
},
'android.emu.debug': {
device: 'emulator',
app: 'android.debug',
testRunner: testRunnerAos,
},
'android.emu.release': {
device: 'emulator',
app: 'android.release',
testRunner: testRunnerAos,
},
'ci.android': {
device: 'ci.emulator',
app: 'ci.android',
testRunner: testRunnerAos,
},
'ci.sim': {
device: 'ci.simulator',
app: 'ci.ios',
testRunner: testRunnerIos,
},
},
};
1 change: 1 addition & 0 deletions samples/react-native/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ GEM
PLATFORMS
arm64-darwin-22
arm64-darwin-23
arm64-darwin-24
x86_64-darwin-20

DEPENDENCIES
Expand Down
8 changes: 8 additions & 0 deletions samples/react-native/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@ android {
versionCode 39
versionName "6.7.0-alpha.0"
buildConfigField "boolean", "SENTRY_DISABLE_NATIVE_START", System.getenv('SENTRY_DISABLE_NATIVE_START') ?: String.valueOf(sentryDisableNativeStart)

// Detox
testBuildType System.getProperty('testBuildType', 'debug')
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
}

signingConfigs {
Expand Down Expand Up @@ -193,11 +197,15 @@ android {
signingConfig signingConfigs.debug
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
proguardFile "${rootProject.projectDir}/../node_modules/detox/android/detox/proguard-rules-app.pro"
}
}
}

dependencies {
androidTestImplementation('com.wix:detox:+')
implementation 'androidx.appcompat:appcompat:1.7.0'

// The version of react-native is set by the React Native Gradle Plugin
implementation("com.facebook.react:react-android")

Expand Down
4 changes: 4 additions & 0 deletions samples/react-native/android/app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,7 @@
# http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# Detox Release tests were failing on missing kotlin.Result
# It should be covered by node_modules/detox/android/detox/proguard-rules-app.pro but it seems missing
-keep class kotlin.** { *; }
Loading
Loading