Skip to content

Commit e46354e

Browse files
test(sample): Add E2E tests for app start transactions (#4619)
1 parent eb597b3 commit e46354e

24 files changed

+847
-10
lines changed

.github/workflows/sample-application.yml

Lines changed: 158 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,14 @@ concurrency:
1313

1414
env:
1515
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
16+
MAESTRO_VERSION: '1.39.0'
1617
RN_SENTRY_POD_NAME: RNSentry
18+
IOS_APP_ARCHIVE_PATH: sentry-react-native-sample.app.zip
19+
ANDROID_APP_ARCHIVE_PATH: sentry-react-native-sample.apk.zip
20+
REACT_NATIVE_SAMPLE_PATH: samples/react-native
21+
IOS_DEVICE: 'iPhone 16'
22+
IOS_VERSION: '18.1'
23+
ANDROID_API_LEVEL: '30'
1724

1825
jobs:
1926
diff_check:
@@ -66,7 +73,7 @@ jobs:
6673
- uses: ruby/setup-ruby@v1
6774
if: ${{ matrix.platform == 'ios' || matrix.platform == 'macos' }}
6875
with:
69-
working-directory: ${{ matrix.platform == 'ios' && ' samples/react-native' || ' samples/react-native-macos' }}
76+
working-directory: ${{ matrix.platform == 'ios' && env.REACT_NATIVE_SAMPLE_PATH || ' samples/react-native-macos' }}
7077
ruby-version: '3.3.0' # based on what is used in the sample
7178
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
7279
cache-version: 1 # cache the installed gems
@@ -106,7 +113,7 @@ jobs:
106113
107114
- name: Build Android App
108115
if: ${{ matrix.platform == 'android' }}
109-
working-directory: samples/react-native/android
116+
working-directory: ${{ env.REACT_NATIVE_SAMPLE_PATH }}/android
110117
run: |
111118
if [[ ${{ matrix.rn-architecture }} == 'new' ]]; then
112119
perl -i -pe's/newArchEnabled=false/newArchEnabled=true/g' gradle.properties
@@ -119,11 +126,14 @@ jobs:
119126
fi
120127
[[ "${{ matrix.build-type }}" == "production" ]] && CONFIG='Release' || CONFIG='Debug'
121128
echo "Building $CONFIG"
129+
[[ "${{ matrix.build-type }}" == "production" ]] && TEST_TYPE='release' || TEST_TYPE='debug'
130+
echo "Building $TEST_TYPE"
131+
122132
./gradlew ":app:assemble$CONFIG" -PreactNativeArchitectures=x86
123133
124134
- name: Build iOS App
125135
if: ${{ matrix.platform == 'ios' }}
126-
working-directory: samples/react-native/ios
136+
working-directory: ${{ env.REACT_NATIVE_SAMPLE_PATH }}/ios
127137
run: |
128138
[[ "${{ matrix.build-type }}" == "production" ]] && CONFIG='Release' || CONFIG='Debug'
129139
echo "Building $CONFIG"
@@ -160,9 +170,153 @@ jobs:
160170
| tee xcodebuild.log \
161171
| xcbeautify --quieter --is-ci --disable-colored-output
162172
173+
- name: Archive iOS App
174+
if: ${{ matrix.platform == 'ios' && matrix.rn-architecture == 'new' && matrix.build-type == 'production' && matrix.ios-use-frameworks == 'no-frameworks' }}
175+
run: |
176+
cd ${{ env.REACT_NATIVE_SAMPLE_PATH }}/ios/DerivedData/Build/Products/Release-iphonesimulator
177+
zip -r \
178+
${{ github.workspace }}/${{ env.IOS_APP_ARCHIVE_PATH }} \
179+
sentryreactnativesample.app
180+
181+
- name: Archive Android App
182+
if: ${{ matrix.platform == 'android' && matrix.rn-architecture == 'new' && matrix.build-type == 'production' }}
183+
run: |
184+
mv ${{ env.REACT_NATIVE_SAMPLE_PATH }}/android/app/build/outputs/apk/release/app-release.apk app.apk
185+
zip -j \
186+
${{ env.ANDROID_APP_ARCHIVE_PATH }} \
187+
app.apk
188+
189+
- name: Upload iOS APP
190+
if: ${{ matrix.platform == 'ios' && matrix.rn-architecture == 'new' && matrix.build-type == 'production' && matrix.ios-use-frameworks == 'no-frameworks' }}
191+
uses: actions/upload-artifact@v4
192+
with:
193+
name: sample-rn-${{ matrix.rn-architecture }}-${{ matrix.build-type }}-${{ matrix.ios-use-frameworks}}-${{ matrix.platform }}
194+
path: ${{ env.IOS_APP_ARCHIVE_PATH }}
195+
retention-days: 1
196+
197+
- name: Upload Android APK
198+
if: ${{ matrix.platform == 'android' && matrix.rn-architecture == 'new' && matrix.build-type == 'production' }}
199+
uses: actions/upload-artifact@v4
200+
with:
201+
name: sample-rn-${{ matrix.rn-architecture }}-${{ matrix.build-type }}-${{ matrix.platform }}
202+
path: ${{ env.ANDROID_APP_ARCHIVE_PATH }}
203+
retention-days: 1
204+
163205
- name: Upload logs
164206
if: ${{ always() }}
165207
uses: actions/upload-artifact@v4
166208
with:
167209
name: build-sample-${{ matrix.rn-architecture }}-${{ matrix.platform }}-${{ matrix.build-type }}-${{ matrix.ios-use-frameworks}}-logs
168-
path: samples/react-native/${{ matrix.platform }}/*.log
210+
path: ${{ env.REACT_NATIVE_SAMPLE_PATH }}/${{ matrix.platform }}/*.log
211+
212+
test:
213+
name: Test ${{ matrix.platform }} ${{ matrix.build-type }}
214+
runs-on: ${{ matrix.runs-on }}
215+
needs: [diff_check, build]
216+
if: ${{ needs.diff_check.outputs.skip_ci != 'true' }}
217+
strategy:
218+
# we want that the matrix keeps running, default is to cancel them if it fails.
219+
fail-fast: false
220+
matrix:
221+
include:
222+
- platform: ios
223+
runs-on: macos-15
224+
rn-architecture: 'new'
225+
ios-use-frameworks: 'no-frameworks'
226+
build-type: 'production'
227+
228+
- platform: android
229+
runs-on: ubuntu-latest
230+
rn-architecture: 'new'
231+
build-type: 'production'
232+
233+
steps:
234+
- uses: actions/checkout@v4
235+
236+
- name: Install Maestro
237+
uses: dniHze/maestro-test-action@bda8a93211c86d0a05b7a4597c5ad134566fbde4 # [email protected]
238+
with:
239+
version: ${{env.MAESTRO_VERSION}}
240+
241+
- name: Download iOS App Archive
242+
if: ${{ matrix.platform == 'ios' }}
243+
uses: actions/download-artifact@v4
244+
with:
245+
name: sample-rn-${{ matrix.rn-architecture }}-${{ matrix.build-type }}-${{ matrix.ios-use-frameworks}}-${{ matrix.platform }}
246+
path: ${{ env.REACT_NATIVE_SAMPLE_PATH }}
247+
248+
- name: Download Android APK
249+
if: ${{ matrix.platform == 'android' }}
250+
uses: actions/download-artifact@v4
251+
with:
252+
name: sample-rn-${{ matrix.rn-architecture }}-${{ matrix.build-type }}-${{ matrix.platform }}
253+
path: ${{ env.REACT_NATIVE_SAMPLE_PATH }}
254+
255+
- name: Unzip iOS App Archive
256+
if: ${{ matrix.platform == 'ios' }}
257+
working-directory: ${{ env.REACT_NATIVE_SAMPLE_PATH }}
258+
run: unzip ${{ env.IOS_APP_ARCHIVE_PATH }}
259+
260+
- name: Unzip Android APK
261+
if: ${{ matrix.platform == 'android' }}
262+
working-directory: ${{ env.REACT_NATIVE_SAMPLE_PATH }}
263+
run: unzip ${{ env.ANDROID_APP_ARCHIVE_PATH }}
264+
265+
- name: Enable Corepack
266+
run: |
267+
npm install -g [email protected]
268+
corepack enable
269+
- uses: actions/setup-node@v4
270+
with:
271+
node-version: 18
272+
cache: 'yarn'
273+
cache-dependency-path: yarn.lock
274+
275+
- name: Install JS Dependencies
276+
run: yarn install
277+
278+
- name: Setup KVM
279+
if: ${{ matrix.platform == 'android' }}
280+
shell: bash
281+
run: |
282+
# check if virtualization is supported...
283+
sudo apt install -y --no-install-recommends cpu-checker coreutils && echo "CPUs=$(nproc --all)" && kvm-ok
284+
# allow access to KVM to run the emulator
285+
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' \
286+
| sudo tee /etc/udev/rules.d/99-kvm4all.rules
287+
sudo udevadm control --reload-rules
288+
sudo udevadm trigger --name-match=kvm
289+
290+
- name: Boot ${{ env.IOS_DEVICE }} with iOS ${{ env.IOS_VERSION }}
291+
uses: futureware-tech/simulator-action@dab10d813144ef59b48d401cd95da151222ef8cd # pin@v4
292+
if: ${{ matrix.platform == 'ios' }}
293+
with:
294+
model: ${{ env.IOS_DEVICE }}
295+
os_version: ${{ env.IOS_VERSION }}
296+
297+
- name: Run iOS Tests
298+
if: ${{ matrix.platform == 'ios' }}
299+
working-directory: ${{ env.REACT_NATIVE_SAMPLE_PATH }}
300+
run: yarn test-ios
301+
302+
- name: Run Android Tests on API ${{ env.ANDROID_API_LEVEL }}
303+
if: ${{ matrix.platform == 'android' }}
304+
uses: reactivecircus/android-emulator-runner@62dbb605bba737720e10b196cb4220d374026a6d # [email protected]
305+
with:
306+
api-level: ${{ env.ANDROID_API_LEVEL }}
307+
force-avd-creation: false
308+
disable-animations: true
309+
disable-spellchecker: true
310+
target: 'aosp_atd'
311+
channel: canary # Necessary for ATDs
312+
emulator-options: >
313+
-no-window
314+
-no-snapshot-save
315+
-gpu swiftshader_indirect
316+
-noaudio
317+
-no-boot-anim
318+
-camera-back none
319+
-camera-front none
320+
-timezone US/Pacific
321+
working-directory: ${{ env.REACT_NATIVE_SAMPLE_PATH }}
322+
script: yarn test-android

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>

samples/react-native/e2e/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.xml

0 commit comments

Comments
 (0)