Skip to content

Commit cf40320

Browse files
committed
Skip Gradle tests by default and enable it on CI
1 parent c6a7d68 commit cf40320

File tree

3 files changed

+54
-46
lines changed

3 files changed

+54
-46
lines changed

.github/workflows/check.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ name: Check
33
env:
44
# Version here should match the one in React Native template and packages/cmake-rn/src/cli.ts
55
NDK_VERSION: 27.1.12297006
6+
# Enabling the Gradle test on CI (disabled by default because it downloads a lot)
7+
ENABLE_GRADLE_TESTS: true
68

79
on:
810
push:

packages/host/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
"build-weak-node-api": "cmake-rn --no-auto-link --no-weak-node-api-linkage --xcframework-extension --source ./weak-node-api --out ./weak-node-api",
4848
"build-weak-node-api:all-triplets": "cmake-rn --android --apple --no-auto-link --no-weak-node-api-linkage --xcframework-extension --source ./weak-node-api --out ./weak-node-api",
4949
"test": "tsx --test --test-reporter=@reporters/github --test-reporter-destination=stdout --test-reporter=spec --test-reporter-destination=stdout src/node/**/*.test.ts src/node/*.test.ts",
50+
"test:gradle": "ENABLE_GRADLE_TESTS=true node --run test",
5051
"bootstrap": "node --run copy-node-api-headers && node --run generate-weak-node-api-injector && node --run generate-weak-node-api && node --run build-weak-node-api",
5152
"prerelease": "node --run copy-node-api-headers && node --run generate-weak-node-api-injector && node --run generate-weak-node-api && node --run build-weak-node-api:all-triplets"
5253
},

packages/host/src/node/gradle.test.ts

Lines changed: 51 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -7,55 +7,60 @@ const PACKAGE_ROOT = path.join(__dirname, "../..");
77
const MONOREPO_ROOT = path.join(PACKAGE_ROOT, "../..");
88
const TEST_APP_ANDROID_PATH = path.join(MONOREPO_ROOT, "apps/test-app/android");
99

10-
describe("Gradle tasks", () => {
11-
describe("checkHermesOverride task", () => {
12-
it("should fail if REACT_NATIVE_OVERRIDE_HERMES_DIR is not set", () => {
13-
const { status, stdout, stderr } = cp.spawnSync(
14-
"sh",
15-
["gradlew", "react-native-node-api:checkHermesOverride"],
16-
{
17-
cwd: TEST_APP_ANDROID_PATH,
18-
env: {
19-
...process.env,
20-
REACT_NATIVE_OVERRIDE_HERMES_DIR: undefined,
10+
describe(
11+
"Gradle tasks",
12+
// Skipping these tests by default, as they download a lot and takes a long time
13+
{ skip: process.env.ENABLE_GRADLE_TESTS !== "true" },
14+
() => {
15+
describe("checkHermesOverride task", () => {
16+
it("should fail if REACT_NATIVE_OVERRIDE_HERMES_DIR is not set", () => {
17+
const { status, stdout, stderr } = cp.spawnSync(
18+
"sh",
19+
["gradlew", "react-native-node-api:checkHermesOverride"],
20+
{
21+
cwd: TEST_APP_ANDROID_PATH,
22+
env: {
23+
...process.env,
24+
REACT_NATIVE_OVERRIDE_HERMES_DIR: undefined,
25+
},
26+
encoding: "utf-8",
2127
},
22-
encoding: "utf-8",
23-
},
24-
);
28+
);
2529

26-
assert.notEqual(status, 0, `Expected failure: ${stdout} ${stderr}`);
27-
assert.match(
28-
stderr,
29-
/React Native Node-API needs a custom version of Hermes with Node-API enabled/,
30-
);
31-
assert.match(
32-
stderr,
33-
/Run the following in your terminal, to clone Hermes and instruct React Native to use it/,
34-
);
35-
assert.match(
36-
stderr,
37-
/export REACT_NATIVE_OVERRIDE_HERMES_DIR=`npx react-native-node-api vendor-hermes --silent --force`/,
38-
);
39-
assert.match(
40-
stderr,
41-
/And follow this guide to build React Native from source/,
42-
);
30+
assert.notEqual(status, 0, `Expected failure: ${stdout} ${stderr}`);
31+
assert.match(
32+
stderr,
33+
/React Native Node-API needs a custom version of Hermes with Node-API enabled/,
34+
);
35+
assert.match(
36+
stderr,
37+
/Run the following in your terminal, to clone Hermes and instruct React Native to use it/,
38+
);
39+
assert.match(
40+
stderr,
41+
/export REACT_NATIVE_OVERRIDE_HERMES_DIR=`npx react-native-node-api vendor-hermes --silent --force`/,
42+
);
43+
assert.match(
44+
stderr,
45+
/And follow this guide to build React Native from source/,
46+
);
47+
});
4348
});
44-
});
4549

46-
describe("linkNodeApiModules task", () => {
47-
it("should call the CLI to autolink", () => {
48-
const { status, stdout, stderr } = cp.spawnSync(
49-
"sh",
50-
["gradlew", "react-native-node-api:linkNodeApiModules"],
51-
{
52-
cwd: TEST_APP_ANDROID_PATH,
53-
encoding: "utf-8",
54-
},
55-
);
50+
describe("linkNodeApiModules task", () => {
51+
it("should call the CLI to autolink", () => {
52+
const { status, stdout, stderr } = cp.spawnSync(
53+
"sh",
54+
["gradlew", "react-native-node-api:linkNodeApiModules"],
55+
{
56+
cwd: TEST_APP_ANDROID_PATH,
57+
encoding: "utf-8",
58+
},
59+
);
5660

57-
assert.equal(status, 0, `Expected failure: ${stdout} ${stderr}`);
58-
assert.match(stdout, /Auto-linking Node-API modules/);
61+
assert.equal(status, 0, `Expected failure: ${stdout} ${stderr}`);
62+
assert.match(stdout, /Auto-linking Node-API modules/);
63+
});
5964
});
60-
});
61-
});
65+
},
66+
);

0 commit comments

Comments
 (0)