Skip to content

Commit

Permalink
Upgrade integration test app to React Native v0.66.2 (realm#4068)
Browse files Browse the repository at this point in the history
* Upgraded React Native to 0.66.2

* Removed patch needed to start catalyst app

* Attempt updating the Xcode project

* Reenabling catalyst support

* Applying fix to RCT-Folly

* Simplified lerna bootstrap command

This is no longer needed as we're no longer using install-local

* Failing tests faster
  • Loading branch information
kraenhansen committed Nov 10, 2021
1 parent 9334dd9 commit b95e045
Show file tree
Hide file tree
Showing 14 changed files with 2,358 additions and 3,433 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ jobs:
# Build the iOS xcframework
- run: ./scripts/build-ios.sh -c ${{ matrix.type }} ${{matrix.platform.build-configuration}}
# Bootstrap lerna sub-packages (builds the packages, the Realm JS native module and pod install)
- run: npx lerna bootstrap --scope '{realm-integration-tests,realm-react-native-tests}' --include-dependencies
- run: npx lerna bootstrap --scope realm-react-native-tests --include-dependencies
# Run the tests
- name: Run tests (${{matrix.platform.name}}/ Native)
run: npm run test:${{matrix.platform.name}} --prefix integration-tests/environments/react-native
Expand Down Expand Up @@ -274,7 +274,7 @@ jobs:
# Build the Android shared object file
- run: ANDROID_NDK=$ANDROID_NDK_HOME node scripts/build-android.js --arch=x86 --build-type=${{ matrix.type }}
# Bootstrap lerna sub-packages (builds the packages, the Realm JS native module and pod install)
- run: npx lerna bootstrap --scope '{realm-integration-tests,realm-react-native-tests}' --include-dependencies
- run: npx lerna bootstrap --scope realm-react-native-tests --include-dependencies
# Run the tests
- name: Run tests (Android / Native)
uses: reactivecircus/android-emulator-runner@v2
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/environments/node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"private": true,
"scripts": {
"start": "node index.js",
"test": "mocha-remote -- concurrently npm:app-importer npm:start",
"test": "mocha-remote -- concurrently --kill-others-on-fail npm:app-importer npm:start",
"lint": "eslint .",
"app-importer": "realm-app-importer serve ../../realm-apps"
},
Expand Down
66 changes: 0 additions & 66 deletions integration-tests/environments/react-native/.flowconfig

This file was deleted.

1 change: 1 addition & 0 deletions integration-tests/environments/react-native/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ build/
.gradle
local.properties
*.iml
*.hprof

# node.js
#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,16 +120,16 @@ def jscFlavor = 'org.webkit:android-jsc:+'
*/
def enableHermes = project.ext.react.get("enableHermes", false);

/**
* Architectures to build native code for in debug.
*/
def nativeArchitectures = project.getProperties().get("reactNativeDebugArchitectures")

android {
ndkVersion rootProject.ext.ndkVersion

compileSdkVersion rootProject.ext.compileSdkVersion

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

defaultConfig {
applicationId "com.realmreactnativetests"
minSdkVersion rootProject.ext.minSdkVersion
Expand All @@ -156,6 +156,11 @@ android {
buildTypes {
debug {
signingConfig signingConfigs.debug
if (nativeArchitectures) {
ndk {
abiFilters nativeArchitectures.split(',')
}
}
}
release {
// Caution! In production, you need to generate your own keystore file.
Expand Down Expand Up @@ -193,7 +198,7 @@ dependencies {
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"

debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
exclude group:'com.facebook.fbjni'
exclude group:'com.facebook.fbjni'
}

debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
Expand All @@ -217,7 +222,7 @@ dependencies {
// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
from configurations.implementation
into 'libs'
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
<!-- Customize your theme here. -->
<item name="android:textColor">#000000</item>
</style>

</resources>
14 changes: 7 additions & 7 deletions integration-tests/environments/react-native/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,26 @@

buildscript {
ext {
buildToolsVersion = "29.0.3"
buildToolsVersion = "30.0.2"
minSdkVersion = 21
compileSdkVersion = 29
targetSdkVersion = 29
ndkVersion = "20.1.5948944"
compileSdkVersion = 30
targetSdkVersion = 30
ndkVersion = "21.4.7075529"
}
repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
classpath("com.android.tools.build:gradle:4.1.0")
classpath("com.android.tools.build:gradle:4.2.2")
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

allprojects {
repositories {
mavenCentral()
mavenLocal()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
Expand All @@ -32,7 +33,6 @@ allprojects {
}

google()
jcenter()
maven { url 'https://www.jitpack.io' }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ android.useAndroidX=true
android.enableJetifier=true

# Version of flipper SDK to use with React Native
FLIPPER_VERSION=0.75.1
FLIPPER_VERSION=0.99.0
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\:https://services.gradle.org/distributions/gradle-6.7-all.zip
distributionUrl=https\:https://services.gradle.org/distributions/gradle-6.9-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
51 changes: 3 additions & 48 deletions integration-tests/environments/react-native/harness/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
// limitations under the License.
//
////////////////////////////////////////////////////////////////////////////
const cp = require("child_process");
const puppeteer = require("puppeteer");

const rn = require("./react-native-cli");
Expand Down Expand Up @@ -141,59 +140,15 @@ async function run(headless, spawnLogcat) {
if (spawnLogcat) {
logcat.start("com.realmreactnativetests", true).catch(console.error);
}
// Ask React Native to run the android app
// Ask React Native to build and run the app
rn.sync("run-android", "--no-packager");
} else if (PLATFORM === "ios") {
// Ask React Native to run the ios app
// Ask React Native to build and run the app
rn.sync("run-ios", "--no-packager", "--simulator", IOS_DEVICE_NAME);
} else if (PLATFORM === "catalyst") {
// Ask React Native to run the ios app
const myMacDeviceId = xcode.getMyMacDeviceId();

// This will just build the app, but not launch it
// Ask React Native to build and run the app
rn.sync("run-ios", "--no-packager", "--udid", myMacDeviceId);

// TODO: When the PR (https://github.com/react-native-community/cli/pull/1449) is live in React-Native
// the following lines can be removed

// This will retrieve the build information and launch the app
const buildSettings = cp.execFileSync(
"xcodebuild",
[
"-workspace",
"./ios/RealmReactNativeTests.xcworkspace",
"-scheme",
"RealmReactNativeTests",
"-sdk",
"macosx",
"-configuration",
"Debug",
"-showBuildSettings",
"-json",
],
{ encoding: "utf8" },
);
const settings = JSON.parse(buildSettings);

let targetExecutable = "";

for (const i in settings) {
const wrapperExtension = settings[i].buildSettings.WRAPPER_EXTENSION;

if (wrapperExtension === "app") {
const targetBuildDir = `${settings[i].buildSettings.TARGET_BUILD_DIR}-maccatalyst`;
const executableFolderPath = settings[i].buildSettings.EXECUTABLE_FOLDER_PATH;
targetExecutable = `${targetBuildDir}/${executableFolderPath}/RealmReactNativeTests`;
}
}

if (targetExecutable !== "") {
const appProcess = cp.spawn(targetExecutable, [], {
detached: true,
stdio: "ignore",
});
appProcess.unref();
}
} else {
throw new Error(`Unexpected platform: '${PLATFORM}'`);
}
Expand Down
9 changes: 8 additions & 1 deletion integration-tests/environments/react-native/ios/Podfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

platform :ios, '10.0'
platform :ios, '11.0'

# Remove all warnings to limit the build logs
inhibit_all_warnings!
Expand Down Expand Up @@ -31,6 +31,7 @@ target 'RealmReactNativeTests' do

post_install do |installer|
react_native_post_install(installer)
__apply_Xcode_12_5_M1_post_install_workaround(installer)
# TODO: The following is a workaround for a bug in CocoaPods when using Catalyst
# https://github.com/CocoaPods/CocoaPods/issues/8891
# Fix bundle targets' 'Signing Certificate' to 'Sign to Run Locally'
Expand All @@ -40,6 +41,12 @@ target 'RealmReactNativeTests' do
config.build_settings['CODE_SIGN_IDENTITY[sdk=macosx*]'] = '-'
end
end
# Applying https://github.com/facebook/folly/issues/1470#issuecomment-943123653
if target.name == "RCT-Folly"
target.build_configurations.each do |config|
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['$(inherited)', 'FOLLY_HAVE_CLOCK_GETTIME=1']
end
end
end
end
end
Loading

0 comments on commit b95e045

Please sign in to comment.