-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add node binding for y-octo (#4)
* feat: add y-octo-node * feat: add deps * feat: init build * chore: ignore auto generate files lint in prettier * test: add test for node binding * ci: extract rust toolchain action * feat: extract more actions * feat: add test workflow for node * ci: fix coverage * fix: binding build * ci: fix artifact name * chore: ci name * feat: add rust test for node binding * chore: cleanup
- Loading branch information
1 parent
57286a3
commit 3152dc0
Showing
21 changed files
with
1,494 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
name: "Y-Octo Node.js Setup" | ||
description: "Node.js setup for CI, including cache configuration" | ||
inputs: | ||
extra-flags: | ||
description: "Extra flags to pass to the yarn install." | ||
required: false | ||
default: "--immutable --inline-builds" | ||
package-install: | ||
description: "Run the install step." | ||
required: false | ||
default: "true" | ||
hard-link-nm: | ||
description: "set nmMode to hardlinks-local in .yarnrc.yml" | ||
required: false | ||
default: "true" | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Setup Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version-file: ".nvmrc" | ||
cache: "yarn" | ||
|
||
- name: Set nmMode | ||
if: ${{ inputs.hard-link-nm == 'true' }} | ||
shell: bash | ||
run: yarn config set nmMode hardlinks-local | ||
|
||
- name: yarn install | ||
if: ${{ inputs.package-install == 'true' }} | ||
continue-on-error: true | ||
shell: bash | ||
run: yarn install ${{ inputs.extra-flags }} | ||
env: | ||
HUSKY: "0" | ||
|
||
- name: yarn install (try again) | ||
if: ${{ steps.install.outcome == 'failure' }} | ||
shell: bash | ||
run: yarn install ${{ inputs.extra-flags }} | ||
env: | ||
HUSKY: "0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: "Y-Octo Rust setup" | ||
description: "Rust setup, including cache configuration" | ||
inputs: | ||
components: | ||
description: "Cargo components" | ||
required: false | ||
target: | ||
description: "Cargo target" | ||
required: true | ||
toolchain: | ||
description: "Rustup toolchain" | ||
required: false | ||
default: "stable" | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Setup Rust | ||
uses: dtolnay/rust-toolchain@stable | ||
with: | ||
toolchain: ${{ inputs.toolchain }} | ||
targets: ${{ inputs.target }} | ||
components: ${{ inputs.components }} | ||
- uses: Swatinem/rust-cache@v2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
name: Y-Octo Node Binding Build & Test | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
branches: [main] | ||
|
||
env: | ||
DEBUG: napi:* | ||
COVERAGE: true | ||
|
||
jobs: | ||
build-node: | ||
name: Build Node Binding | ||
runs-on: ubuntu-latest | ||
env: | ||
RUSTFLAGS: "-C debuginfo=1" | ||
environment: development | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Setup Node.js | ||
uses: ./.github/actions/setup-node | ||
- name: Setup Rust | ||
uses: ./.github/actions/setup-rust | ||
with: | ||
target: "x86_64-unknown-linux-gnu" | ||
- name: Build node binding | ||
run: yarn build:node | ||
- name: Upload y-octo.node | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: y-octo.node | ||
path: ./y-octo-node/y-octo.linux-x64-gnu.node | ||
if-no-files-found: error | ||
|
||
test-node: | ||
name: Test & Collect Coverage | ||
runs-on: ubuntu-latest | ||
continue-on-error: true | ||
env: | ||
RUSTFLAGS: -D warnings | ||
CARGO_TERM_COLOR: always | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Setup Rust | ||
uses: ./.github/actions/setup-rust | ||
with: | ||
components: llvm-tools-preview | ||
- name: Install latest nextest release | ||
uses: taiki-e/install-action@nextest | ||
- name: Install cargo-llvm-cov | ||
uses: taiki-e/install-action@cargo-llvm-cov | ||
|
||
- name: Collect coverage data | ||
run: cargo llvm-cov nextest --lcov --output-path lcov.info | ||
- name: Upload coverage data to codecov | ||
uses: codecov/codecov-action@v3 | ||
with: | ||
name: tests | ||
files: lcov.info | ||
|
||
node-binding-test: | ||
name: Node Binding Test | ||
runs-on: ubuntu-latest | ||
needs: build-node | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Setup Node.js | ||
uses: ./.github/actions/setup-node | ||
- name: Download y-octo.node | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: y-octo.node | ||
path: ./y-octo-node | ||
- name: Run node binding tests | ||
run: yarn test:node:coverage | ||
working-directory: y-octo-node | ||
- name: Upload server test coverage results | ||
uses: codecov/codecov-action@v3 | ||
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
files: ./y-octo-node/.coverage/lcov.info | ||
flags: node-binding-test | ||
name: y-octo | ||
fail_ci_if_error: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
18 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,5 @@ target | |
y-octo/README.md | ||
.cargo | ||
vendor | ||
index.d.ts | ||
index.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,19 @@ | ||
{ | ||
"name": "y-octo", | ||
"name": "@y-octo/cli", | ||
"version": "0.0.0", | ||
"packageManager": "[email protected]", | ||
"license": "MIT", | ||
"workspaces": [ | ||
".", | ||
"y-octo-node" | ||
], | ||
"engines": { | ||
"node": ">=18.16.1 <19.0.0" | ||
}, | ||
"scripts": { | ||
"build:node": "yarn workspace @y-octo/node build", | ||
"test:node": "yarn workspace @y-octo/node test", | ||
"test:node:coverage": "yarn workspace @y-octo/node test:coverage", | ||
"format": "run-p format:toml format:prettier format:rs", | ||
"format:toml": "taplo format", | ||
"format:prettier": "prettier --write .", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
{ | ||
"compilerOptions": { | ||
"verbatimModuleSyntax": true, | ||
// Classification follows https://www.typescriptlang.org/tsconfig | ||
|
||
// Type Checking | ||
"strict": true, | ||
// exactOptionalPropertyTypes: false, | ||
"noFallthroughCasesInSwitch": true, | ||
"noImplicitAny": true, | ||
"noImplicitOverride": true, | ||
"noImplicitReturns": true, | ||
"noImplicitThis": true, | ||
// "noUnusedLocals": true, | ||
// "noUnusedParameters": true, | ||
// noPropertyAccessFromIndexSignature: false, | ||
// noUncheckedIndexedAccess: false, | ||
"useUnknownInCatchVariables": true, | ||
|
||
// Modules | ||
"module": "ESNext", | ||
"moduleResolution": "bundler", | ||
"resolveJsonModule": true, | ||
// Emit | ||
"declaration": true, | ||
"declarationMap": true, | ||
"sourceMap": true, | ||
// skip type emit for @internal types | ||
// "stripInternal": true, | ||
|
||
// JavaScript Support | ||
"allowJs": false, | ||
"checkJs": false, | ||
|
||
// Interop Constraints | ||
"forceConsistentCasingInFileNames": true, | ||
"allowSyntheticDefaultImports": true, | ||
"isolatedModules": true, | ||
|
||
// Language and Environment | ||
"jsx": "preserve", | ||
"jsxImportSource": "@emotion/react", | ||
"lib": ["ESNext", "DOM"], | ||
"target": "ES2022", | ||
"useDefineForClassFields": false, | ||
"experimentalDecorators": true, | ||
"emitDecoratorMetadata": true, | ||
|
||
// Projects | ||
"composite": true, | ||
"incremental": true, | ||
|
||
// Completeness | ||
"skipLibCheck": true, // skip all type checks for .d.ts files | ||
"paths": { | ||
"@y-octo/node/*": ["./y-octo-node/src/*"] | ||
} | ||
}, | ||
"include": [], | ||
"references": [ | ||
{ | ||
"path": "./y-octo-node" | ||
} | ||
], | ||
"files": [], | ||
"exclude": ["node_modules", "target", "lib", "test-results"], | ||
"ts-node": { | ||
"compilerOptions": { | ||
"module": "ESNext", | ||
"moduleResolution": "Node" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
*.node | ||
.coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
[package] | ||
authors = ["DarkSky <[email protected]>"] | ||
edition = "2021" | ||
license = "MIT" | ||
name = "y-octo-node" | ||
repository = "https://github.com/toeverything/y-octo" | ||
version = "0.0.1" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
[lib] | ||
crate-type = ["cdylib"] | ||
|
||
[dependencies] | ||
napi = "2" | ||
napi-derive = "2" | ||
y-octo = { path = "../y-octo" } | ||
|
||
[build-dependencies] | ||
napi-build = "2" | ||
|
||
[profile.release] | ||
lto = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
fn main() { | ||
napi_build::setup(); | ||
} |
Oops, something went wrong.