Skip to content

Commit

Permalink
Merge pull request #1 from NillionNetwork/timhm/packaging
Browse files Browse the repository at this point in the history
feat: git hooks, updated tooling, fix lints, cicd workflows
  • Loading branch information
lapets authored Jan 10, 2025
2 parents a9de994 + 6352b85 commit b878ccd
Show file tree
Hide file tree
Showing 17 changed files with 3,625 additions and 642 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/cd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: CD

on:
workflow_dispatch:
inputs:
tag:
description: 'NPM tag'
type: choice
required: true
options:
- next
- latest

concurrency:
group: "publish"
cancel-in-progress: true

publish-nilql:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "23"
registry-url: "https://registry.npmjs.org"
- uses: pnpm/action-setup@v4
- run: pnpm install
- run: pnpm build
- env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: pnpm --tag ${{ github.event.inputs.tag }}
40 changes: 40 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: CI

on:
pull_request:
branches:
- main
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "23"
- uses: pnpm/action-setup@v4
- run: pnpm install
- run: pnpm biome ci
- run: pnpm typecheck

test:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "23"
- uses: pnpm/action-setup@v4
- run: pnpm install
- run: pnpm vitest --coverage
- uses: davelosert/vitest-coverage-report-action@v2
if: always()
with:
comment-on: "pr"
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,7 @@ dist
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*

# ide aretefacts
.vscode
.idea
48 changes: 27 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
# nilql
# nilQL

Library for working with encrypted data within NilDB queries and replies.
Library for working with encrypted data within nilDB queries and replies.

Package Installation and Usage
------------------------------
## Package Installation and Usage

The package can be installed using NPM:
The package can be installed using [pnpm](https://pnpm.io/):

```shell
npm install
pnpm install
```

The library can be imported in the usual ways:
The library can be imported in the usual way:

```TypeScript
const { nilql } = require('@nillion/nilql');
```ts
import { nilql } from "@nillion/nilql";
```

An example demonstrating use of the library is presented below:

```TypeScript
```ts
const cluster = {"nodes": [{}, {}]};
const secretKey = await nilql.secretKey(cluster, {"sum": true});
const plaintext = BigInt(123);
Expand All @@ -28,27 +27,34 @@ const decrypted = await nilql.decrypt(secretKey, ciphertext);
console.log(plaintext, decrypted); // Should output `123n 123n`.
```

Testing and Conventions
-----------------------
## Testing and Conventions

All unit tests are executed and their coverage measured when using [Jest](https://jestjs.io/) (see `jest.config.js` for configuration details):
All unit tests are executed and their coverage measured with [vitest](https://vitest.dev/):

```shell
npm test
pnpm test
```

Style conventions are enforced using [ESLint](https://eslint.org/):
Style conventions are enforced using [biomejs](https://biomejs.dev/):

```shell
npm run lint
pnpm lint
```

Contributions
-------------
Types are checked with:

In order to contribute to the source code, open an issue or submit a pull request on the GitHub page for this library.
```shell
pnpm typecheck
```

## Contributions

In order to contribute, open an issue or submit a pull request on the GitHub. To enforce conventions, git hooks are provided and can be setup with:

```shell
pnpm install-hooks
```

Versioning
----------
## Versioning

The version number format for this library and the changes to the library associated with version number increments conform with [Semantic Versioning 2.0.0](https://semver.org/#semantic-versioning-200).
37 changes: 37 additions & 0 deletions biome.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
"vcs": {
"enabled": true,
"clientKind": "git",
"useIgnoreFile": true
},
"files": {
"ignoreUnknown": false,
"include": ["**/*.ts", "**/*.mjs", "**/*.json"]
},
"formatter": {
"enabled": true,
"indentStyle": "space"
},
"organizeImports": {
"enabled": true
},
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"correctness": {
"useExhaustiveDependencies": "off"
},
"style": {
"noNonNullAssertion": "warn"
}
}
},
"javascript": {
"formatter": {
"quoteStyle": "double",
"trailingCommas": "all"
}
}
}
14 changes: 14 additions & 0 deletions commitlint.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { RuleConfigSeverity, type UserConfig } from "@commitlint/types";

const config: UserConfig = {
extends: ["@commitlint/config-conventional"],
rules: {
"body-max-line-length": [
RuleConfigSeverity.Disabled,
"always",
Number.POSITIVE_INFINITY,
],
},
};

export default config;
147 changes: 0 additions & 147 deletions eslint.config.mjs

This file was deleted.

6 changes: 0 additions & 6 deletions jest.config.js

This file was deleted.

23 changes: 23 additions & 0 deletions lefthook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
pre-commit:
commands:
biome-format:
glob: "*.{ts,json,jsonc}"
run: pnpm exec biome format --write --no-errors-on-unmatched --files-ignore-unknown=true --colors=off {staged_files}
stage_fixed: true

commit-msg:
commands:
lint-commit-msg:
run: pnpm commitlint --edit

pre-push:
commands:
biome-check:
glob: "*.{ts,json,jsonc}"
run: pnpm biome check --no-errors-on-unmatched --files-ignore-unknown=true --colors=off {push_files}
tsc-check:
glob: "*.{ts}"
run: pnpm exec tsc
test:
glob: "*.{ts}"
run: pnpm test
Loading

0 comments on commit b878ccd

Please sign in to comment.