Skip to content

Commit 61ddd2e

Browse files
Merge d9f5804 into 48ad514
2 parents 48ad514 + d9f5804 commit 61ddd2e

20 files changed

+794
-10
lines changed

.github/workflows/sample-application.yml

Lines changed: 164 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ concurrency:
1414
env:
1515
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
1616
RN_SENTRY_POD_NAME: RNSentry
17+
IOS_APP_ARCHIVE_PATH: sentry-react-native-sample.app.zip
18+
ANDROID_APP_ARCHIVE_PATH: sentry-react-native-sample.apk.zip
19+
REACT_NATIVE_SAMPLE_PATH: samples/react-native
20+
IOS_DEVICE: 'iPhone 16'
21+
IOS_VERSION: '18.1'
22+
ANDROID_API_LEVEL: '30'
1723

1824
jobs:
1925
diff_check:
@@ -66,7 +72,7 @@ jobs:
6672
- uses: ruby/setup-ruby@v1
6773
if: ${{ matrix.platform == 'ios' || matrix.platform == 'macos' }}
6874
with:
69-
working-directory: ${{ matrix.platform == 'ios' && ' samples/react-native' || ' samples/react-native-macos' }}
75+
working-directory: ${{ matrix.platform == 'ios' && env.REACT_NATIVE_SAMPLE_PATH || ' samples/react-native-macos' }}
7076
ruby-version: '3.3.0' # based on what is used in the sample
7177
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
7278
cache-version: 1 # cache the installed gems
@@ -106,7 +112,7 @@ jobs:
106112
107113
- name: Build Android App
108114
if: ${{ matrix.platform == 'android' }}
109-
working-directory: samples/react-native/android
115+
working-directory: ${{ env.REACT_NATIVE_SAMPLE_PATH }}/android
110116
run: |
111117
if [[ ${{ matrix.rn-architecture }} == 'new' ]]; then
112118
perl -i -pe's/newArchEnabled=false/newArchEnabled=true/g' gradle.properties
@@ -119,11 +125,14 @@ jobs:
119125
fi
120126
[[ "${{ matrix.build-type }}" == "production" ]] && CONFIG='Release' || CONFIG='Debug'
121127
echo "Building $CONFIG"
128+
[[ "${{ matrix.build-type }}" == "production" ]] && TEST_TYPE='release' || TEST_TYPE='debug'
129+
echo "Building $TEST_TYPE"
130+
122131
./gradlew ":app:assemble$CONFIG" -PreactNativeArchitectures=x86
123132
124133
- name: Build iOS App
125134
if: ${{ matrix.platform == 'ios' }}
126-
working-directory: samples/react-native/ios
135+
working-directory: ${{ env.REACT_NATIVE_SAMPLE_PATH }}/ios
127136
run: |
128137
[[ "${{ matrix.build-type }}" == "production" ]] && CONFIG='Release' || CONFIG='Debug'
129138
echo "Building $CONFIG"
@@ -160,9 +169,160 @@ jobs:
160169
| tee xcodebuild.log \
161170
| xcbeautify --quieter --is-ci --disable-colored-output
162171
172+
- name: Archive iOS App
173+
if: ${{ matrix.platform == 'ios' && matrix.rn-architecture == 'new' && matrix.build-type == 'production' && matrix.ios-use-frameworks == 'no-frameworks' }}
174+
run: |
175+
cd ${{ env.REACT_NATIVE_SAMPLE_PATH }}/ios/DerivedData/Build/Products/Release-iphonesimulator
176+
zip -r \
177+
${{ github.workspace }}/${{ env.IOS_APP_ARCHIVE_PATH }} \
178+
sentryreactnativesample.app
179+
180+
- name: Archive Android App
181+
if: ${{ matrix.platform == 'android' && matrix.rn-architecture == 'new' && matrix.build-type == 'production' }}
182+
run: |
183+
mv ${{ env.REACT_NATIVE_SAMPLE_PATH }}/android/app/build/outputs/apk/release/app-release.apk app.apk
184+
zip -j \
185+
${{ env.ANDROID_APP_ARCHIVE_PATH }} \
186+
app.apk
187+
188+
- name: Upload iOS APP
189+
if: ${{ matrix.platform == 'ios' && matrix.rn-architecture == 'new' && matrix.build-type == 'production' && matrix.ios-use-frameworks == 'no-frameworks' }}
190+
uses: actions/upload-artifact@v4
191+
with:
192+
name: sample-rn-${{ matrix.rn-architecture }}-${{ matrix.build-type }}-${{ matrix.ios-use-frameworks}}-${{ matrix.platform }}
193+
path: ${{ env.IOS_APP_ARCHIVE_PATH }}
194+
retention-days: 1
195+
196+
- name: Upload Android APK
197+
if: ${{ matrix.platform == 'android' && matrix.rn-architecture == 'new' && matrix.build-type == 'production' }}
198+
uses: actions/upload-artifact@v4
199+
with:
200+
name: sample-rn-${{ matrix.rn-architecture }}-${{ matrix.build-type }}-${{ matrix.platform }}
201+
path: ${{ env.ANDROID_APP_ARCHIVE_PATH }}
202+
retention-days: 1
203+
163204
- name: Upload logs
164205
if: ${{ always() }}
165206
uses: actions/upload-artifact@v4
166207
with:
167208
name: build-sample-${{ matrix.rn-architecture }}-${{ matrix.platform }}-${{ matrix.build-type }}-${{ matrix.ios-use-frameworks}}-logs
168-
path: samples/react-native/${{ matrix.platform }}/*.log
209+
path: ${{ env.REACT_NATIVE_SAMPLE_PATH }}/${{ matrix.platform }}/*.log
210+
211+
test:
212+
name: Test ${{ matrix.platform }} ${{ matrix.build-type }}
213+
runs-on: ${{ matrix.runs-on }}
214+
needs: [diff_check, build]
215+
if: ${{ needs.diff_check.outputs.skip_ci != 'true' }}
216+
strategy:
217+
# we want that the matrix keeps running, default is to cancel them if it fails.
218+
fail-fast: false
219+
matrix:
220+
include:
221+
- platform: ios
222+
runs-on: macos-15
223+
rn-architecture: 'new'
224+
ios-use-frameworks: 'no-frameworks'
225+
build-type: 'production'
226+
227+
- platform: android
228+
runs-on: ubuntu-latest
229+
rn-architecture: 'new'
230+
build-type: 'production'
231+
232+
steps:
233+
- uses: actions/checkout@v4
234+
235+
- name: Download iOS App Archive
236+
if: ${{ matrix.platform == 'ios' }}
237+
uses: actions/download-artifact@v4
238+
with:
239+
name: sample-rn-${{ matrix.rn-architecture }}-${{ matrix.build-type }}-${{ matrix.ios-use-frameworks}}-${{ matrix.platform }}
240+
path: ${{ env.REACT_NATIVE_SAMPLE_PATH }}
241+
242+
- name: Download Android APK
243+
if: ${{ matrix.platform == 'android' }}
244+
uses: actions/download-artifact@v4
245+
with:
246+
name: sample-rn-${{ matrix.rn-architecture }}-${{ matrix.build-type }}-${{ matrix.platform }}
247+
path: ${{ env.REACT_NATIVE_SAMPLE_PATH }}
248+
249+
- name: Unzip iOS App Archive
250+
if: ${{ matrix.platform == 'ios' }}
251+
working-directory: ${{ env.REACT_NATIVE_SAMPLE_PATH }}
252+
run: unzip ${{ env.IOS_APP_ARCHIVE_PATH }}
253+
254+
- name: Unzip Android APK
255+
if: ${{ matrix.platform == 'android' }}
256+
working-directory: ${{ env.REACT_NATIVE_SAMPLE_PATH }}
257+
run: unzip ${{ env.ANDROID_APP_ARCHIVE_PATH }}
258+
259+
- name: Enable Corepack
260+
run: |
261+
npm install -g [email protected]
262+
corepack enable
263+
- uses: actions/setup-node@v4
264+
with:
265+
node-version: 18
266+
cache: 'yarn'
267+
cache-dependency-path: yarn.lock
268+
269+
- name: Install JS Dependencies
270+
run: yarn install
271+
272+
- name: Install Detox
273+
run: npm install -g [email protected]
274+
275+
- name: Install Apple Simulator Utilities
276+
if: ${{ matrix.platform == 'ios' }}
277+
run: |
278+
brew tap wix/brew
279+
brew install applesimutils
280+
281+
- name: Setup KVM
282+
if: ${{ matrix.platform == 'android' }}
283+
shell: bash
284+
run: |
285+
# check if virtualization is supported...
286+
sudo apt install -y --no-install-recommends cpu-checker coreutils && echo "CPUs=$(nproc --all)" && kvm-ok
287+
# allow access to KVM to run the emulator
288+
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' \
289+
| sudo tee /etc/udev/rules.d/99-kvm4all.rules
290+
sudo udevadm control --reload-rules
291+
sudo udevadm trigger --name-match=kvm
292+
293+
- uses: futureware-tech/simulator-action@dab10d813144ef59b48d401cd95da151222ef8cd # pin@v4
294+
if: ${{ matrix.platform == 'ios' }}
295+
with:
296+
# the same envs are used by Detox ci.sim configuration
297+
model: ${{ env.IOS_DEVICE }}
298+
os_version: ${{ env.IOS_VERSION }}
299+
300+
- name: Run Detox iOS Tests
301+
if: ${{ matrix.platform == 'ios' }}
302+
working-directory: ${{ env.REACT_NATIVE_SAMPLE_PATH }}
303+
run: yarn test-ios
304+
305+
- name: Run tests on Android
306+
if: ${{ matrix.platform == 'android' }}
307+
env:
308+
# used by Detox ci.android configuration
309+
ANDROID_AVD_NAME: 'test' # test is default reactivecircus/android-emulator-runner name
310+
uses: reactivecircus/android-emulator-runner@62dbb605bba737720e10b196cb4220d374026a6d # [email protected]
311+
with:
312+
api-level: ${{ env.ANDROID_API_LEVEL }}
313+
force-avd-creation: false
314+
disable-animations: true
315+
disable-spellchecker: true
316+
target: 'aosp_atd'
317+
channel: canary # Necessary for ATDs
318+
emulator-options: >
319+
-no-window
320+
-no-snapshot-save
321+
-gpu swiftshader_indirect
322+
-noaudio
323+
-no-boot-anim
324+
-camera-back none
325+
-camera-front none
326+
-timezone US/Pacific
327+
working-directory: ${{ env.REACT_NATIVE_SAMPLE_PATH }}
328+
script: yarn test-android

samples/react-native/android/app/build.gradle

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,11 +192,15 @@ android {
192192
signingConfig signingConfigs.debug
193193
minifyEnabled enableProguardInReleaseBuilds
194194
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
195+
proguardFile "${rootProject.projectDir}/../node_modules/detox/android/detox/proguard-rules-app.pro"
195196
}
196197
}
197198
}
198199

199200
dependencies {
201+
androidTestImplementation('com.wix:detox:+')
202+
implementation 'androidx.appcompat:appcompat:1.7.0'
203+
200204
// The version of react-native is set by the React Native Gradle Plugin
201205
implementation("com.facebook.react:react-android")
202206

samples/react-native/android/app/src/main/AndroidManifest.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
android:roundIcon="@mipmap/ic_launcher_round"
1010
android:allowBackup="false"
1111
android:theme="@style/AppTheme"
12-
android:supportsRtl="true">
12+
android:supportsRtl="true"
13+
android:networkSecurityConfig="@xml/network_security_config">
1314
<activity
1415
android:name=".MainActivity"
1516
android:label="@string/app_name"
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<network-security-config>
3+
<domain-config cleartextTrafficPermitted="true">
4+
<domain includeSubdomains="true">10.0.2.2</domain>
5+
<domain includeSubdomains="true">localhost</domain>
6+
</domain-config>
7+
</network-security-config>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.xml

0 commit comments

Comments
 (0)