Skip to content
Merged
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
18 changes: 18 additions & 0 deletions .github/actions/setup-env/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Setup Environment
description: Install Zig toolchain, Node.js, pnpm, and dependencies

runs:
using: composite
steps:
- uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v4
- uses: mlugg/setup-zig@d1434d08867e3ee9daa34448df10607b98908d29 # v2
with:
version: 0.14.1
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: 24
cache: pnpm
- run: zig version
shell: bash
- run: pnpm install --frozen-lockfile
shell: bash
46 changes: 46 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: CI

on:
pull_request:
branches: [main]
push:
branches: [main]

jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- uses: ./.github/actions/setup-env
- name: Build
run: pnpm build

test-zig:
name: Zig Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- uses: ./.github/actions/setup-env
- name: Test
run: pnpm test:zig

test-js:
name: JS Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- uses: ./.github/actions/setup-env
- name: Build
run: pnpm build
- name: Test
run: pnpm test:js

lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- uses: ./.github/actions/setup-env
- name: Lint
run: pnpm lint
31 changes: 31 additions & 0 deletions .github/workflows/pr-title.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: PR Title

on:
pull_request:
branches: [main]
types: [opened, edited, synchronize]

jobs:
conventional-commit:
name: Conventional Commit Title
runs-on: ubuntu-latest
steps:
- name: Validate PR title
env:
PR_TITLE: ${{ github.event.pull_request.title }}
run: |
pattern='^(feat|fix|chore|docs|refactor|test|ci|perf|build|revert)(\(.+\))?(!)?: .+'
if [[ ! "$PR_TITLE" =~ $pattern ]]; then
echo "::error::PR title does not follow Conventional Commits format."
echo ""
echo "Expected: <type>[optional scope][!]: <description>"
echo "Got: $PR_TITLE"
echo ""
echo "Allowed types: feat, fix, chore, docs, refactor, test, ci, perf, build, revert"
echo "Examples:"
echo " feat: add new API endpoint"
echo " fix(parser): handle edge case"
echo " chore!: drop support for Node 18"
exit 1
fi
echo "PR title is valid: $PR_TITLE"
1 change: 1 addition & 0 deletions examples/hello_world/mod.zig
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ fn Timer_ctor(env: napi.Env, cb: napi.CallbackInfo(0)) !napi.Value {
timer,
Timer_finalize,
null,
null,
);
return cb.this();
}
Expand Down
4 changes: 2 additions & 2 deletions examples/type_tag/mod.zig
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ fn Cat_ctor(env: napi.Env, cb: napi.CallbackInfo(1)) !napi.Value {
const cat = try allocator.create(Cat);
cat.* = Cat{ .name_buf = buf, .len = name.len };

_ = try env.wrap(cb.this(), Cat, cat, Cat_finalize, null);
_ = try env.wrap(cb.this(), Cat, cat, Cat_finalize, null, null);
try env.typeTagObject(cb.this(), cat_type_tag);
return cb.this();
}
Expand Down Expand Up @@ -94,7 +94,7 @@ fn Dog_ctor(env: napi.Env, cb: napi.CallbackInfo(1)) !napi.Value {
const dog = try allocator.create(Dog);
dog.* = Dog{ .name_buf = buf, .len = name.len };

_ = try env.wrap(cb.this(), Dog, dog, Dog_finalize, null);
_ = try env.wrap(cb.this(), Dog, dog, Dog_finalize, null, null);
try env.typeTagObject(cb.this(), dog_type_tag);
return cb.this();
}
Expand Down
15 changes: 8 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
"build": "pnpm build:js && pnpm build:zig",
"build:js": "tsc --outDir lib",
"build:zig": "zig build",
"test:napi": "zig build test:napi",
"test:examples": "vitest run examples/**/*.test.ts",
"test": "pnpm test:napi && pnpm test:examples",
"lint:zapi": "zig fmt src",
"lint:ts": "pnpm biome check",
"lint": "pnpm lint:zapi && pnpm lint:ts",
"test:zig": "zig build test:napi",
"test:js": "vitest run examples/**/*.test.ts",
"test": "pnpm test:zig && pnpm test:js",
"lint:zig": "zig fmt src",
"lint:js": "pnpm biome check",
"lint": "pnpm lint:zig && pnpm lint:js",
"lint:fix": "pnpm biome check --write"
},
"files": [
Expand All @@ -31,5 +31,6 @@
"@types/node": "^24.1.0",
"typescript": "^5.8.3",
"vitest": "^4.0.18"
}
},
"packageManager": "pnpm@10.8.1+sha512.c50088ba998c67b8ca8c99df8a5e02fd2ae2e2b29aaf238feaa9e124248d3f48f9fb6db2424949ff901cffbb5e0f0cc1ad6aedb602cd29450751d11c35023677"
}
Loading