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

Upgrade/rn72 final #4336

Merged
merged 37 commits into from
Jan 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
faba8da
WIP
gosha212 Jan 7, 2024
9cbfd66
WIP
gosha212 Jan 8, 2024
e71ffc4
Fixed legacy components
gosha212 Jan 8, 2024
39b0402
Make android workin with rn72
gosha212 Jan 8, 2024
34d467f
Support iOS
gosha212 Jan 8, 2024
d43f0ba
Fixed ios
gosha212 Jan 8, 2024
788c1f6
Reverted detox config
gosha212 Jan 9, 2024
d96ac64
Fixed build for ios RN 0.71
gosha212 Jan 10, 2024
fadb43d
Fixed support for RN 71
gosha212 Jan 11, 2024
a0544eb
Rall back to older gradle
gosha212 Jan 11, 2024
71c978d
Added rn 72 pipelines
gosha212 Jan 11, 2024
eeb9332
Disable old pipelines
gosha212 Jan 11, 2024
512bd8c
Fixed pod
gosha212 Jan 11, 2024
f82059b
Fixed build on rn 71
gosha212 Jan 11, 2024
8ae933d
More build fixes
gosha212 Jan 11, 2024
23a12dd
Revert "More build fixes"
gosha212 Jan 11, 2024
94be43c
Fixed build
gosha212 Jan 11, 2024
7cbfbaa
Fixed build
gosha212 Jan 11, 2024
9d02632
Fixed test
gosha212 Jan 11, 2024
04068ab
Fixed android build
gosha212 Jan 11, 2024
929c7f9
Merge branch 'master' into upgrade/RN72
gosha212 Jan 11, 2024
0f378cc
Fixed build for ios
gosha212 Jan 11, 2024
8f9f5b9
Fixed ios build
gosha212 Jan 11, 2024
5ec6f6f
Gradle refactorign
gosha212 Jan 14, 2024
41b8eb1
Fixed android build
gosha212 Jan 14, 2024
259d287
Merge branch 'master' into upgrade/RN72-final
gosha212 Jan 15, 2024
6462481
Try to fix ios
gosha212 Jan 15, 2024
845addd
Fixed lint
gosha212 Jan 15, 2024
025b3d1
Fixed tests for ios
gosha212 Jan 15, 2024
7beb1ad
Another attept to fix a build
gosha212 Jan 15, 2024
f71e0bd
Fixed pod file
gosha212 Jan 15, 2024
2368406
Undo changes
gosha212 Jan 15, 2024
8f7a474
Fixed documentation
gosha212 Jan 16, 2024
b87c4e1
Fixed build for ios
gosha212 Jan 16, 2024
912c1ce
Fixes after MR
gosha212 Jan 21, 2024
8dfbdf8
Fixed lint
gosha212 Jan 21, 2024
1f3e32c
Fixed build
gosha212 Jan 21, 2024
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
12 changes: 12 additions & 0 deletions .buildkite/jobs/pipeline.android_demo_app_rn_72.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
- label: ":android::react: RN .72 + Android: Demo app"
command:
- "nvm install"
- "./scripts/demo-projects.android.sh"
env:
REACT_NATIVE_VERSION: 0.72.8
REACT_NATIVE_COMPAT_TEST: true # Only set 'true' in jobs with the latest supported RN
DETOX_DISABLE_POD_INSTALL: true
DETOX_DISABLE_POSTINSTALL: true
artifact_paths:
- "/Users/builder/work/coverage/**/*.lcov"
- "/Users/builder/work/artifacts*.tar.gz"
1 change: 1 addition & 0 deletions .buildkite/jobs/pipeline.android_rn_71.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
REACT_NATIVE_VERSION: 0.71.10
DETOX_DISABLE_POD_INSTALL: true
DETOX_DISABLE_POSTINSTALL: true
SKIP_UNIT_TESTS: true
artifact_paths:
- "/Users/builder/work/coverage/**/*.lcov"
- "/Users/builder/work/**/allure-report-*.html"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
- label: ":android::detox: RN .70 + Android: Tests app"
- label: ":android::detox: RN .72 + Android: Tests app"
command:
- "nvm install"
- "./scripts/ci.android.sh"
env:
REACT_NATIVE_VERSION: 0.70.7
REACT_NATIVE_VERSION: 0.72.8
DETOX_DISABLE_POD_INSTALL: true
DETOX_DISABLE_POSTINSTALL: true
SKIP_UNIT_TESTS: true
artifact_paths:
gosha212 marked this conversation as resolved.
Show resolved Hide resolved
- "/Users/builder/work/coverage/**/*.lcov"
- "/Users/builder/work/**/allure-report-*.html"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
- label: ":ios::react: RN. 70 + iOS: Demo app"
- label: ":ios::react: RN .72 + iOS: Demo app"
command:
- "nvm install"
- "./scripts/demo-projects.ios.sh"
env:
REACT_NATIVE_VERSION: 0.70.7
REACT_NATIVE_VERSION: 0.72.8
artifact_paths:
- "/Users/builder/work/coverage/**/*.lcov"
- "/Users/builder/work/artifacts*.tar.gz"
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
- label: ":ios::detox: RN .70 + iOS: Tests app"
- label: ":ios::detox: RN .72 + iOS: Tests app"
command:
- "nvm install"
- "./scripts/ci.ios.sh"
env:
REACT_NATIVE_VERSION: 0.70.7
REACT_NATIVE_VERSION: 0.72.8
artifact_paths:
- "/Users/builder/work/coverage/**/*.lcov"
- "/Users/builder/work/**/allure-report-*.html"
Expand Down
7 changes: 4 additions & 3 deletions .buildkite/pipeline_common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

echo "steps:"

cat .buildkite/jobs/pipeline.ios_rn_72.yml
cat .buildkite/jobs/pipeline.ios_rn_71.yml
cat .buildkite/jobs/pipeline.ios_rn_70.yml
cat .buildkite/jobs/pipeline.ios_demo_app_rn_72.yml
cat .buildkite/jobs/pipeline.ios_demo_app_rn_71.yml
cat .buildkite/jobs/pipeline.ios_demo_app_rn_70.yml
cat .buildkite/jobs/pipeline.android_rn_72.yml
cat .buildkite/jobs/pipeline.android_rn_71.yml
cat .buildkite/jobs/pipeline.android_rn_70.yml
cat .buildkite/jobs/pipeline.android_demo_app_rn_72.yml
cat .buildkite/jobs/pipeline.android_demo_app_rn_71.yml
cat .buildkite/pipeline.post_processing.yml
2 changes: 1 addition & 1 deletion detox/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module.exports = {
'eslint:recommended',
'plugin:import/recommended',
'plugin:node/recommended',
'plugin:ecmascript-compat/recommended'
'plugin:ecmascript-compat/recommended',
],
parser: '@typescript-eslint/parser',
plugins: [
Expand Down
12 changes: 2 additions & 10 deletions detox/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,11 @@ buildscript {
ext {
isOfficialDetoxLib = true
kotlinVersion = '1.6.21'
dokkaVersion = '1.6.0'
dokkaVersion = '1.9.10'
buildToolsVersion = '33.0.0'
compileSdkVersion = 33
targetSdkVersion = 33
minSdkVersion = 21

if (System.properties['os.arch'] == "aarch64") {
// For M1 Users we need to use the NDK 24 which added support for aarch64
ndkVersion = "24.0.8215888"
} else {
// Otherwise we default to the side-by-side NDK version from AGP.
ndkVersion = "21.4.7075529"
}
gosha212 marked this conversation as resolved.
Show resolved Hide resolved
}
ext.detoxKotlinVersion = ext.kotlinVersion

Expand All @@ -28,7 +20,7 @@ buildscript {
if (!rnInfo.isRN71OrNewer) {
classpath "com.facebook.react:react-native-gradle-plugin"
}
classpath 'com.android.tools.build:gradle:7.3.1'
classpath 'com.android.tools.build:gradle'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
classpath "org.jetbrains.dokka:dokka-gradle-plugin:$dokkaVersion"

Expand Down
2 changes: 2 additions & 0 deletions detox/android/detox/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ def _rnNativeArtifact = rnInfo.isRN71OrHigher
? "com.facebook.react:react-android:${rnInfo.version}"
: 'com.facebook.react:react-native:+'

println "[$project] Resorted to RN native artifact $_rnNativeArtifact"

android {
def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')[0].toInteger()
if (agpVersion >= 7) {
Expand Down
4 changes: 2 additions & 2 deletions detox/android/detox/publishing.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ tasks.named("dokkaJavadoc") {
// suppression config var or something.
task dokkaDocJar(type: Jar, dependsOn: dokkaJavadoc) {
from "$buildDir/dokkaDoc"
classifier = 'javadoc'
archiveClassifier.set("javadoc")
}

/*
Expand All @@ -119,7 +119,7 @@ task dokkaDocJar(type: Jar, dependsOn: dokkaJavadoc) {

task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier = 'sources'
archiveClassifier.set("sources")
}

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import com.facebook.react.bridge.JavaOnlyMap
import com.facebook.react.uimanager.ReactStylesDiffMap
import com.wix.detox.common.DetoxErrors.DetoxIllegalStateException
import com.wix.detox.espresso.action.common.ReflectUtils
import com.facebook.react.views.slider.ReactSlider
import org.joor.Reflect

private const val CLASS_REACT_SLIDER_LEGACY = "com.facebook.react.views.slider.ReactSlider"
private const val CLASS_REACT_SLIDER_LEGACY_MANAGER = "com.facebook.react.views.slider.ReactSliderManager"
private const val CLASS_REACT_SLIDER_COMMUNITY = "com.reactnativecommunity.slider.ReactSlider"
private const val CLASS_REACT_SLIDER_COMMUNITY_MANAGER = "com.reactnativecommunity.slider.ReactSliderManager"

Expand Down Expand Up @@ -50,7 +50,7 @@ abstract class ReactSliderHelper(protected val slider: AppCompatSeekBar) {
fun maybeCreate(view: View): ReactSliderHelper? =
when {
ReflectUtils.isAssignableFrom(view, CLASS_REACT_SLIDER_LEGACY)
-> LegacySliderHelper(view as ReactSlider)
-> LegacySliderHelper(view as AppCompatSeekBar)
ReflectUtils.isAssignableFrom(view, CLASS_REACT_SLIDER_COMMUNITY)
-> CommunitySliderHelper(view as AppCompatSeekBar)
else
Expand All @@ -59,10 +59,10 @@ abstract class ReactSliderHelper(protected val slider: AppCompatSeekBar) {
}
}

private class LegacySliderHelper(slider: ReactSlider): ReactSliderHelper(slider) {
private class LegacySliderHelper(slider: AppCompatSeekBar): ReactSliderHelper(slider) {
override fun setProgressJS(valueJS: Double) {
val reactSliderManager = com.facebook.react.views.slider.ReactSliderManager()
reactSliderManager.updateProperties(slider as ReactSlider, buildStyles("value", valueJS))
val reactSliderManager = Class.forName(CLASS_REACT_SLIDER_LEGACY_MANAGER).newInstance()
Reflect.on(reactSliderManager).call("updateProperties", slider, buildStyles("value", valueJS))
}

private fun buildStyles(vararg keysAndValues: Any) = ReactStylesDiffMap(JavaOnlyMap.of(*keysAndValues))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import android.view.View
import android.widget.CheckBox
import android.widget.ProgressBar
import android.widget.TextView
import com.facebook.react.views.slider.ReactSlider
import com.google.android.material.slider.Slider
import com.wix.detox.reactnative.ui.getAccessibilityLabel
import org.assertj.core.api.Assertions.assertThat
Expand Down Expand Up @@ -190,7 +189,8 @@ class GetAttributesActionTest {
assertThat(resultJson.opt("value")).isEqualTo(42)
}

@Test
//FIXME: Complete the integration over RN72 or delete this test
/* @Test
fun `should return RN-Slider via value attribute`() {
val progressBar: ReactSlider = mock {
on { max } doReturn 100
Expand All @@ -199,7 +199,7 @@ class GetAttributesActionTest {

val resultJson = perform(progressBar)
assertThat(resultJson.opt("value")).isEqualTo(0.5)
}
}*/

@Test
fun `should return material-Slider state through value attribute`() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.wix.detox.espresso.common

import com.facebook.react.views.slider.ReactSlider
//import com.facebook.react.views.slider.ReactSlider
import org.assertj.core.api.Assertions.assertThat
import org.junit.Before
import org.junit.Test
Expand All @@ -14,26 +14,28 @@ import org.robolectric.RobolectricTestRunner
* Note: This only tests against the react *legacy* (non-community) slider in order
* to avoid having to install the community slider under node_modules just for this.
*/
@RunWith(RobolectricTestRunner::class)
class ReactSliderHelperTest {
lateinit var slider: ReactSlider
lateinit var uut: ReactSliderHelper

@Before
fun setup() {
slider = mock()
uut = ReactSliderHelper.create(slider)
}

private fun givenNativeProgressTraits(current: Int, max: Int) {
whenever(slider.progress).doReturn(current)
whenever(slider.max).doReturn(max)
}

@Test
fun `should properly calculate current progress, in percentage`() {
givenNativeProgressTraits(current = 20, max = 100)

assertThat(uut.getCurrentProgressPct()).isEqualTo(0.2)
}
}
// FIXME: RN72 upgrade - this test is broken
//@RunWith(RobolectricTestRunner::class)
//class ReactSliderHelperTest {
// lateinit var slider: ReactSlider
// lateinit var uut: ReactSliderHelper
//
// @Before
// fun setup() {
// slider = mock()
// uut = ReactSliderHelper.create(slider)
// }
//
// private fun givenNativeProgressTraits(current: Int, max: Int) {
// whenever(slider.progress).doReturn(current)
// whenever(slider.max).doReturn(max)
// }
//
// @Test
// fun `should properly calculate current progress, in percentage`() {
// givenNativeProgressTraits(current = 20, max = 100)
//
// assertThat(uut.getCurrentProgressPct()).isEqualTo(0.2)
// }
//}
42 changes: 27 additions & 15 deletions detox/android/rninfo.gradle
Original file line number Diff line number Diff line change
@@ -1,25 +1,37 @@
import groovy.json.JsonSlurper

def rnVersion = getRNVersion(project.rootDir)
def rnMajorVer = getMajorVersion(rnVersion)
println "[$project] RNInfo: detected React Native version: $rnVersion (major=$rnMajorVer)"

project.ext.rnInfo = [
version: rnVersion,
majorVersion: rnMajorVer,
isRN69OrHigher: rnMajorVer >= 69,
isRN70OrHigher: rnMajorVer >= 70,
isRN71OrHigher: rnMajorVer >= 71,
]

private static def getRNVersion(workingDir) {
def getRNVersion = { workingDir ->
println("RNInfo: workingDir=$workingDir")
def jsonSlurper = new JsonSlurper()
Map<String, Object> packageJSON = jsonSlurper.parse(new File("$workingDir/../node_modules/react-native/package.json"))
def packageFile = "$workingDir/../node_modules/react-native/package.json"
println("RNInfo: reading $packageFile")
Map<String, Object> packageJSON = jsonSlurper.parse(new File(packageFile))
String rnVersion = packageJSON.get('version')
return rnVersion
}

private static def getMajorVersion(semanticVersion) {
def getMajorVersionInternal = { semanticVersion ->
Integer rnVersionMajor = semanticVersion.split('\\.')[1].toInteger()
return rnVersionMajor
}

ext.getRnMajorVersion = { workingDir ->
gosha212 marked this conversation as resolved.
Show resolved Hide resolved
String rnVersion = getRNVersion(workingDir)
Integer rnVersionMajor = getMajorVersionInternal(rnVersion)
return rnVersionMajor
}

def rnVersion = getRNVersion(rootDir)
def rnMajorVer = getMajorVersionInternal(rnVersion)
if (hasProperty('project')) {
println "[$project] RNInfo: detected React Native version: $rnVersion (major=$rnMajorVer)"

project.ext.rnInfo = [
version : rnVersion,
majorVersion : rnMajorVer,
isRN69OrHigher: rnMajorVer >= 69,
isRN70OrHigher: rnMajorVer >= 70,
isRN71OrHigher: rnMajorVer >= 71,
isRN72OrHigher: rnMajorVer >= 72,
]
}
14 changes: 13 additions & 1 deletion detox/android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,2 +1,14 @@
apply from: '../android/rninfo.gradle'
include ':detox'
includeBuild('../node_modules/react-native-gradle-plugin')

println("RNInfo: rootDir=$rootDir")

def rnMajorVer = getRnMajorVersion(rootDir)
println "[settings] RNInfo: detected React Native version: (major=$rnMajorVer)"

if (rnMajorVer < 72) {
includeBuild('../node_modules/react-native-gradle-plugin')
} else {
includeBuild('../node_modules/@react-native/gradle-plugin')
}

10 changes: 7 additions & 3 deletions detox/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@
"jest": "^29.0.0",
"jest-allure2-reporter": "^2.0.0-beta.4",
"prettier": "^3.1.1",
"react-native": "0.71.10",
"react-native": "0.72.8",
"@react-native/eslint-config": "^0.72.2",
"@react-native/metro-config": "^0.72.11",
"metro-react-native-babel-preset": "0.76.8",
"@tsconfig/react-native": "^3.0.0",
"react-native-codegen": "^0.0.8",
"typescript": "^5.3.3",
"wtfnode": "^0.9.1"
Expand Down Expand Up @@ -104,9 +108,9 @@
}
},
"engines": {
"node": ">=14.14.0"
"node": ">=16"
},
"browserslist": [
"node 14"
"node 16"
]
}
2 changes: 1 addition & 1 deletion detox/test/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = {
root: true,
extends: [
'@react-native-community',
'@react-native',
],
plugins: [
'unicorn',
Expand All @@ -18,7 +18,7 @@

'@typescript-eslint/no-unused-vars': ['error', {argsIgnorePattern: '^_'}],

// TODO: enable these rules gradually

Check warning on line 21 in detox/test/.eslintrc.js

View workflow job for this annotation

GitHub Actions / Linux

Unexpected 'todo' comment without any conditions: 'TODO: enable these rules gradually'

Check warning on line 21 in detox/test/.eslintrc.js

View workflow job for this annotation

GitHub Actions / Linux

Unexpected 'todo' comment without any conditions: 'TODO: enable these rules gradually'
'comma-dangle': 0,
'curly': 0,
'eol-last': 0,
Expand Down
12 changes: 11 additions & 1 deletion detox/test/android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
apply from: file("../../android/rninfo.gradle")
rootProject.name = 'DetoxTest'
include ':app'

includeBuild('../node_modules/react-native-gradle-plugin')
def rnMajorVer = getRnMajorVersion(rootDir)
println "[settings] RNInfo: detected React Native version: (major=$rnMajorVer)"

if (rnMajorVer < 72) {
includeBuild('../node_modules/react-native-gradle-plugin')
} else {
includeBuild('../node_modules/@react-native/gradle-plugin')
}



include ':detox'
project(':detox').projectDir = new File(rootProject.projectDir, '../../android/detox')
Expand Down
3 changes: 2 additions & 1 deletion detox/test/e2e/03.actions.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const driver = require('./drivers/actions-driver').actionsScreenDriver;
const custom = require('./utils/custom-it');

describe('Actions', () => {
beforeEach(async () => {
Expand Down Expand Up @@ -81,7 +82,7 @@
});
});

it.skip(':android: should throw if tap handling is too slow', async () => {

Check warning on line 85 in detox/test/e2e/03.actions.test.js

View workflow job for this annotation

GitHub Actions / Linux

Disabled test

Check warning on line 85 in detox/test/e2e/03.actions.test.js

View workflow job for this annotation

GitHub Actions / Linux

Disabled test
try {
await driver.sluggishTapElement.tap();
} catch (e) {
Expand Down Expand Up @@ -212,7 +213,7 @@
await expect(element(by.id('UniqueId007'))).toBeVisible();
});

it('should adjust legacy slider and assert its value', async () => {
custom.it.skipFromRNVersion(71)('should adjust legacy slider and assert its value', async () => {
const reactSliderId = 'legacySliderWithASimpleID';
await expect(element(by.id(reactSliderId))).toHaveSliderPosition(0.25);
await element(by.id(reactSliderId)).adjustSliderToPosition(0.75);
Expand Down
Loading
Loading