Skip to content

use napi-rs #39

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 21, 2024
Merged

use napi-rs #39

merged 3 commits into from
Sep 21, 2024

Conversation

2bndy5
Copy link
Collaborator

@2bndy5 2bndy5 commented Sep 20, 2024

Initial node binding using napi-rs.

I'm opening this just to test the generated (and customized) CI workflow...

I might have to make this repo a npm workspace project because it is already a cargo workspace.

Summary by CodeRabbit

  • New Features

    • Introduced a new Node.js package for cpp-linter with support for multiple platforms (Darwin, Linux, Windows).
    • Added a comprehensive CI/CD pipeline for building, testing, and publishing the Node.js application.
    • Implemented a dynamic loading mechanism for native bindings based on the operating system.
  • Documentation

    • Added detailed README files for the new Node.js packages, outlining usage and installation instructions.
  • Bug Fixes

    • Enhanced version management and dependency updates through Dependabot configuration.
  • Chores

    • Expanded .gitignore and .npmignore files to improve project cleanliness.
    • Updated configuration files for better dependency management across various environments.

Copy link

codecov bot commented Sep 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.50%. Comparing base (25c3951) to head (2dfcae0).
Report is 11 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #39   +/-   ##
=======================================
  Coverage   98.50%   98.50%           
=======================================
  Files          14       14           
  Lines        3144     3144           
=======================================
  Hits         3097     3097           
  Misses         47       47           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@2bndy5
Copy link
Collaborator Author

2bndy5 commented Sep 20, 2024

@shenxianpeng I created an org on npmjs.org named cpp-linter. If you want, I can send you an invite.

Once I get the CI working, the node binding will be published to npm in the @cpp-linter namespace. Each tageted platform will have a separate package:

  • @cpp-linter/cpp-linter -- the core package that delegates which platform-specific package to install as a dependency.
  • @cpp-linter/cpp-linter.linux-x64-gnu -- for x86_64 Linux with GNU libc
  • @cpp-linter/cpp-linter.x86_64-apple-darwin -- for x86_64 MacOS
  • @cpp-linter/cpp-linter.x86_64-pc-windows-msvc -- for x86_64 Windows with MSVC

I suppose I could add support for more platforms/targets (once I understand how), but these should be sufficient enough to use in a Typescript-based GitHub action. I think there might be a way to export the exposed main() function as a CLI script also. 🤷🏼‍♂️

For now, I'm concerned about the dependence on openSSL (from the libgit2 rust binding)...

@shenxianpeng
Copy link
Contributor

If you want, I can send you an invite.

Sure, why not? Feel free to send the invite. thank you.

@shenxianpeng
Copy link
Contributor

shenxianpeng commented Sep 20, 2024

My npm account is also @shenxianpeng

@2bndy5 2bndy5 force-pushed the napi-rs branch 4 times, most recently from b459b55 to cffadac Compare September 20, 2024 21:50
@2bndy5 2bndy5 marked this pull request as ready for review September 20, 2024 22:51
@2bndy5
Copy link
Collaborator Author

2bndy5 commented Sep 21, 2024

Ok, I think I have wrapped my head around the release process.

yarn version --new-version <tag>
git add --all
git commit -m "bump version to <tag>"
git push
git tag <tag>
git push origin refs/tags/<tag>
  • yarn version is used to bump the version in the node-binding/**package.json files.
  • When the new tag gets pushed, the CI workflow basically does:
    • yarn build compiles the binding.
    • yarn artifacts copies the accumulated artifacts (from each platform build) into the correct path for distribution.
    • npm publish does all the magic it seems. The --provenance true option uses attestations.

Using just again

I already have a recipe that bumps the version for the rust code in the root Cargo.toml. To do so, run

just bump <component>

where <component> is either major, minor, patch, or rc (for Release Candidate).

I augmented the just bump recipe to now include the above commands using yarn version ... git tag <tag>.

The only thing that is not automated is the git push origin refs/tags/<tag> command because that will instigate a release of all packages (crates-io, pypi, and npmjs).

make a yarn workspace

update cargo lock
@2bndy5 2bndy5 force-pushed the napi-rs branch 2 times, most recently from bf38613 to c5ccdcf Compare September 21, 2024 03:27
@2bndy5 2bndy5 merged commit 937a567 into main Sep 21, 2024
48 checks passed
@2bndy5 2bndy5 deleted the napi-rs branch September 21, 2024 03:50
@2bndy5 2bndy5 linked an issue Sep 21, 2024 that may be closed by this pull request
@2bndy5 2bndy5 added the enhancement New feature or request label Sep 23, 2024
Copy link
Contributor

coderabbitai bot commented Sep 23, 2024

Caution

Review failed

The pull request is closed.

Walkthrough

The pull request introduces significant updates across various files in the project, including the addition of an npm configuration for Dependabot, enhancements to version management scripts, and the establishment of a new CI/CD workflow for Node.js packaging. Additionally, a new node-binding module is created, incorporating Rust and Node.js integrations, with comprehensive documentation and testing provisions. The project structure is refined with improved .gitignore and .npmignore files, and new package configurations for multiple platforms are established.

Changes

File(s) Change Summary
.github/dependabot.yml Added npm package ecosystem configuration with weekly updates.
.github/workflows/bump_version.py Enhanced version management script with subprocess calls for updating dependencies, committing changes, and tagging versions.
.github/workflows/node-js-packaging.yml Introduced CI/CD workflow for building, testing, and publishing a Node.js application across multiple platforms.
.github/workflows/python-packaging.yml Removed master branch from workflow triggers, focusing on main.
.gitignore Expanded to include patterns for Node.js, Yarn, and Python, enhancing ignored files for various environments.
.pre-commit-config.yaml Added exclusion for end-of-file-fixer for node-binding/.*package\.json.
Cargo.toml Updated workspace members to include node-binding and added release profile settings.
cspell.config.yml Added new words to the spell checker vocabulary.
node-binding/.cargo/config.toml Introduced configuration for static linking on Windows platform.
node-binding/.gitignore Created comprehensive .gitignore for Node.js project, including entries for various environments.
node-binding/.npmignore Introduced .npmignore to specify files to ignore during npm publishing.
node-binding/.yarnrc.yml Added Yarn configuration to use node-modules linker.
node-binding/Cargo.toml Added new package cpp-linter-js with dependencies and metadata.
node-binding/README.md Provided documentation for the cpp-linter node binding project.
node-binding/__test__/index.spec.mjs Introduced tests for the main function using the AVA framework.
node-binding/build.rs Created build script for initializing Node.js native module build process.
node-binding/index.d.ts Added TypeScript declaration for the main function.
node-binding/index.js Implemented dynamic loading mechanism for native bindings based on the operating system.
node-binding/npm/darwin-x64/README.md Added README for Darwin x64 package.
node-binding/npm/darwin-x64/package.json Created package.json for Darwin x64 package with metadata.
node-binding/npm/linux-x64-gnu/README.md Added README for Linux x64 GNU package.
node-binding/npm/linux-x64-gnu/package.json Created package.json for Linux x64 GNU package with metadata.
node-binding/npm/win32-x64-msvc/README.md Added README for Windows x64 MSVC package.
node-binding/npm/win32-x64-msvc/package.json Created package.json for Windows x64 MSVC package with metadata.
node-binding/package.json Introduced package.json for @cpp-linter/cpp_linter_rs project with metadata and scripts.
node-binding/src/lib.rs Added an asynchronous main function for command-line argument handling.

Poem

In the garden of code, where rabbits play,
New bindings emerge, brightening the day.
With scripts that now dance, and workflows that sing,
A patchwork of changes, oh what joy they bring!
So hop with delight, let the versions align,
For in this code burrow, all will be fine! 🐇✨


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?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    -- I pushed a fix in commit <commit_id>, please review it.
    -- Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    -- @coderabbitai generate unit testing code for this file.
    -- @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    -- @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    -- @coderabbitai read src/utils.ts and generate unit testing code.
    -- @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    -- @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

consider node.js binding
2 participants