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

Feat/rn76 #4652

Merged
merged 16 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from 13 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
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
- label: ":android::react: RN .75 + Android: Demo app"
- label: ":android::react: RN .76 + Android: Demo app"
command:
- "nvm install"
- "./scripts/demo-projects.android.sh"
env:
REACT_NATIVE_VERSION: 0.75.4
REACT_NATIVE_VERSION: 0.76.3
REACT_NATIVE_COMPAT_TEST: true # Only set 'true' in jobs with the latest supported RN
DETOX_DISABLE_POD_INSTALL: true
DETOX_DISABLE_POSTINSTALL: true
Expand Down
12 changes: 12 additions & 0 deletions .buildkite/jobs/pipeline.android_rn_76.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
- label: ":android::detox: RN .76 + Android: Tests app"
command:
- "nvm install"
- "./scripts/ci.android.sh"
env:
REACT_NATIVE_VERSION: 0.76.3
DETOX_DISABLE_POD_INSTALL: true
DETOX_DISABLE_POSTINSTALL: true
artifact_paths:
- "/Users/builder/uibuilder/work/coverage/**/*.lcov"
- "/Users/builder/uibuilder/work/**/allure-report-*.html"
- "/Users/builder/uibuilder/work/artifacts*.tar.gz"
9 changes: 9 additions & 0 deletions .buildkite/jobs/pipeline.ios_demo_app_rn_76.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
- label: ":ios::react: RN .76 + iOS: Demo app"
command:
- "nvm install"
- "./scripts/demo-projects.ios.sh"
env:
REACT_NATIVE_VERSION: 0.76.3
artifact_paths:
- "/Users/builder/uibuilder/work/coverage/**/*.lcov"
- "/Users/builder/uibuilder/work/artifacts*.tar.gz"
10 changes: 10 additions & 0 deletions .buildkite/jobs/pipeline.ios_rn_76.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
- label: ":ios::detox: RN .76 + iOS: Tests app"
command:
- "nvm install"
- "./scripts/ci.ios.sh"
env:
REACT_NATIVE_VERSION: 0.76.3
artifact_paths:
- "/Users/builder/uibuilder/work/coverage/**/*.lcov"
- "/Users/builder/uibuilder/work/**/allure-report-*.html"
- "/Users/builder/uibuilder/work/artifacts*.tar.gz"
5 changes: 4 additions & 1 deletion .buildkite/pipeline_common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@

echo "steps:"

cat .buildkite/jobs/pipeline.ios_rn_76.yml
cat .buildkite/jobs/pipeline.ios_rn_75.yml
gosha212 marked this conversation as resolved.
Show resolved Hide resolved
cat .buildkite/jobs/pipeline.ios_rn_73.yml
cat .buildkite/jobs/pipeline.ios_demo_app_rn_76.yml
gosha212 marked this conversation as resolved.
Show resolved Hide resolved
cat .buildkite/jobs/pipeline.ios_demo_app_rn_75.yml
cat .buildkite/jobs/pipeline.ios_demo_app_rn_73.yml
cat .buildkite/jobs/pipeline.android_rn_76.yml
cat .buildkite/jobs/pipeline.android_rn_75.yml
cat .buildkite/jobs/pipeline.android_rn_73.yml
cat .buildkite/jobs/pipeline.android_demo_app_rn_75.yml
cat .buildkite/jobs/pipeline.android_demo_app_rn_76.yml
cat .buildkite/pipeline.post_processing.yml
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ project.xcworkspace
# Android/IJ
#
.gradle
.cxx

# node.js
#
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ The most difficult part of automated testing on mobile is the tip of the testing

Detox was built from the ground up to support React Native projects.

While Detox should work out of the box with almost any React Native version of the latest minor releases, official support is provided for React Native versions `0.72.x`, `0.73.x`, `0.74.x`, `0.75.x` with or without React Native's ["New Architecture"](https://reactnative.dev/docs/the-new-architecture/landing-page).
While Detox should work out of the box with almost any React Native version of the latest minor releases, official support is provided for React Native versions `0.72.x`, `0.73.x`, `0.74.x`, `0.75.x`, `0.76.x` without React Native's ["New Architecture"](https://reactnative.dev/docs/the-new-architecture/landing-page).
gosha212 marked this conversation as resolved.
Show resolved Hide resolved

Newer versions, as well as React Native's "New Architecture", may work with Detox, but have not been tested out yet by the Detox team.

Expand Down
8 changes: 4 additions & 4 deletions detox/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ buildscript {
isOfficialDetoxLib = true
kotlinVersion = '1.9.24'
dokkaVersion = '1.9.10'
buildToolsVersion = '34.0.0'
compileSdkVersion = 34
targetSdkVersion = 34
minSdkVersion = 23
buildToolsVersion = '35.0.0'
compileSdkVersion = 35
targetSdkVersion = 35
gosha212 marked this conversation as resolved.
Show resolved Hide resolved
minSdkVersion = 24
}
ext.detoxKotlinVersion = ext.kotlinVersion

Expand Down
3 changes: 3 additions & 0 deletions detox/android/detox/proguard-rules-app.pro
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
-keep class com.facebook.react.ReactInstanceManager { *; }
-keep class com.facebook.react.ReactInstanceManager** { *; }
-keep class com.facebook.react.ReactInstanceEventListener { *; }
-keep class com.facebook.react.soloader.OpenSourceMergedSoMapping { *; }
-keep class com.facebook.soloader.SoLoader { *; }
-keep class com.facebook.soloader.ExternalSoMapping { *; }

-keep class com.facebook.react.views.slider.** { *; }
-keep class com.google.android.material.slider.** { *; }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
package com.wix.detox.reactnative

import org.joor.Reflect
import java.util.Map
import com.facebook.react.modules.systeminfo.ReactNativeVersion

data class RNVersion(val major: Int, val minor: Int, val patch: Int)

object ReactNativeInfo {
private var rnVersion: RNVersion =
try {
val versionClass = Class.forName("com.facebook.react.modules.systeminfo.ReactNativeVersion")
val versionMap: Map<String, Int> = Reflect.on(versionClass).field("VERSION").get()
RNVersion(versionMap.get("major")!!, versionMap.get("minor")!!, versionMap.get("patch")!!)
} catch (e: ClassNotFoundException) {
// ReactNativeVersion was introduced in RN50, default to latest previous version.
RNVersion(0, 49, 0)
}
private var rnVersion: RNVersion = ReactNativeVersion.VERSION.run {
RNVersion(get("major") as Int, get("minor") as Int, get("patch") as Int)
}

@JvmStatic
fun rnVersion() = rnVersion
Expand Down
2 changes: 1 addition & 1 deletion detox/android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
13 changes: 8 additions & 5 deletions detox/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,13 @@
"postinstall": "node scripts/postinstall.js"
},
"devDependencies": {
"@react-native/babel-preset": "0.75.4",
"@react-native/eslint-config": "0.75.4",
"@react-native/metro-config": "0.75.4",
"@react-native/typescript-config": "0.75.4",
"@react-native/babel-preset": "0.76.3",
"@react-native/eslint-config": "0.76.3",
"@react-native/metro-config": "0.76.3",
"@react-native/typescript-config": "0.76.3",
"@react-native-community/cli": "15.0.1",
"@react-native-community/cli-platform-android": "15.0.1",
"@react-native-community/cli-platform-ios": "15.0.1",
gosha212 marked this conversation as resolved.
Show resolved Hide resolved
"@tsconfig/react-native": "^3.0.0",
"@types/bunyan": "^1.8.8",
"@types/child-process-promise": "^2.2.1",
Expand All @@ -59,7 +62,7 @@
"jest-allure2-reporter": "^2.0.0-beta.18",
"metro-react-native-babel-preset": "0.76.8",
"prettier": "^3.1.1",
"react-native": "0.75.4",
"react-native": "0.76.3",
"react-native-codegen": "^0.0.8",
"typescript": "^5.3.3",
"wtfnode": "^0.9.1"
Expand Down
2 changes: 2 additions & 0 deletions detox/scripts/updateGradle.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ const rnMinor = require('../src/utils/rn-consts/rn-consts').rnVersion.minor;
function getGradleVersionByRNVersion() {
switch (rnMinor) {
default:
return '8.10.2';
case '75':
return '8.8';
case '74':
return '8.6';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@ package com.example

import android.app.Application
import android.webkit.WebView
import com.example.utils.DetoxSoLoader
import com.facebook.react.ReactApplication
import com.facebook.react.ReactNativeHost
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.load
import com.facebook.soloader.SoLoader

class MainApplication : Application(), ReactApplication {
override val reactNativeHost: ReactNativeHost = DetoxRNHost(this)

override fun onCreate() {
super.onCreate()
DetoxSoLoader.init(this)

SoLoader.init(this, /* native exopackage */false)
WebView.setWebContentsDebuggingEnabled(true)
if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
// If you opted-in for the New Architecture, we load the native entry point for this app.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.example.utils

import android.content.Context
import com.facebook.react.modules.systeminfo.ReactNativeVersion
import com.facebook.soloader.SoLoader

private const val OpenSourceMergedSoMappingClassName = "com.facebook.react.soloader.OpenSourceMergedSoMapping"
private const val ExternalSoMappingClassName ="com.facebook.soloader.ExternalSoMapping"

object DetoxSoLoader {
fun init(appContext: Context) {
if (ReactNativeVersion.VERSION.run { get("minor") as Int } >= 76) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we replace that with ReactNativeInfo?

val mergedSoMappingClass = Class.forName(OpenSourceMergedSoMappingClassName)
val externalSoMapping = Class.forName(ExternalSoMappingClassName)
val initMethod = SoLoader::class.java.getMethod("init", Context::class.java, externalSoMapping)
gosha212 marked this conversation as resolved.
Show resolved Hide resolved
initMethod.invoke(null, appContext, mergedSoMappingClass.getDeclaredField("INSTANCE").get(null))
} else {
SoLoader.init(appContext, false)
}
}
}
6 changes: 3 additions & 3 deletions detox/test/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ buildscript {
ext {
isOfficialDetoxApp = true
kotlinVersion = '1.9.24'
buildToolsVersion = '34.0.0'
compileSdkVersion = 34
targetSdkVersion = 34
buildToolsVersion = '35.0.0'
compileSdkVersion = 35
targetSdkVersion = 35
minSdkVersion = 26
appCompatVersion = '1.6.1'
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
2 changes: 2 additions & 0 deletions detox/test/ios/Podfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
ENV['RCT_NEW_ARCH_ENABLED'] = '0'
gosha212 marked this conversation as resolved.
Show resolved Hide resolved

if ENV["REACT_NATIVE_VERSION"] && ENV["REACT_NATIVE_VERSION"].match(/0.(70|71).*/)
require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
Expand Down
19 changes: 11 additions & 8 deletions detox/test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,23 @@
"@react-native-segmented-control/segmented-control": "^2.5.6",
"moment": "^2.30.1",
"react": "18.3.1",
"react-native": "0.75.4",
"react-native": "0.76.3",
"react-native-launch-arguments": "^4.0.2",
"react-native-permissions": "^5.2.1",
"react-native-webview": "^13.12.4",
"ssim.js": "^3.5.0"
},
"devDependencies": {
"@babel/core": "^7.20.0",
"@babel/preset-env": "^7.20.0",
"@babel/runtime": "^7.20.0",
"@react-native/babel-preset": "0.75.4",
"@react-native/eslint-config": "0.75.4",
"@react-native/metro-config": "0.75.4",
"@react-native/typescript-config": "0.75.4",
"@babel/core": "^7.25.2",
"@babel/preset-env": "^7.25.3",
"@babel/runtime": "^7.25.0",
"@react-native/babel-preset": "0.76.3",
"@react-native/eslint-config": "0.76.3",
"@react-native/metro-config": "0.76.3",
"@react-native/typescript-config": "0.76.3",
"@react-native-community/cli": "15.0.1",
"@react-native-community/cli-platform-android": "15.0.1",
"@react-native-community/cli-platform-ios": "15.0.1",
Comment on lines +57 to +59
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

excessive args etc

"@tsconfig/react-native": "^3.0.0",
"@types/jest": "^29.5.11",
"@types/node": "^16.18.68",
Expand Down
1 change: 1 addition & 0 deletions examples/demo-react-native/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ react {
android {
namespace 'com.example'

ndkVersion rootProject.ext.ndkVersion
gosha212 marked this conversation as resolved.
Show resolved Hide resolved
buildToolsVersion = rootProject.ext.buildToolsVersion

println("[$project] Using buildToolsVersion $buildToolsVersion")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,24 @@

import android.app.Application;

import androidx.annotation.Nullable;

import com.facebook.react.PackageList;
import com.facebook.react.ReactApplication;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.defaults.DefaultReactNativeHost;
import com.facebook.react.shell.MainReactPackage;
import com.facebook.soloader.SoLoader;
import com.reactnativecommunity.asyncstorage.AsyncStoragePackage;

import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import com.facebook.react.soloader.OpenSourceMergedSoMapping;

public class MainApplication extends Application implements ReactApplication {
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
private final ReactNativeHost mReactNativeHost = new DefaultReactNativeHost(this) {
@Override
public boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
Expand All @@ -24,6 +29,22 @@ public boolean getUseDeveloperSupport() {
protected List<ReactPackage> getPackages() {
return new PackageList(this).getPackages();
}

@Override
protected String getJSMainModuleName() {
return "index";
}

@Override
protected boolean isNewArchEnabled() {
return BuildConfig.IS_NEW_ARCHITECTURE_ENABLED;
}

@Nullable
@Override
protected Boolean isHermesEnabled() {
return BuildConfig.IS_HERMES_ENABLED;
}
};

@Override
Expand All @@ -34,7 +55,11 @@ public ReactNativeHost getReactNativeHost() {
@Override
public void onCreate() {
super.onCreate();
SoLoader.init(this, /* native exopackage */ false);
try {
SoLoader.init(this, OpenSourceMergedSoMapping.INSTANCE);
} catch (IOException e) {
gosha212 marked this conversation as resolved.
Show resolved Hide resolved
throw new RuntimeException(e);
}
}

}
16 changes: 7 additions & 9 deletions examples/demo-react-native/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ buildscript {
apply from: '../../../detox/android/rninfo.gradle'

ext {
kotlinVersion = '1.9.20'
buildToolsVersion = '34.0.0'
compileSdkVersion = 34
targetSdkVersion = 34
minSdkVersion = 23
kotlinVersion = '1.9.24'
buildToolsVersion = '35.0.0'
compileSdkVersion = 35
targetSdkVersion = 35
ndkVersion = "26.1.10909125"
minSdkVersion = 24
}

repositories {
Expand Down Expand Up @@ -42,7 +43,4 @@ subprojects {
}
}

if (ext.rnInfo.isRN73OrHigher) {
apply plugin: "com.facebook.react.rootproject"
}

apply plugin: "com.facebook.react.rootproject"
4 changes: 2 additions & 2 deletions examples/demo-react-native/android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ org.gradle.jvmargs=-Xmx3g -Dfile.encoding=UTF-8
# org.gradle.parallel=true

android.useAndroidX=true
android.enableJetifier=true

newArchEnabled=false
hermesEnabled=true
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
Loading
Loading