From 2311720e28b875f1b64b952d9d185a33cf5f7460 Mon Sep 17 00:00:00 2001 From: Tommy Nguyen <4123478+tido64@users.noreply.github.com> Date: Mon, 31 Jan 2022 11:05:45 +0100 Subject: [PATCH 1/7] fix(android): patch `argument type mismatch` in cli prior to 6.0 --- test-app.gradle | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/test-app.gradle b/test-app.gradle index 27ecfd648..9a3c2f8b4 100644 --- a/test-app.gradle +++ b/test-app.gradle @@ -33,11 +33,23 @@ private static void applySettings(Settings settings) { .projectDir = new File("${projectDir}/android/support") } +// TODO: Remove when `@react-native-community/cli` 6.0+ is required. See also +// https://github.com/react-native-community/cli/commit/fa0d09b2c9be144bbdff526bb14f171d7ddca88e. +private static void patchArgumentTypeMismatchError(String cliAndroidDir) { + def script = new File("${cliAndroidDir}/native_modules.gradle") + def patched = script.text.replace( + "ArrayList>[] packages = this.reactNativeModules", + "ArrayList> packages = this.reactNativeModules", + ) + script.write(patched) +} + def scriptDir = buildscript.sourceFile.getParent() -apply from: "${scriptDir}/android/test-app-util.gradle" +apply(from: "${scriptDir}/android/test-app-util.gradle") def cliAndroidDir = findNodeModulesPath(rootDir, "@react-native-community/cli-platform-android") -apply from: "${cliAndroidDir}/native_modules.gradle" +patchArgumentTypeMismatchError(cliAndroidDir) +apply(from: "${cliAndroidDir}/native_modules.gradle") ext.applyTestAppSettings = { DefaultSettings defaultSettings -> applySettings(defaultSettings) From 0669a5d5cdffae7b0e36fe331535c8a5e1a70898 Mon Sep 17 00:00:00 2001 From: Tommy Nguyen <4123478+tido64@users.noreply.github.com> Date: Mon, 31 Jan 2022 11:25:33 +0100 Subject: [PATCH 2/7] Update test-app.gradle Co-authored-by: Lorenzo Sciandra --- test-app.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test-app.gradle b/test-app.gradle index 9a3c2f8b4..c9158cfcc 100644 --- a/test-app.gradle +++ b/test-app.gradle @@ -34,7 +34,7 @@ private static void applySettings(Settings settings) { } // TODO: Remove when `@react-native-community/cli` 6.0+ is required. See also -// https://github.com/react-native-community/cli/commit/fa0d09b2c9be144bbdff526bb14f171d7ddca88e. +// https://github.com/react-native-community/cli/commit/fa0d09b2c9be144bbdff526bb14f171d7ddca88e private static void patchArgumentTypeMismatchError(String cliAndroidDir) { def script = new File("${cliAndroidDir}/native_modules.gradle") def patched = script.text.replace( From d68fa085cda79dd8ee7d0dd6a182b87f5a17b10f Mon Sep 17 00:00:00 2001 From: Tommy Nguyen <4123478+tido64@users.noreply.github.com> Date: Mon, 31 Jan 2022 13:25:04 +0100 Subject: [PATCH 3/7] bump Java heap space --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 249070ce5..fa7e37a5d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -84,6 +84,7 @@ jobs: - name: JavaScript env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + JVM_ARGS: org.gradle.jvmargs=-Xmx4g -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 run: | # TODO: GITHUB_TOKEN is not set if a PR comes from a forked repo. # Ignore errors until we can create a GitHub PAT from a system From f206631f7bbb446f8300d651fe73921ad4637b23 Mon Sep 17 00:00:00 2001 From: Tommy Nguyen <4123478+tido64@users.noreply.github.com> Date: Mon, 31 Jan 2022 15:21:17 +0100 Subject: [PATCH 4/7] handle file not found --- test-app.gradle | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/test-app.gradle b/test-app.gradle index c9158cfcc..ae63f70ed 100644 --- a/test-app.gradle +++ b/test-app.gradle @@ -37,11 +37,14 @@ private static void applySettings(Settings settings) { // https://github.com/react-native-community/cli/commit/fa0d09b2c9be144bbdff526bb14f171d7ddca88e private static void patchArgumentTypeMismatchError(String cliAndroidDir) { def script = new File("${cliAndroidDir}/native_modules.gradle") - def patched = script.text.replace( - "ArrayList>[] packages = this.reactNativeModules", - "ArrayList> packages = this.reactNativeModules", - ) - script.write(patched) + if (script.exists()) { + def content = script.text + def patched = content.replace( + "ArrayList>[] packages = this.reactNativeModules", + "ArrayList> packages = this.reactNativeModules", + ) + script.write(patched) + } } def scriptDir = buildscript.sourceFile.getParent() From 6401c667b47b0030e7c465bf9e1b28c6d792d74a Mon Sep 17 00:00:00 2001 From: Tommy Nguyen <4123478+tido64@users.noreply.github.com> Date: Mon, 31 Jan 2022 19:05:40 +0100 Subject: [PATCH 5/7] skip Gradle tests on Windows CI --- test/android-test-app/test-app-util.test.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/android-test-app/test-app-util.test.js b/test/android-test-app/test-app-util.test.js index fa9847200..1a62e0d7a 100644 --- a/test/android-test-app/test-app-util.test.js +++ b/test/android-test-app/test-app-util.test.js @@ -47,6 +47,10 @@ describe("test-app-util", () => { removeProject(defaultTestProject); }); + // TODO: Figure out why Windows CI keeps running out of Java heap space. + const test = + process.env["CI"] && require("os").platform() === "win32" ? it.skip : it; + test("getAppName() returns `name` if `displayName` is omitted", async () => { const { status, stdout } = await runGradle({ "app.json": JSON.stringify({ From e134dfe65176aae4bcbaa57b5144b218e1023f3a Mon Sep 17 00:00:00 2001 From: Tommy Nguyen <4123478+tido64@users.noreply.github.com> Date: Mon, 31 Jan 2022 19:05:42 +0100 Subject: [PATCH 6/7] Revert "bump Java heap space" This reverts commit d68fa085cda79dd8ee7d0dd6a182b87f5a17b10f. --- .github/workflows/build.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fa7e37a5d..249070ce5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -84,7 +84,6 @@ jobs: - name: JavaScript env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - JVM_ARGS: org.gradle.jvmargs=-Xmx4g -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 run: | # TODO: GITHUB_TOKEN is not set if a PR comes from a forked repo. # Ignore errors until we can create a GitHub PAT from a system From 88c4bfbb5d359942a6e78122ab88fde987944b1e Mon Sep 17 00:00:00 2001 From: Tommy Nguyen <4123478+tido64@users.noreply.github.com> Date: Mon, 31 Jan 2022 19:15:42 +0100 Subject: [PATCH 7/7] add link to issue --- test/android-test-app/test-app-util.test.js | 1 + 1 file changed, 1 insertion(+) diff --git a/test/android-test-app/test-app-util.test.js b/test/android-test-app/test-app-util.test.js index 1a62e0d7a..36a43507b 100644 --- a/test/android-test-app/test-app-util.test.js +++ b/test/android-test-app/test-app-util.test.js @@ -48,6 +48,7 @@ describe("test-app-util", () => { }); // TODO: Figure out why Windows CI keeps running out of Java heap space. + // https://github.com/microsoft/react-native-test-app/issues/738 const test = process.env["CI"] && require("os").platform() === "win32" ? it.skip : it;