Skip to content

Commit 280bd6f

Browse files
committed
integration test on Windows CI
1 parent 47b1489 commit 280bd6f

File tree

4 files changed

+38
-8
lines changed

4 files changed

+38
-8
lines changed

.github/workflows/check.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,34 @@ jobs:
4141
- run: npm run build
4242
- run: npm test --workspace gyp-to-cmake --workspace react-native-node-api-cmake --workspace react-native-node-api-modules
4343

44+
test-windows-addon-examples:
45+
name: Run addon examples on Windows
46+
runs-on: windows-latest
47+
steps:
48+
- uses: actions/checkout@v4
49+
- uses: actions/setup-node@v4
50+
with:
51+
node-version: lts/jod
52+
- name: Set up JDK 17
53+
uses: actions/setup-java@v3
54+
with:
55+
java-version: "17"
56+
distribution: "temurin"
57+
- name: Setup Android SDK
58+
uses: android-actions/setup-android@v3
59+
# Version here should match the one in React Native template and packages/react-native-node-api-cmake/src/cli.ts
60+
- run: sdkmanager --install "ndk;27.1.12297006"
61+
- name: Install LLVM and Clang
62+
uses: KyleMayes/install-llvm-action@v2
63+
with:
64+
version: "18.1"
65+
- run: npm ci
66+
- run: npm run build
67+
- run: npm run copy-node-api-headers --workspace react-native-node-api-modules
68+
- run: npm run build-weak-node-api --workspace react-native-node-api-modules
69+
- run: npm run generate-weak-node-api-injector --workspace react-native-node-api-modules
70+
- run: npm test --workspace react-native-node-addon-examples
71+
4472
test-macos:
4573
name: Run tests which requires MacOS
4674
runs-on: macos-latest

packages/react-native-node-api-modules/scripts/generate-weak-node-api-injector.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import fs from "node:fs";
22
import path from "node:path";
3-
import cp from "node:child_process";
3+
import { spawnSyncCrossPlatform } from "./platform-utils.js";
44

55
import { FunctionDecl, getNodeApiFunctions } from "./node-api-functions";
66

@@ -20,6 +20,8 @@ export function generateSource(functions: FunctionDecl[]) {
2020
#define WEAK_NODE_API_LIBRARY_NAME "@rpath/weak-node-api.framework/weak-node-api"
2121
#elif defined(__ANDROID__)
2222
#define WEAK_NODE_API_LIBRARY_NAME "libweak-node-api.so"
23+
#elif defined(_WIN32)
24+
#define WEAK_NODE_API_LIBRARY_NAME "weak-node-api.dll"
2325
#else
2426
#error "WEAK_NODE_API_LIBRARY_NAME cannot be defined for this platform"
2527
#endif
@@ -58,7 +60,7 @@ async function run() {
5860
const source = generateSource(nodeApiFunctions);
5961
const sourcePath = path.join(CPP_SOURCE_PATH, "WeakNodeApiInjector.cpp");
6062
await fs.promises.writeFile(sourcePath, source, "utf-8");
61-
cp.spawnSync("clang-format", ["-i", sourcePath], { stdio: "inherit" });
63+
spawnSyncCrossPlatform("clang-format", ["-i", sourcePath], { stdio: "inherit" });
6264
}
6365

6466
run().catch((err) => {

packages/react-native-node-api-modules/scripts/generate-weak-node-api.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import fs from "node:fs";
22
import path from "node:path";
3-
import cp from "node:child_process";
3+
import { spawnSyncCrossPlatform } from "./platform-utils.js";
44

55
import { FunctionDecl, getNodeApiFunctions } from "./node-api-functions";
66

@@ -74,12 +74,12 @@ async function run() {
7474
const header = generateHeader(nodeApiFunctions);
7575
const headerPath = path.join(WEAK_NODE_API_PATH, "weak_node_api.hpp");
7676
await fs.promises.writeFile(headerPath, header, "utf-8");
77-
cp.spawnSync("clang-format", ["-i", headerPath], { stdio: "inherit" });
77+
spawnSyncCrossPlatform("clang-format", ["-i", headerPath], { stdio: "inherit" });
7878

7979
const source = generateSource(nodeApiFunctions);
8080
const sourcePath = path.join(WEAK_NODE_API_PATH, "weak_node_api.cpp");
8181
await fs.promises.writeFile(sourcePath, source, "utf-8");
82-
cp.spawnSync("clang-format", ["-i", sourcePath], { stdio: "inherit" });
82+
spawnSyncCrossPlatform("clang-format", ["-i", sourcePath], { stdio: "inherit" });
8383
}
8484

8585
run().catch((err) => {

packages/react-native-node-api-modules/scripts/node-api-functions.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import assert from "node:assert/strict";
22
import path from "node:path";
3-
import cp from "node:child_process";
3+
import { execFileSyncCrossPlatform } from "./platform-utils.js";
44

55
import {
66
type NodeApiVersion,
@@ -29,7 +29,7 @@ const clangAstDump = z.object({
2929
* @param version
3030
*/
3131
export function getNodeApiHeaderAST(version: NodeApiVersion) {
32-
const output = cp.execFileSync(
32+
const output = execFileSyncCrossPlatform(
3333
"clang",
3434
[
3535
// Declare the Node API version
@@ -50,7 +50,7 @@ export function getNodeApiHeaderAST(version: NodeApiVersion) {
5050
// Emitting the AST can produce a lot of output
5151
maxBuffer: 1024 * 1024 * 10,
5252
}
53-
);
53+
) as string;
5454
const parsed = JSON.parse(output);
5555
return clangAstDump.parse(parsed);
5656
}

0 commit comments

Comments
 (0)