Skip to content

Commit

Permalink
Run tests in bun, deno
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmillr committed Jan 10, 2025
1 parent 280f4a2 commit baf0077
Show file tree
Hide file tree
Showing 14 changed files with 137 additions and 218 deletions.
17 changes: 0 additions & 17 deletions .github/workflows/coverage.yml

This file was deleted.

24 changes: 0 additions & 24 deletions .github/workflows/nodejs.yml

This file was deleted.

15 changes: 0 additions & 15 deletions .github/workflows/publish-jsr.yml

This file was deleted.

23 changes: 0 additions & 23 deletions .github/workflows/publish-npm.yml

This file was deleted.

57 changes: 57 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Publish release
on:
release:
types: [created]
workflow_dispatch:
jobs:
publish-jsr:
name: Publish to JSR.io
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@1e31de5234b9f8995739874a8ce0492dc87873e2 # v4
- run: npm install -g jsr
- run: jsr publish
publish-npm:
name: Publish to NPM
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@1e31de5234b9f8995739874a8ce0492dc87873e2 # v4
- uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4
with:
node-version: 22
registry-url: 'https://registry.npmjs.org'
cache: npm
- run: npm ci
- run: npm run build
- run: npm publish --provenance --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
standalone:
name: Upload files to GitHub Releases
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
steps:
- uses: actions/checkout@1e31de5234b9f8995739874a8ce0492dc87873e2 # v4
- uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4
with:
node-version: 22
registry-url: 'https://registry.npmjs.org'
cache: npm
- run: npm ci
- run: npm run build
- run: |
cd build
npm ci
npm run build:release
cd ..
- run: gh release upload ${{ github.event.release.tag_name }} build/`npx jsbt outfile`
env:
GH_TOKEN: ${{ github.token }}
64 changes: 64 additions & 0 deletions .github/workflows/test-js.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Run JS tests
on:
- push
- pull_request
jobs:
bun:
name: Bun
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@1e31de5234b9f8995739874a8ce0492dc87873e2 # v4
- uses: oven-sh/setup-bun@4bc047ad259df6fc24a6c9b0f9a0cb08cf17fbe5 # v2.0.1
- run: bun install
- run: bun run build
- run: bun test/index.js
deno:
name: Deno
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@1e31de5234b9f8995739874a8ce0492dc87873e2 # v4
- uses: denoland/setup-deno@909cc5acb0fdd60627fb858598759246509fa755 # v2.0.2
- run: deno install
- run: deno task build
- run: deno --allow-env --allow-read --allow-write test/index.js
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@1e31de5234b9f8995739874a8ce0492dc87873e2 # v4
- uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4
with:
registry-url: 'https://registry.npmjs.org'
cache: npm
- run: npm install
- run: npm run build --if-present
- run: npm run lint --if-present
node:
name: Node v${{ matrix.node }}
runs-on: ubuntu-latest
strategy:
matrix:
node: [14, 16, 18, 20, 22]
steps:
- uses: actions/checkout@1e31de5234b9f8995739874a8ce0492dc87873e2 # v4
- name: Use Node.js ${{ matrix.node }}
uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4
with:
node-version: ${{ matrix.node }}
registry-url: 'https://registry.npmjs.org'
cache: npm
- run: npm install
- run: npm run build --if-present
- run: npm test
coverage:
name: Measure coverage on Node
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@1e31de5234b9f8995739874a8ce0492dc87873e2 # v4
- uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4
with:
registry-url: 'https://registry.npmjs.org'
cache: npm
- run: npm install
- run: npm run build --if-present
- run: npm run test:coverage
28 changes: 0 additions & 28 deletions .github/workflows/upload-release.yml

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"bench": "node benchmark/ml-kem.js noble; node benchmark/ml-dsa.js noble; node benchmark/slh-dsa.js noble",
"bench:all": "node benchmark/{ml-kem,ml-dsa,slh-dsa}.js",
"bench:install": "cd benchmark && npm install && cd ../../",
"build": "npm run build:clean; tsc && tsc -p tsconfig.esm.json",
"build": "tsc && tsc -p tsconfig.esm.json",
"build:release": "cd build; npm i; npm run build",
"build:clean": "rm {.,esm}/*.{js,d.ts,d.ts.map,js.map} 2> /dev/null",
"lint": "prettier --check 'src/**/*.{js,ts}' 'test/**/*.{js,ts,mjs}'",
Expand Down
8 changes: 4 additions & 4 deletions test/avcp.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { deepStrictEqual, throws } from 'node:assert';
import { pathToFileURL } from 'node:url';
import { describe, should } from 'micro-should';
import { concatBytes, hexToBytes } from '@noble/hashes/utils';
import { ml_dsa44, ml_dsa65, ml_dsa87 } from '../ml-dsa.js';
import { ml_kem512, ml_kem768, ml_kem1024 } from '../ml-kem.js';
import { ml_dsa44, ml_dsa65, ml_dsa87 } from '../esm/ml-dsa.js';
import { ml_kem512, ml_kem768, ml_kem1024 } from '../esm/ml-kem.js';
import {
slh_dsa_shake_128f,
slh_dsa_shake_128s,
Expand All @@ -17,7 +17,7 @@ import {
slh_dsa_sha2_192s,
slh_dsa_sha2_256f,
slh_dsa_sha2_256s,
} from '../slh-dsa.js';
} from '../esm/slh-dsa.js';
import { jsonGZ } from './util.js';

// TODO: use in other libraries? seems useful
Expand Down Expand Up @@ -188,5 +188,5 @@ if (import.meta.url === pathToFileURL(process.argv[1]).href) {
/*
NOTE: we pass tests from NIST test vectors, however:
- HashML-DSA/HashSLH-DSA not implemented (there is no tests for them)
-
-
*/
4 changes: 2 additions & 2 deletions test/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { should } from 'micro-should';
import './ml-kem.test.js';
import './ml-dsa.test.js';
// import './ml-kem.test.js';
// import './ml-dsa.test.js';
import './avcp.test.js'; // Test vectors from 'AVCP'

// ESM is broken.
Expand Down
20 changes: 0 additions & 20 deletions test/ml-dsa.test.js

This file was deleted.

36 changes: 0 additions & 36 deletions test/ml-kem.test.js

This file was deleted.

41 changes: 0 additions & 41 deletions test/slh-kem.test.js

This file was deleted.

Loading

0 comments on commit baf0077

Please sign in to comment.