Skip to content

Commit c964cd5

Browse files
committed
feat: add rust crate
1 parent db663af commit c964cd5

File tree

15 files changed

+3797
-1
lines changed

15 files changed

+3797
-1
lines changed

.github/dependabot.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: cargo
4+
directory: /rust
5+
schedule:
6+
interval: monthly
7+
8+
- package-ecosystem: github-actions
9+
directory: /
10+
schedule:
11+
interval: monthly

.github/workflows/ci.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,3 +130,44 @@ jobs:
130130
- name: Test (Windows)
131131
if: matrix.os == 'windows-latest'
132132
run: ctest -C ${{ matrix.cmake_config }} --output-on-failure --test-dir build
133+
134+
rust:
135+
strategy:
136+
fail-fast: false
137+
matrix:
138+
include:
139+
- os: ubuntu-22.04
140+
toolchain: stable
141+
- os: ubuntu-22.04
142+
toolchain: nightly
143+
- os: ubuntu-22.04-arm
144+
toolchain: stable
145+
- os: macos-14
146+
toolchain: stable
147+
- os: macos-15
148+
toolchain: stable
149+
- os: windows-latest
150+
toolchain: stable
151+
152+
name: Rust ${{ matrix.toolchain }} / ${{ matrix.os }}
153+
runs-on: ${{ matrix.os }}
154+
steps:
155+
- uses: actions/checkout@v4
156+
157+
- name: Install Rust
158+
uses: dtolnay/rust-toolchain@master
159+
with:
160+
toolchain: ${{ matrix.toolchain }}
161+
components: clippy
162+
163+
- name: Clippy
164+
working-directory: rust
165+
run: cargo clippy -- -D warnings
166+
167+
- name: Test
168+
working-directory: rust
169+
run: cargo test
170+
171+
- name: Test (no default features)
172+
working-directory: rust
173+
run: cargo test --no-default-features

.github/workflows/release.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,41 @@ jobs:
5454
env:
5555
GH_TOKEN: ${{ github.token }}
5656
RELEASE_TAG: ${{ needs.release-please.outputs.release_tag }}
57+
58+
publish-rust:
59+
needs: [release-please, create-release]
60+
if: ${{ needs.release-please.outputs.release_created }}
61+
runs-on: ubuntu-latest
62+
permissions:
63+
contents: write
64+
65+
steps:
66+
- name: Checkout
67+
uses: actions/checkout@v4
68+
69+
- name: Install Rust
70+
uses: dtolnay/rust-toolchain@master
71+
with:
72+
toolchain: stable
73+
74+
- name: Build and test (populates rust/deps from source)
75+
working-directory: rust
76+
run: cargo test
77+
78+
- name: Commit rust/deps if changed
79+
run: |
80+
git config user.name "github-actions[bot]"
81+
git config user.email "github-actions[bot]@users.noreply.github.com"
82+
git add rust/deps/
83+
if git diff --cached --quiet; then
84+
echo "rust/deps is up to date"
85+
else
86+
git commit -m "chore: update rust/deps vendored sources"
87+
git push
88+
fi
89+
90+
- name: Publish to crates.io
91+
working-directory: rust
92+
run: cargo publish
93+
env:
94+
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}

release-please-config.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"release-type": "simple",
55
"extra-files": [
66
"CMakeLists.txt",
7-
"include/merve/version.h"
7+
"include/merve/version.h",
8+
"rust/Cargo.toml"
89
]
910
}
1011
}

rust/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/target

rust/Cargo.lock

Lines changed: 141 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/Cargo.toml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
[package]
2+
name = "merve"
3+
version = "1.0.1" # x-release-please-version
4+
edition = "2024"
5+
rust-version = "1.85"
6+
authors = ["Yagiz Nizipli <yagiz@nizipli.com>"]
7+
license = "Apache-2.0 OR MIT"
8+
description = "A fast C++ lexer for extracting named exports from CommonJS modules"
9+
repository = "https://github.com/nodejs/merve"
10+
categories = ["parsing", "development-tools"]
11+
keywords = ["commonjs", "cjs", "exports", "lexer", "javascript"]
12+
include = [
13+
"src/**/*.rs",
14+
"deps/**/*.cpp",
15+
"deps/**/*.h",
16+
"wasi_to_unknown.cpp",
17+
"build.rs",
18+
"Cargo.toml",
19+
"LICENSE-*",
20+
"README.md",
21+
]
22+
23+
[features]
24+
default = ["std"]
25+
# pass `cpp_set_stdlib("c++")` to `cc`
26+
libcpp = []
27+
# enable allocations
28+
std = []
29+
30+
[package.metadata.docs.rs]
31+
rustdoc-args = ["--cfg", "docsrs"]
32+
33+
[build-dependencies]
34+
cc = { version = "1.1", features = ["parallel"] }
35+
link_args = "0.6"
36+
regex = { version = "1.11", features = [] }

0 commit comments

Comments
 (0)