Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
10 changes: 5 additions & 5 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ See the [README.md](../README.md#packages) for detailed descriptions of each pac
### Development Setup

```bash
npm ci && npm run build # Install deps and build all packages
npm run bootstrap # Build native components (weak-node-api, examples)
pnpm install && pnpm run build # Install deps and build all packages
pnpm run bootstrap # Build native components (weak-node-api, examples)
```

### Package Development

- **TypeScript project references**: Use `tsc --build` for incremental compilation
- **Workspace scripts**: Most build/test commands use npm workspaces (`--workspace` flag)
- **Workspace scripts**: Most build/test commands use pnpm workspaces (`--filter` flag), run in topological (dependency) order and fail fast
- **Focus on Node.js packages**: AI development primarily targets the Node.js tooling packages rather than native mobile code
- **No TypeScript type asserts**: You have to ask explicitly and justify if you want to add `as` type assertions.

Expand Down Expand Up @@ -70,8 +70,8 @@ Library names use double-dash separation: `package-name--path-component--addon-n

### Testing

- **Individual packages**: Some packages have VS Code test tasks and others have their own `npm test` scripts for focused iteration (e.g., `npm test --workspace cmake-rn`). Use the latter only if the former is missing.
- **Cross-package**: Use root-level `npm test` for cross-package testing once individual package tests pass
- **Individual packages**: Some packages have VS Code test tasks and others have their own test scripts for focused iteration (e.g., `pnpm --filter cmake-rn run test`). Use the latter only if the former is missing.
- **Cross-package**: Use root-level `pnpm test` for cross-package testing once individual package tests pass
- **Mobile integration**: Available but not the primary AI development focus - ask the developer to run those tests as needed

**Documentation**: Integration details, platform setup, and toolchain configuration are covered in existing repo documentation files.
87 changes: 54 additions & 33 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ env:
NDK_VERSION: 27.1.12297006
# Enabling the Gradle test on CI (disabled by default because it downloads a lot)
ENABLE_GRADLE_TESTS: true
# pnpm records GitHub git dependencies (e.g. node-addon-examples) with an SSH
# repo URL, which anonymous CI runners can't clone. Rewrite git@github.com: to
# HTTPS so the public repo is fetched over HTTPS. Provided as ad-hoc git config
# via env so it applies to every job without a per-job step.
GIT_CONFIG_COUNT: 1
GIT_CONFIG_KEY_0: "url.https://github.com/.insteadOf"
GIT_CONFIG_VALUE_0: "git@github.com:"

on:
push:
Expand All @@ -24,9 +31,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v6
with:
node-version: lts/krypton
cache: pnpm
- name: Setup cpp tools
uses: aminya/setup-cpp@v1
with:
Expand All @@ -47,18 +56,18 @@ jobs:
with:
packages: tools platform-tools ndk;${{ env.NDK_VERSION }}
- run: rustup target add x86_64-linux-android
- run: npm ci
- run: npm run build
- run: pnpm install
- run: pnpm run build
# Bootstrap weak-node-api and ferric-example to get types
# TODO: Solve this by adding an option to ferric to build only types or by committing the types into the repo as a fixture for an "init" command
- run: npm run bootstrap --workspace weak-node-api
- run: npm run bootstrap --workspace @react-native-node-api/ferric-example
- run: npm run lint
- run: pnpm --filter weak-node-api run bootstrap
- run: pnpm --filter @react-native-node-api/ferric-example run bootstrap
- run: pnpm run lint
env:
DEBUG: eslint:eslint
- run: npm run prettier:check
- run: npm run depcheck
- run: npm run publint
- run: pnpm run prettier:check
- run: pnpm run depcheck
- run: pnpm run publint
unit-tests:
strategy:
fail-fast: false
Expand All @@ -71,9 +80,11 @@ jobs:
name: Unit tests (${{ matrix.runner }})
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v6
with:
node-version: lts/krypton
cache: pnpm
- name: Setup cpp tools
uses: aminya/setup-cpp@v1
with:
Expand All @@ -92,9 +103,9 @@ jobs:
with:
packages: tools platform-tools ndk;${{ env.NDK_VERSION }}
- run: rustup target add x86_64-linux-android aarch64-linux-android armv7-linux-androideabi i686-linux-android aarch64-apple-ios-sim
- run: npm ci
- run: npm run bootstrap
- run: npm test
- run: pnpm install
- run: pnpm run bootstrap
- run: pnpm test
weak-node-api-tests:
if: github.ref == 'refs/heads/main' || contains(github.event.pull_request.labels.*.name, 'weak-node-api')
strategy:
Expand All @@ -108,9 +119,11 @@ jobs:
name: Weak Node-API tests (${{ matrix.runner }})
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v6
with:
node-version: lts/krypton
cache: pnpm
- name: Setup cpp tools
uses: aminya/setup-cpp@v1
with:
Expand All @@ -119,10 +132,10 @@ jobs:
uses: hendrikmuhs/ccache-action@v1.2
with:
key: ${{ github.job }}-${{ runner.os }}
- run: npm ci
- run: npm run build
- run: pnpm install
- run: pnpm run build
- name: Prepare weak-node-api
run: npm run prebuild:prepare --workspace weak-node-api
run: pnpm --filter weak-node-api run prebuild:prepare
- name: Build and run weak-node-api C++ tests
run: |
cmake -S . -B build -DBUILD_TESTS=ON
Expand All @@ -135,9 +148,11 @@ jobs:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v6
with:
node-version: lts/krypton
cache: pnpm
- name: Setup cpp tools
uses: aminya/setup-cpp@v1
with:
Expand All @@ -156,17 +171,17 @@ jobs:
with:
packages: tools platform-tools ndk;${{ env.NDK_VERSION }}
- run: rustup target add x86_64-linux-android aarch64-linux-android armv7-linux-androideabi i686-linux-android aarch64-apple-ios-sim
- run: npm ci
- run: npm run bootstrap
- run: pnpm install
- run: pnpm run bootstrap
env:
CMAKE_RN_TRIPLETS: arm64;x86_64-apple-ios-sim
FERRIC_TARGETS: aarch64-apple-ios-sim
- run: npm run pod-install
- run: pnpm run pod-install
working-directory: apps/test-app
- name: Run tests (iOS)
run: npm run test:ios:allTests
run: pnpm run test:ios:allTests
# TODO: Enable release mode when it works
# run: npm run test:ios:allTests -- --mode Release
# run: pnpm run test:ios:allTests -- --mode Release
working-directory: apps/test-app
test-macos:
# Disabling this on main for now, as initializing the template takes a long time and
Expand All @@ -176,9 +191,11 @@ jobs:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v6
with:
node-version: lts/krypton
cache: pnpm
- name: Setup cpp tools
uses: aminya/setup-cpp@v1
with:
Expand All @@ -193,12 +210,12 @@ jobs:
java-version: "17"
distribution: "temurin"
- run: rustup target add x86_64-apple-darwin
- run: npm ci
- run: npm run bootstrap
- run: pnpm install
- run: pnpm run bootstrap
env:
CMAKE_RN_TRIPLETS: arm64;x86_64-apple-darwin
FERRIC_TARGETS: aarch64-apple-darwin,x86_64-apple-darwin
- run: npm run init-macos-test-app
- run: pnpm run init-macos-test-app
- run: pod install --project-directory=macos
working-directory: apps/macos-test-app
- name: Bundle test app
Expand All @@ -222,9 +239,11 @@ jobs:
runs-on: ubuntu-self-hosted
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v6
with:
node-version: lts/krypton
cache: pnpm
- name: Setup cpp tools
uses: aminya/setup-cpp@v1
with:
Expand All @@ -243,15 +262,15 @@ jobs:
with:
packages: tools platform-tools ndk;${{ env.NDK_VERSION }} cmake;${{ env.CMAKE_VERSION }}
- run: rustup target add x86_64-linux-android aarch64-linux-android armv7-linux-androideabi i686-linux-android aarch64-apple-ios-sim
- run: npm ci
- run: npm run bootstrap
- run: pnpm install
- run: pnpm run bootstrap
env:
CMAKE_RN_TRIPLETS: x86_64-linux-android
FERRIC_TARGETS: x86_64-linux-android
- name: Clone patched Hermes version
shell: bash
run: |
REACT_NATIVE_OVERRIDE_HERMES_DIR=$(npx react-native-node-api vendor-hermes --silent)
REACT_NATIVE_OVERRIDE_HERMES_DIR=$(pnpm exec react-native-node-api vendor-hermes --silent)
echo "REACT_NATIVE_OVERRIDE_HERMES_DIR=$REACT_NATIVE_OVERRIDE_HERMES_DIR" >> $GITHUB_ENV
working-directory: apps/test-app
# - name: Setup Android Emulator cache
Expand All @@ -269,9 +288,9 @@ jobs:
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
- name: Build weak-node-api for all Android architectures
run: npm run prebuild:build:android --workspace weak-node-api
run: pnpm --filter weak-node-api run prebuild:build:android
- name: Build ferric-example for all architectures
run: npm run build -- --android
run: pnpm run build -- --android
working-directory: packages/ferric-example
- name: Run tests (Android)
timeout-minutes: 75
Expand All @@ -293,7 +312,7 @@ jobs:
adb logcat > emulator-logcat.txt 2>&1 &
LOGCAT_PID=$!
# Build, install and run the app
npm run test:android:allTests -- --mode Release
pnpm run test:android:allTests -- --mode Release
# Wait a bit for the sub-process to terminate, before terminating the emulator
sleep 5
# Stop logcat
Expand All @@ -310,9 +329,11 @@ jobs:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v6
with:
node-version: lts/krypton
cache: pnpm
- name: Setup cpp tools
uses: aminya/setup-cpp@v1
with:
Expand All @@ -328,14 +349,14 @@ jobs:
distribution: "temurin"
- run: rustup target add x86_64-apple-darwin x86_64-apple-ios aarch64-apple-ios aarch64-apple-ios-sim
- run: rustup toolchain install nightly --component rust-src
- run: npm ci
- run: npm run build
- run: pnpm install
- run: pnpm run build
- name: Build weak-node-api for all Apple architectures
run: |
npm run prebuild:prepare --workspace weak-node-api
npm run prebuild:build:apple --workspace weak-node-api
pnpm --filter weak-node-api run prebuild:prepare
pnpm --filter weak-node-api run prebuild:build:apple
# Build Ferric example for all Apple architectures
- run: npx ferric --apple
- run: pnpm exec ferric --apple
working-directory: packages/ferric-example
- name: Inspect the structure of the prebuilt binary
run: lipo -info ferric_example.apple.node/*/libferric_example.framework/libferric_example > lipo-info.txt
Expand Down
12 changes: 10 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ name: Release
env:
# Version here should match the one in React Native template and packages/cmake-rn/src/cli.ts
NDK_VERSION: 27.1.12297006
# pnpm records GitHub git dependencies (e.g. node-addon-examples) with an SSH
# repo URL, which anonymous CI runners can't clone. Rewrite git@github.com: to
# HTTPS so the public repo is fetched over HTTPS.
GIT_CONFIG_COUNT: 1
GIT_CONFIG_KEY_0: "url.https://github.com/.insteadOf"
GIT_CONFIG_VALUE_0: "git@github.com:"

on:
push:
Expand All @@ -18,9 +24,11 @@ jobs:
environment: main
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v6
with:
node-version: lts/krypton
cache: pnpm
- name: Setup cpp tools
uses: aminya/setup-cpp@v1
with:
Expand All @@ -39,12 +47,12 @@ jobs:
with:
packages: tools platform-tools ndk;${{ env.NDK_VERSION }}
- run: rustup target add x86_64-linux-android aarch64-linux-android armv7-linux-androideabi i686-linux-android aarch64-apple-ios-sim
- run: npm install
- run: pnpm install

- name: Create Release Pull Request or Publish to NPM
id: changesets
uses: changesets/action@v1
with:
publish: npm run release
publish: pnpm run release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ Pods
target
.cxx

# Ignore the pnpm lockfile (managed by pnpm, not formatted by Prettier)
pnpm-lock.yaml

# Ignore hermes
packages/host/hermes
packages/node-addon-examples/examples
Expand Down
10 changes: 5 additions & 5 deletions apps/test-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
"@react-native-community/cli": "^20.0.2",
"@react-native-community/cli-platform-android": "^20.0.2",
"@react-native-community/cli-platform-ios": "^20.0.2",
"@react-native-node-api/ferric-example": "*",
"@react-native-node-api/node-addon-examples": "*",
"@react-native-node-api/node-tests": "*",
"@react-native-node-api/ferric-example": "workspace:*",
"@react-native-node-api/node-addon-examples": "workspace:*",
"@react-native-node-api/node-tests": "workspace:*",
"@react-native/babel-preset": "0.81.4",
"@react-native/metro-config": "0.81.4",
"@react-native/typescript-config": "0.81.4",
Expand All @@ -42,8 +42,8 @@
"mocha-remote-react-native": "^1.13.2",
"react": "19.1.0",
"react-native": "0.81.4",
"react-native-node-api": "*",
"react-native-node-api": "workspace:*",
"react-native-test-app": "^4.4.7",
"weak-node-api": "*"
"weak-node-api": "workspace:*"
}
}
Loading
Loading