-
Notifications
You must be signed in to change notification settings - Fork 584
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 on Android using "release" configuration #6769
Changes from all commits
98a7f65
e1c63e1
3f90b25
e450978
98483ae
ef7320b
4b0e69a
897f29c
31a565a
ed77194
382261d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -698,11 +698,32 @@ jobs: | |
~/.android/adb* | ||
key: avd-29 | ||
|
||
- name: Bundle test app | ||
working-directory: integration-tests/environments/react-native-test-app | ||
run: | | ||
mkdir dist | ||
npx react-native bundle --entry-file index.js --platform android --dev false --minify false --bundle-output dist/main.android.jsbundle --assets-dest dist/res | ||
|
||
- name: Generate a keystore for signing | ||
working-directory: integration-tests/environments/react-native-test-app | ||
env: | ||
STORE_PATH: debug.keystore | ||
STORE_PASS: android | ||
KEY_ALIAS: debug-key | ||
KEY_PASS: android | ||
run: | | ||
keytool -genkey -v -keyalg RSA -keysize 2048 -validity 10000 -dname cn=Realm -keystore ${{ env.STORE_PATH }} -storepass ${{ env.STORE_PASS }} -alias ${{ env.KEY_ALIAS }} -keypass ${{ env.KEY_PASS }} | ||
jq --arg storeFile ${{ env.STORE_PATH }} --arg storePassword ${{ env.STORE_PASS }} --arg keyAlias ${{ env.KEY_ALIAS }} --arg keyPassword ${{ env.KEY_PASS }} '. +{android: {signingConfigs: { release: { $storeFile, $storePassword, $keyAlias, $keyPassword } }}}' app.json > patched-app.json | ||
mv patched-app.json app.json | ||
Comment on lines
+715
to
+717
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This generates a temporary keystore and key to sign the release APK and patch the RNTA app.json to pick it up when building the app. |
||
|
||
- name: Run tests | ||
env: | ||
PLATFORM: android | ||
# Limit architecture to speed up the build | ||
ORG_GRADLE_PROJECT_reactNativeArchitectures: x86 | ||
# Enabling new architecture and bridgeless | ||
ORG_GRADLE_PROJECT_newArchEnabled: true | ||
ORG_GRADLE_PROJECT_bridgelessEnabled: true | ||
Comment on lines
+723
to
+725
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Our native module supports this only on Android at the moment, while #6737 will bring this to iOS too (and refactor the Android implementation too). |
||
MOCHA_REMOTE_CONTEXT: ${{ steps.mocha-env.outputs.context }} | ||
# TODO: Consider passing ORG_GRADLE_PROJECT_reactNativeArchitectures=x86 to limit increase build speed | ||
timeout-minutes: 75 | ||
uses: reactivecircus/android-emulator-runner@v2 | ||
with: | ||
|
@@ -713,6 +734,17 @@ jobs: | |
arch: x86 | ||
ndk: ${{ env.NDK_VERSION }} | ||
cmake: 3.22.1 | ||
working-directory: integration-tests/environments/react-native-test-app | ||
script: npx mocha-remote -- concurrently --kill-others-on-fail npm:metro npm:runner | ||
|
||
working-directory: integration-tests/environments/react-native-test-app/android | ||
script: | | ||
# Setup port forwarding to Mocha Remote | ||
adb reverse tcp:8090 tcp:8090 | ||
# Uninstall the app if already in the snapshot (unlikely but could result in a signature mismatch failure) | ||
adb uninstall com.microsoft.reacttestapp || true | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Uninstalling here should fix the issues we're having with the Android test app being unable to install on other branches: https://github.com/realm/realm-js/actions/runs/9680928508/job/26757061658?pr=6743#step:16:526
|
||
# Build and install the app | ||
./gradlew installRelease | ||
# Launch the app | ||
# -W wait for launch to complete, to allow the logcat script to find a pid | ||
# -S force stop the target app before starting the activity | ||
adb shell am start -W -S -n com.microsoft.reacttestapp/.MainActivity | ||
# Start Mocha Remote, wrapping logcat | ||
npx mocha-remote -- npm run logcat |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,8 @@ | |
"realm:build-android:debug": "wireit", | ||
"realm:build-android:release": "wireit", | ||
"metro": "react-native start --reset-cache", | ||
"runner": "node harness/runner.js" | ||
"runner": "node harness/runner.js", | ||
"logcat": "adb logcat -v color --pid=$(adb shell pidof -s com.microsoft.reacttestapp)" | ||
}, | ||
"wireit": { | ||
"test:android": { | ||
|
@@ -130,7 +131,7 @@ | |
}, | ||
"dependencies": { | ||
"base-64": "^1.0.0", | ||
"mocha-remote-react-native": "^1.12.2", | ||
"mocha-remote-react-native": "^1.12.3", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This new version avoids transforming errors when the bundle isn't shipped from Metro. |
||
"path-browserify": "^1.0.1", | ||
"react": "18.2.0", | ||
"react-native": "0.74.1", | ||
|
@@ -152,8 +153,8 @@ | |
"@rnx-kit/metro-config": "^1.3.15", | ||
"@types/react": "^18.2.6", | ||
"concurrently": "^8.2.2", | ||
"mocha-remote-cli": "^1.12.2", | ||
"mocha-remote-cli": "^1.12.3", | ||
"pod-install": "^0.2.2", | ||
"react-native-test-app": "^3.7.3" | ||
"react-native-test-app": "^3.8.7" | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use
--minify false
to avoid test failures from error messages mismatching due to class names being renamed in the bundle.