fix: various napi build fix#1667
Conversation
|
Warning Rate limit exceeded@HerringtonDarkholme has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 17 minutes and 31 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (1)
WalkthroughThis pull request focuses on enhancing the build and type generation workflow for the NAPI (Node-API) package. The changes include expanding the GitHub Actions workflow to support multiple build targets across macOS, Windows, and Linux architectures. Additionally, the type generation script for the NAPI package has been modified to change how language node types are exported, and the Changes
Sequence DiagramsequenceDiagram
participant GHA as GitHub Actions
participant Build as Build Job
participant Publish as Publish Job
GHA->>Build: Trigger build matrix
Build->>Build: Build for multiple architectures
alt Build Successful
Build-->>Publish: Trigger publish
Publish->>Publish: Prepare artifacts
else Build Failed
Build--xPublish: Halt publication
end
Possibly related PRs
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
.github/workflows/napi.yml (1)
62-77: Consider adding tests for ARM64 buildsThe ARM64 builds (aarch64-unknown-linux-musl and aarch64-unknown-linux-gnu) don't include test execution. While cross-architecture testing can be challenging, consider adding tests if possible.
Options to consider:
- Use QEMU for ARM64 emulation during tests
- Set up dedicated ARM64 runners
- Add architecture-specific test skip logic
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
.github/workflows/napi.yml(2 hunks)crates/napi/package.json(1 hunks)crates/napi/scripts/generateTypes.ts(1 hunks)
🧰 Additional context used
📓 Learnings (1)
crates/napi/scripts/generateTypes.ts (2)
Learnt from: HerringtonDarkholme
PR: ast-grep/ast-grep#1662
File: crates/napi/scripts/generate-types.ts:49-49
Timestamp: 2024-12-14T18:57:37.142Z
Learning: In `crates/napi/scripts/generate-types.ts`, it's expected to assign the output of `JSON.stringify(nodeTypeMap, null, 2)` directly to a TypeScript type alias using `export type` syntax.
Learnt from: HerringtonDarkholme
PR: ast-grep/ast-grep#1662
File: crates/napi/scripts/generate-types.ts:128-129
Timestamp: 2024-12-14T18:57:47.685Z
Learning: In `crates/napi/scripts/generate-types.ts`, when re-exporting modules that only export types (e.g., `./types/${lang}-node-types`), use `export type { ... }` to correctly re-export the types in TypeScript.
🔇 Additional comments (5)
crates/napi/scripts/generateTypes.ts (1)
40-46: Consider impact of default export on type consumers
While the new type export format is cleaner, changing from named exports to default exports might require updates in consuming code. Additionally, consider adding more metadata in the auto-generated comment.
Let's verify the impact on type consumers:
Consider enhancing the auto-generated comment with:
-// This file is auto-generated by ast-grep script
+// This file is auto-generated by ast-grep
+// Generated from tree-sitter grammar version: ${tag}
+// DO NOT EDITcrates/napi/package.json (1)
47-47: LGTM! Script simplified as types are generated in CI
The removal of typegen from prepublishOnly is correct since type generation is now handled in the CI workflow (see .github/workflows/napi.yml).
.github/workflows/napi.yml (3)
53-61: LGTM! Comprehensive musl target configuration
The Linux musl target configuration is well-structured with proper build steps and test execution.
78-83: LGTM! Well-configured Apple Silicon support
The aarch64-apple-darwin target is properly configured with both build and test steps.
25-30: Verify test coverage for macOS x86_64 target
The macOS x86_64 build is missing test execution. Consider adding tests for consistency with other targets.
Let's check if tests are compatible with this target:
✅ Verification successful
Tests can be safely added for macOS x86_64 target
The test suite uses the ava test framework and consists of platform-agnostic tests that verify core functionality like parsing, finding nodes, and code transformations. There are no platform-specific test cases or dependencies that would prevent the tests from running on macOS x86_64. The tests should be added to maintain consistency with other targets and ensure reliability across all supported platforms.
- Add test execution for macOS x86_64 target in
.github/workflows/napi.ymlsimilar to other targets - Example addition:
build: |
yarn build --target x86_64-apple-darwin
strip -x *.node
yarn test🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Check for platform-specific test code
rg -l "process\.platform.*darwin" crates/napi/test/
Length of output: 111
Script:
#!/bin/bash
# Let's first find the test directory structure
fd test --type d
# Then check for any platform-specific test code in all test files
rg -l "process\.platform.*darwin"
Length of output: 131
Script:
#!/bin/bash
# Check test files in the NAPI directory for any platform-specific tests
rg -l "test" crates/napi/__test__/
# Look for any test configuration or setup files
fd -t f . crates/napi/__test__/
# Check if there are any test scripts in package.json
rg "test.*script" package.json
Length of output: 254
Script:
#!/bin/bash
# Let's examine the test file content to understand the test structure
cat crates/napi/__test__/index.spec.ts
# Also check if there's any platform-specific configuration in the test.vue file
cat crates/napi/__test__/test.vue
Length of output: 11552
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1667 +/- ##
=======================================
Coverage 87.13% 87.13%
=======================================
Files 96 96
Lines 15476 15476
=======================================
Hits 13485 13485
Misses 1991 1991 ☔ View full report in Codecov by Sentry. |
Summary by CodeRabbit
New Features
Bug Fixes
prepublishOnlyscript to streamline the publishing process by removing unnecessary commands.Refactor
Chores