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

Iterating bridgeless support for Android #6755

Draft
wants to merge 22 commits into
base: kh/rn-bridgeless-2
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
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
74 changes: 58 additions & 16 deletions .github/workflows/pr-realm-js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ jobs:
packages/realm/binding/generated

prebuild-node:
if: false
name: Prebuild ${{ matrix.os }} ${{ matrix.arch }} (Node.js)
runs-on: ${{ matrix.runner }}
strategy:
Expand Down Expand Up @@ -220,6 +221,7 @@ jobs:
packages/realm/prebuilds/realm-*-napi-*.tar.gz

prebuild-apple-archives:
if: false
name: Prebuild ${{ matrix.platform }} (Apple React Native)
runs-on: macos-latest-large
strategy:
Expand Down Expand Up @@ -267,6 +269,7 @@ jobs:
if-no-files-found: error

prebuild-apple:
if: false
name: Combine Xcframework (Apple React Native)
runs-on: macos-latest-large
needs: prebuild-apple-archives
Expand Down Expand Up @@ -366,6 +369,7 @@ jobs:
if-no-files-found: error

merge-prebuilds:
if: false
name: Merge prebuild artifacts
runs-on: ubuntu-latest
needs:
Expand All @@ -379,6 +383,7 @@ jobs:
pattern: '*-prebuild'

node-electron-tests:
if: false
name: Test ${{ matrix.environment }} on ${{ matrix.runner }} (${{matrix.script_name}})
needs:
- build-ts
Expand Down Expand Up @@ -483,6 +488,7 @@ jobs:
run: ${{ env.wrapper }} npm run ${{ matrix.script_name}} --prefix integration-tests/environments/${{ matrix.environment }}

apple-tests:
if: false
name: Test iOS (React Native)
needs:
- build-ts
Expand Down Expand Up @@ -613,7 +619,7 @@ jobs:
- generate-jsi
- prebuild-android
runs-on: macos-latest-large
timeout-minutes: 60
timeout-minutes: 180
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand All @@ -626,6 +632,12 @@ jobs:
node-version: 20
cache: npm

# - name: Enable KVM
# run: |
# 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: Setup Java
uses: actions/setup-java@v3
with:
Expand Down Expand Up @@ -687,32 +699,62 @@ jobs:
restore-keys: |
${{ runner.os }}-gradle-

- name: Setup Android Emulator cache
uses: actions/cache@v4
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-29
# - name: Setup Android Emulator cache
# uses: actions/cache@v4
# id: avd-cache
# with:
# path: |
# ~/.android/avd/*
# ~/.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 --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

- name: Run tests
env:
PLATFORM: android
SPAWN_LOGCAT: true
# 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
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:
ram-size: 2048M
heap-size: 512M
api-level: 29
force-avd-creation: false
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
emulator-options: -no-snapshot-save -no-metrics -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: true
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
# 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
4 changes: 2 additions & 2 deletions integration-tests/environments/react-native-test-app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@

import { polyfill as polyfillReadableStream } from "react-native-polyfill-globals/src/readable-stream";
import { polyfill as polyfillEncoding } from "react-native-polyfill-globals/src/encoding";
import { polyfill as polyfillFetch } from "react-native-polyfill-globals/src/fetch";
// import { polyfill as polyfillFetch } from "react-native-polyfill-globals/src/fetch";

polyfillReadableStream();
polyfillEncoding();
polyfillFetch();
// polyfillFetch();

import { AppRegistry } from "react-native";
import App from "./App";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down Expand Up @@ -155,6 +156,6 @@
"concurrently": "^8.2.2",
"mocha-remote-cli": "^1.12.2",
"pod-install": "^0.2.2",
"react-native-test-app": "^3.8.2"
"react-native-test-app": "^3.8.7"
}
}
Loading
Loading