Skip to content
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

test(sample): Add E2E tests for app start transactions #4619

Open
wants to merge 18 commits into
base: main
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
162 changes: 158 additions & 4 deletions .github/workflows/sample-application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,14 @@ concurrency:

env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
MAESTRO_VERSION: '1.39.0'
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 +73,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,7 +113,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
Expand All @@ -119,11 +126,14 @@ jobs:
fi
[[ "${{ matrix.build-type }}" == "production" ]] && CONFIG='Release' || CONFIG='Debug'
echo "Building $CONFIG"
[[ "${{ matrix.build-type }}" == "production" ]] && TEST_TYPE='release' || TEST_TYPE='debug'
echo "Building $TEST_TYPE"

./gradlew ":app:assemble$CONFIG" -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"
Expand Down Expand Up @@ -160,9 +170,153 @@ 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
zip -j \
${{ env.ANDROID_APP_ARCHIVE_PATH }} \
app.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: Install Maestro
uses: dniHze/maestro-test-action@bda8a93211c86d0a05b7a4597c5ad134566fbde4 # [email protected]
with:
version: ${{env.MAESTRO_VERSION}}

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

- name: Boot ${{ env.IOS_DEVICE }} with iOS ${{ env.IOS_VERSION }}
uses: futureware-tech/simulator-action@dab10d813144ef59b48d401cd95da151222ef8cd # pin@v4
if: ${{ matrix.platform == 'ios' }}
with:
model: ${{ env.IOS_DEVICE }}
os_version: ${{ env.IOS_VERSION }}

- name: Run iOS Tests
if: ${{ matrix.platform == 'ios' }}
working-directory: ${{ env.REACT_NATIVE_SAMPLE_PATH }}
run: yarn test-ios

- name: Run Android Tests on API ${{ env.ANDROID_API_LEVEL }}
if: ${{ matrix.platform == 'android' }}
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: yarn test-android
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:allowBackup="false"
android:theme="@style/AppTheme"
android:supportsRtl="true">
android:supportsRtl="true"
android:networkSecurityConfig="@xml/network_security_config">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="true">10.0.2.2</domain>
<domain includeSubdomains="true">localhost</domain>
</domain-config>
</network-security-config>
1 change: 1 addition & 0 deletions samples/react-native/e2e/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.xml
Loading
Loading