Skip to content

Commit e935360

Browse files
chore(samples): Add package scripts for native builds, dsn and testing (#4561)
1 parent 0f5cd7d commit e935360

30 files changed

+401
-171
lines changed

.github/workflows/sample-application.yml

Lines changed: 22 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -99,66 +99,39 @@ jobs:
9999
if: ${{ matrix.platform == 'ios' || matrix.platform == 'macos' }}
100100
working-directory: samples
101101
run: |
102-
[[ "${{ matrix.platform }}" == "ios" ]] && cd react-native/ios
103-
[[ "${{ matrix.platform }}" == "macos" ]] && cd react-native-macos/macos
102+
[[ "${{ matrix.platform }}" == "ios" ]] && cd react-native
103+
[[ "${{ matrix.platform }}" == "macos" ]] && cd react-native-macos
104104
105-
[[ "${{ matrix.build-type }}" == "production" ]] && ENABLE_PROD=1 || ENABLE_PROD=0
106-
[[ "${{ matrix.rn-architecture }}" == "new" ]] && ENABLE_NEW_ARCH=1 || ENABLE_NEW_ARCH=0
105+
[[ "${{ matrix.build-type }}" == "production" ]] && export ENABLE_PROD=1 || export ENABLE_PROD=0
106+
[[ "${{ matrix.rn-architecture }}" == "new" ]] && export ENABLE_NEW_ARCH=1 || export ENABLE_NEW_ARCH=0
107107
[[ "${{ matrix.ios-use-frameworks }}" == "dynamic-frameworks" ]] && export USE_FRAMEWORKS=dynamic
108-
echo "ENABLE_PROD=$ENABLE_PROD"
109-
echo "ENABLE_NEW_ARCH=$ENABLE_NEW_ARCH"
110-
PRODUCTION=$ENABLE_PROD RCT_NEW_ARCH_ENABLED=$ENABLE_NEW_ARCH bundle exec pod install
111-
cat Podfile.lock | grep $RN_SENTRY_POD_NAME
108+
109+
./scripts/pod-install.sh
112110
113111
- name: Build Android App
114112
if: ${{ matrix.platform == 'android' }}
115-
working-directory: ${{ env.REACT_NATIVE_SAMPLE_PATH }}/android
113+
working-directory: ${{ env.REACT_NATIVE_SAMPLE_PATH }}
116114
run: |
117-
../scripts/set-aos-dsn.mjs
118-
119-
if [[ ${{ matrix.rn-architecture }} == 'new' ]]; then
120-
perl -i -pe's/newArchEnabled=false/newArchEnabled=true/g' gradle.properties
121-
echo 'New Architecture enabled'
122-
elif [[ ${{ matrix.rn-architecture }} == 'legacy' ]]; then
123-
perl -i -pe's/newArchEnabled=true/newArchEnabled=false/g' gradle.properties
124-
echo 'Legacy Architecture enabled'
125-
else
126-
echo 'No changes for architecture: ${{ matrix.rn-architecture }}'
127-
fi
128-
[[ "${{ matrix.build-type }}" == "production" ]] && CONFIG='Release' || CONFIG='Debug'
129-
echo "Building $CONFIG"
130-
[[ "${{ matrix.build-type }}" == "production" ]] && TEST_TYPE='release' || TEST_TYPE='debug'
131-
echo "Building $TEST_TYPE"
115+
export RN_ARCHITECTURE="${{ matrix.rn-architecture }}"
116+
[[ "${{ matrix.build-type }}" == "production" ]] && export CONFIG='release' || export CONFIG='debug'
132117
133-
./gradlew ":app:assemble$CONFIG" app:assembleAndroidTest -DtestBuildType=$TEST_TYPE -PreactNativeArchitectures=x86
118+
./scripts/set-dsn-aos.mjs
119+
./scripts/build-android.sh -PreactNativeArchitectures=x86
134120
135121
- name: Build iOS App
136122
if: ${{ matrix.platform == 'ios' }}
137-
working-directory: ${{ env.REACT_NATIVE_SAMPLE_PATH }}/ios
123+
working-directory: ${{ env.REACT_NATIVE_SAMPLE_PATH }}
138124
run: |
139-
../scripts/set-ios-dsn.mjs
125+
[[ "${{ matrix.build-type }}" == "production" ]] && export CONFIG='Release' || export CONFIG='Debug'
140126
141-
[[ "${{ matrix.build-type }}" == "production" ]] && CONFIG='Release' || CONFIG='Debug'
142-
echo "Building $CONFIG"
143-
mkdir -p "DerivedData"
144-
derivedData="$(cd "DerivedData" ; pwd -P)"
145-
set -o pipefail && xcodebuild \
146-
-workspace sentryreactnativesample.xcworkspace \
147-
-configuration "$CONFIG" \
148-
-scheme sentryreactnativesample \
149-
-sdk 'iphonesimulator' \
150-
-destination 'generic/platform=iOS Simulator' \
151-
ONLY_ACTIVE_ARCH=yes \
152-
-derivedDataPath "$derivedData" \
153-
build \
154-
| tee xcodebuild.log \
155-
| xcbeautify --quieter --is-ci --disable-colored-output
127+
./scripts/set-dsn-ios.mjs
128+
./scripts/build-ios.sh
156129
157130
- name: Build macOS App
158131
if: ${{ matrix.platform == 'macos' }}
159132
working-directory: samples/react-native-macos/macos
160133
run: |
161-
[[ "${{ matrix.build-type }}" == "production" ]] && CONFIG='Release' || CONFIG='Debug'
134+
[[ "${{ matrix.build-type }}" == "production" ]] && export CONFIG='Release' || export CONFIG='Debug'
162135
echo "Building $CONFIG"
163136
mkdir -p "DerivedData"
164137
derivedData="$(cd "DerivedData" ; pwd -P)"
@@ -175,21 +148,19 @@ jobs:
175148
176149
- name: Archive iOS App
177150
if: ${{ matrix.platform == 'ios' && matrix.rn-architecture == 'new' && matrix.build-type == 'production' && matrix.ios-use-frameworks == 'no-frameworks' }}
151+
working-directory: ${{ env.REACT_NATIVE_SAMPLE_PATH }}
178152
run: |
179-
cd ${{ env.REACT_NATIVE_SAMPLE_PATH }}/ios/DerivedData/Build/Products/Release-iphonesimulator
180153
zip -r \
181154
${{ github.workspace }}/${{ env.IOS_APP_ARCHIVE_PATH }} \
182155
sentryreactnativesample.app
183156
184157
- name: Archive Android App
185158
if: ${{ matrix.platform == 'android' && matrix.rn-architecture == 'new' && matrix.build-type == 'production' }}
186159
run: |
187-
mv ${{ env.REACT_NATIVE_SAMPLE_PATH }}/android/app/build/outputs/apk/release/app-release.apk app.apk
188-
mv ${{ env.REACT_NATIVE_SAMPLE_PATH }}/android/app/build/outputs/apk/androidTest/release/app-release-androidTest.apk app-androidTest.apk
189160
zip -j \
190161
${{ env.ANDROID_APP_ARCHIVE_PATH }} \
191-
app.apk \
192-
app-androidTest.apk
162+
${{ env.REACT_NATIVE_SAMPLE_PATH }}/app.apk \
163+
${{ env.REACT_NATIVE_SAMPLE_PATH }}/app-androidTest.apk
193164
194165
- name: Upload iOS APP
195166
if: ${{ matrix.platform == 'ios' && matrix.rn-architecture == 'new' && matrix.build-type == 'production' && matrix.ios-use-frameworks == 'no-frameworks' }}
@@ -306,13 +277,14 @@ jobs:
306277
- name: Run Detox iOS Tests
307278
if: ${{ matrix.platform == 'ios' }}
308279
working-directory: ${{ env.REACT_NATIVE_SAMPLE_PATH }}
309-
run: detox test --configuration ci.sim
280+
run: yarn test-ios
310281

311282
- name: Run tests on Android
312283
if: ${{ matrix.platform == 'android' }}
313284
env:
314285
# used by Detox ci.android configuration
315286
ANDROID_AVD_NAME: 'test' # test is default reactivecircus/android-emulator-runner name
287+
ANDROID_TYPE: 'android.emulator'
316288
uses: reactivecircus/android-emulator-runner@62dbb605bba737720e10b196cb4220d374026a6d # pin@v2.33.0
317289
with:
318290
api-level: ${{ env.ANDROID_API_LEVEL }}
@@ -331,4 +303,4 @@ jobs:
331303
-camera-front none
332304
-timezone US/Pacific
333305
working-directory: ${{ env.REACT_NATIVE_SAMPLE_PATH }}
334-
script: detox test --configuration ci.android
306+
script: yarn test-android
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
3+
# Exit on error
4+
set -e
5+
6+
thisFilePath=$(dirname "$0")
7+
8+
echo "USE_FRAMEWORKS=$USE_FRAMEWORKS"
9+
echo "ENABLE_PROD=$ENABLE_PROD"
10+
echo "ENABLE_NEW_ARCH=$ENABLE_NEW_ARCH"
11+
12+
cd "${thisFilePath}/.."
13+
bundle install
14+
15+
cd macos
16+
PRODUCTION=$ENABLE_PROD RCT_NEW_ARCH_ENABLED=$ENABLE_NEW_ARCH bundle exec pod update
17+
18+
cat Podfile.lock | grep $RN_SENTRY_POD_NAME

samples/react-native/.detoxrc.js

Lines changed: 23 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,9 @@
11
const process = require('process');
22

3-
const testRunnerIos = {
4-
args: {
5-
$0: 'jest',
6-
config: 'e2e/jest.config.ios.js',
7-
},
8-
jest: {
9-
setupTimeout: 120000,
10-
},
11-
};
12-
13-
const testRunnerAos = {
14-
args: {
15-
$0: 'jest',
16-
config: 'e2e/jest.config.android.js',
17-
},
18-
jest: {
19-
setupTimeout: 120000,
20-
},
21-
};
22-
233
/** @type {Detox.DetoxConfig} */
244
module.exports = {
255
testRunner: {},
266
apps: {
27-
'ios.debug': {
28-
type: 'ios.app',
29-
binaryPath:
30-
'ios/build/Build/Products/Debug-iphonesimulator/sentryreactnativesample.app',
31-
build:
32-
'xcodebuild -workspace ios/sentryreactnativesample.xcworkspace -scheme sentryreactnativesample -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build',
33-
},
34-
'ios.release': {
35-
type: 'ios.app',
36-
binaryPath:
37-
'ios/build/Build/Products/Release-iphonesimulator/sentryreactnativesample.app',
38-
build:
39-
'xcodebuild -workspace ios/sentryreactnativesample.xcworkspace -scheme sentryreactnativesample -configuration Release -sdk iphonesimulator -derivedDataPath ios/build',
40-
},
41-
'android.debug': {
42-
type: 'android.apk',
43-
binaryPath: 'android/app/build/outputs/apk/debug/app-debug.apk',
44-
build:
45-
'cd android && ./gradlew app:assembleDebug app:assembleAndroidTest -DtestBuildType=debug',
46-
reversePorts: [8081],
47-
},
48-
'android.release': {
49-
type: 'android.apk',
50-
binaryPath: 'android/app/build/outputs/apk/release/app-release.apk',
51-
build:
52-
'cd android && ./gradlew app:assembleRelease app:assembleAndroidTest -DtestBuildType=release',
53-
},
547
'ci.android': {
558
type: 'android.apk',
569
binaryPath: 'app.apk',
@@ -62,78 +15,47 @@ module.exports = {
6215
},
6316
},
6417
devices: {
65-
simulator: {
66-
type: 'ios.simulator',
67-
device: {
68-
type: 'iPhone 16',
69-
},
70-
},
71-
attached: {
72-
type: 'android.attached',
73-
device: {
74-
adbName: '.*',
75-
},
76-
},
77-
emulator: {
78-
type: 'android.emulator',
79-
device: {
80-
avdName: 'Pixel_9_API_35',
81-
},
82-
},
8318
'ci.emulator': {
84-
type: 'android.emulator',
19+
type: process.env.ANDROID_TYPE?.trim(),
8520
device: {
86-
avdName: process.env.ANDROID_AVD_NAME,
21+
avdName: process.env.ANDROID_AVD_NAME?.trim(),
22+
adbName: process.env.ANDROID_ADB_NAME?.trim(),
8723
},
8824
},
8925
'ci.simulator': {
9026
type: 'ios.simulator',
9127
device: {
92-
type: process.env.IOS_DEVICE,
93-
os: process.env.IOS_VERSION,
28+
type: process.env.IOS_DEVICE?.trim(),
29+
os: process.env.IOS_VERSION?.trim(),
9430
},
9531
},
9632
},
9733
configurations: {
98-
'ios.sim.debug': {
99-
device: 'simulator',
100-
app: 'ios.debug',
101-
testRunner: testRunnerIos,
102-
},
103-
'ios.sim.release': {
104-
device: 'simulator',
105-
app: 'ios.release',
106-
testRunner: testRunnerIos,
107-
},
108-
'android.att.debug': {
109-
device: 'attached',
110-
app: 'android.debug',
111-
testRunner: testRunnerAos,
112-
},
113-
'android.att.release': {
114-
device: 'attached',
115-
app: 'android.release',
116-
testRunner: testRunnerAos,
117-
},
118-
'android.emu.debug': {
119-
device: 'emulator',
120-
app: 'android.debug',
121-
testRunner: testRunnerAos,
122-
},
123-
'android.emu.release': {
124-
device: 'emulator',
125-
app: 'android.release',
126-
testRunner: testRunnerAos,
127-
},
12834
'ci.android': {
12935
device: 'ci.emulator',
13036
app: 'ci.android',
131-
testRunner: testRunnerAos,
37+
testRunner: {
38+
args: {
39+
$0: 'jest',
40+
config: 'e2e/jest.config.android.js',
41+
},
42+
jest: {
43+
setupTimeout: 120000,
44+
},
45+
},
13246
},
13347
'ci.sim': {
13448
device: 'ci.simulator',
13549
app: 'ci.ios',
136-
testRunner: testRunnerIos,
50+
testRunner: {
51+
args: {
52+
$0: 'jest',
53+
config: 'e2e/jest.config.ios.js',
54+
},
55+
jest: {
56+
setupTimeout: 120000,
57+
},
58+
},
13759
},
13860
},
13961
};

samples/react-native/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,5 @@ yarn-error.log
6363
.metro-health-check*
6464

6565
*.xcarchive
66+
*.apk
67+
**/*.app

samples/react-native/package.json

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,28 @@
44
"private": true,
55
"scripts": {
66
"postinstall": "patch-package",
7-
"android": "react-native run-android",
8-
"ios": "react-native run-ios",
97
"start": "react-native start",
8+
"build-android-release": "scripts/build-android-release.sh",
9+
"build-android-release-legacy": "scripts/build-android-release-legacy.sh",
10+
"build-android-debug": "scripts/build-android-debug.sh",
11+
"build-android-debug-legacy": "scripts/build-android-debug-legacy.sh",
12+
"build-ios-release": "scripts/build-ios-release.sh",
13+
"build-ios-debug": "scripts/build-ios-debug.sh",
1014
"test": "jest",
15+
"set-test-dsn-android": "scripts/set-dsn-aos.mjs",
16+
"set-test-dsn-ios": "scripts/set-dsn-ios.mjs",
17+
"test-android": "scripts/test-android.sh",
18+
"test-ios": "scripts/test-ios.sh",
1119
"lint": "npx eslint . --ext .js,.jsx,.ts,.tsx",
1220
"fix": "eslint . --ext .js,.jsx,.ts,.tsx --fix",
13-
"pod-install": "cd ios; RCT_NEW_ARCH_ENABLED=1 bundle exec pod install; cd ..",
14-
"pod-install-production": "cd ios; PRODUCTION=1 RCT_NEW_ARCH_ENABLED=1 bundle exec pod install; cd ..",
15-
"pod-install-legacy": "cd ios; bundle exec pod install; cd ..",
16-
"pod-install-legacy-production": "cd ios; PRODUCTION=1 bundle exec pod install; cd ..",
21+
"pod-install-debug-static": "scripts/pod-install-debug-static.sh",
22+
"pod-install-debug-static-legacy": "scripts/pod-install-debug-static-legacy.sh",
23+
"pod-install-debug-dynamic": "scripts/pod-install-debug-dynamic.sh",
24+
"pod-install-debug-dynamic-legacy": "scripts/pod-install-debug-dynamic-legacy.sh",
25+
"pod-install-release-static": "scripts/pod-install-release-static.sh",
26+
"pod-install-release-static-legacy": "scripts/pod-install-release-static-legacy.sh",
27+
"pod-install-release-dynamic": "scripts/pod-install-release-dynamic.sh",
28+
"pod-install-release-dynamic-legacy": "scripts/pod-install-release-dynamic-legacy.sh",
1729
"clean-ios": "cd ios; rm -rf Podfile.lock Pods build; cd ..",
1830
"clean-watchman": "watchman watch-del-all",
1931
"set-build-number": "npx react-native-version --skip-tag --never-amend --set-build",
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
# Exit on error
4+
set -e
5+
6+
thisFilePath=$(dirname "$0")
7+
8+
export RN_ARCHITECTURE="legacy"
9+
export CONFIG="debug"
10+
11+
"${thisFilePath}/build-android.sh"
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
# Exit on error
4+
set -e
5+
6+
thisFilePath=$(dirname "$0")
7+
8+
export RN_ARCHITECTURE="new"
9+
export CONFIG="debug"
10+
11+
"${thisFilePath}/build-android.sh"
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
# Exit on error
4+
set -e
5+
6+
thisFilePath=$(dirname "$0")
7+
8+
export RN_ARCHITECTURE="legacy"
9+
export CONFIG="release"
10+
11+
"${thisFilePath}/build-android.sh"
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
# Exit on error
4+
set -e
5+
6+
thisFilePath=$(dirname "$0")
7+
8+
export RN_ARCHITECTURE="new"
9+
export CONFIG="release"
10+
11+
"${thisFilePath}/build-android.sh"

0 commit comments

Comments
 (0)