Skip to content
Closed
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
82 changes: 82 additions & 0 deletions .github/workflows/napi-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: NAPI-RS CI

on:
push:
branches: [main]
paths:
- 'node/term-guard/**'
- '.github/workflows/napi-ci.yml'
pull_request:
types: [opened, synchronize, reopened]
paths:
- 'node/term-guard/**'
- '.github/workflows/napi-ci.yml'

# Prevent concurrent builds from the same branch/PR
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

# Minimal permissions by default
permissions:
contents: read

env:
DEBUG: napi:*
APP_NAME: term-guard
CARGO_TERM_COLOR: always
RUSTFLAGS: -D warnings
CARGO_INCREMENTAL: 0
CARGO_NET_RETRY: 10

jobs:
build-and-test:
name: Build and Test Node.js Bindings
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
cache-dependency-path: node/term-guard/package-lock.json

- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable

- name: Cache Rust dependencies
uses: useblacksmith/rust-cache@v3
with:
prefix-key: "v2-napi"
shared-key: "napi-linux"
cache-on-failure: true
cache-all-crates: true
cache-targets: true

- name: Install dependencies
run: |
cd node/term-guard
npm ci

- name: Build NAPI module
run: |
cd node/term-guard
npm run build

- name: Test NAPI module
run: |
cd node/term-guard
npm test

- name: Upload artifact
uses: actions/upload-artifact@v4
if: github.ref == 'refs/heads/main'
with:
name: node-bindings
path: node/term-guard/*.node
if-no-files-found: error
14 changes: 14 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,17 @@ CLAUDE.md

# Logs directory
logs/

# Node.js dependencies
node_modules/
node/term-guard/node_modules/
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.npm
*.tgz

# Node.js build artifacts
node/term-guard/*.node
node/term-guard/index.node
node/term-guard/artifacts.json
111 changes: 109 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
members = [
"term-guard",
"examples",
"node/term-guard",
]
resolver = "2"

Expand Down
45 changes: 45 additions & 0 deletions node/term-guard/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Node.js dependencies
node_modules/
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.npm

# Build artifacts
*.node
index.node
artifacts.json
*.tgz

# TypeScript build files
*.tsbuildinfo
dist/
lib/
build/
*.js.map
*.d.ts.map

# Keep TypeScript source files
!*.ts
!tsconfig.json

# Testing
coverage/
.nyc_output/

# IDE
.vscode/
.idea/
*.swp
*.swo
*~
.DS_Store

# Environment files
.env
.env.local
.env.*.local

# Temporary files
tmp/
temp/
25 changes: 25 additions & 0 deletions node/term-guard/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
target
Cargo.lock
Cargo.toml
build.rs
src/
*.node
!index.node
test/
benches/
.github/
.gitignore
tsconfig.json
yarn.lock
package-lock.json
pnpm-lock.yaml
.cargo/
examples/
docs/
*.log
.DS_Store
thumbs.db
# TypeScript source files
*.ts
!*.d.ts
index.js
43 changes: 43 additions & 0 deletions node/term-guard/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
[package]
name = "term-guard-node"
version = "0.1.0"
edition = "2021"
authors = ["Eric P. Simon <ericpsimon@gmail.com>"]
license = "MIT"
description = "Node.js bindings for Term data validation library"
repository = "https://github.com/withterm/term"
keywords = ["data-validation", "data-quality", "nodejs", "napi"]

[lib]
crate-type = ["cdylib"]

[dependencies]
# NAPI dependencies
napi = { version = "2", default-features = false, features = ["napi8", "async", "serde-json"] }
napi-derive = "2"

# Term dependency
term-guard = { path = "../../term-guard", version = "0.0.2" }

# DataFusion and Arrow for data handling
datafusion = "48.0.1"
arrow = "55.2"

# Async runtime
tokio = { version = "1", features = ["full"] }
async-trait = "0.1"

# Serialization
serde = { version = "1", features = ["derive"] }
serde_json = "1"

# Error handling
thiserror = "2"

[build-dependencies]
napi-build = "2"

[profile.release]
lto = true
strip = true
opt-level = 3
5 changes: 5 additions & 0 deletions node/term-guard/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
extern crate napi_build;

fn main() {
napi_build::setup();
}
Loading
Loading