Skip to content

Commit

Permalink
Upgrade ci & tests. Run in deno, bun.
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmillr committed Jan 14, 2025
1 parent ffdf5de commit 9618631
Show file tree
Hide file tree
Showing 14 changed files with 137 additions and 128 deletions.
26 changes: 0 additions & 26 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: [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.

4 changes: 2 additions & 2 deletions benchmark/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { deepStrictEqual } from 'assert';
import { deepStrictEqual } from 'node:assert';
import { run, mark } from 'micro-bmark';
import * as jpeg from 'jpeg-js';
import * as fs from 'fs';
import * as fs from 'node:fs';
import encodeQR from '../esm/index.js';
import decodeQR from '../esm/decode.js';
// Other libraries
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"build": "tsc && tsc -p tsconfig.esm.json",
"lint": "prettier --check src",
"format": "prettier --write src",
"test": "node test/index.test.js"
"test": "node test/index.js"
},
"exports": {
".": {
Expand Down
8 changes: 2 additions & 6 deletions test/bitmap.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { deepStrictEqual } from 'assert';
import { deepStrictEqual } from 'node:assert';
import { should } from 'micro-should';
import { GifReader } from 'omggif';
import encodeQR, { _tests } from '../esm/index.js';
Expand Down Expand Up @@ -355,8 +355,4 @@ should('GIF encode', () => {
}
});

// ESM is broken.
import url from 'url';
if (import.meta.url === url.pathToFileURL(process.argv[1]).href) {
should.run();
}
should.runWhen(import.meta.url);
10 changes: 3 additions & 7 deletions test/decode.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { deepStrictEqual } from 'assert';
import { deepStrictEqual } from 'node:assert';
import { should } from 'micro-should';
import { readFileSync, readdirSync, statSync } from 'fs';
import { readFileSync, readdirSync, statSync } from 'node:fs';
import { decode as jpegDecode } from 'jpeg-js';
import readQR, { _tests } from '../esm/decode.js';

Expand Down Expand Up @@ -446,8 +446,4 @@ for (const category of listFiles(DETECTION_PATH, true)) {
// console.log('DECODED', res);
// });

// ESM is broken.
import url from 'url';
if (import.meta.url === url.pathToFileURL(process.argv[1]).href) {
should.run();
}
should.runWhen(import.meta.url);
8 changes: 2 additions & 6 deletions test/encode.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { deepStrictEqual } from 'assert';
import { deepStrictEqual } from 'node:assert';
import { should } from 'micro-should';
import { _tests } from '../esm/index.js';

Expand Down Expand Up @@ -335,8 +335,4 @@ should('encodeData', () => {
}
});

// ESM is broken.
import url from 'url';
if (import.meta.url === url.pathToFileURL(process.argv[1]).href) {
should.run();
}
should.runWhen(import.meta.url);
File renamed without changes.
12 changes: 4 additions & 8 deletions test/qr.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { deepStrictEqual } from 'assert';
import { readFileSync } from 'fs';
import { gunzipSync } from 'zlib';
import { deepStrictEqual } from 'node:assert';
import { readFileSync } from 'node:fs';
import { gunzipSync } from 'node:zlib';
import { should } from 'micro-should';
import encodeQR, { _tests } from '../esm/index.js';
const jsonGZ = (path) => JSON.parse(gunzipSync(readFileSync(path)));
Expand Down Expand Up @@ -454,8 +454,4 @@ should('Full API test url', () => {
deepStrictEqual(q, exp);
});

// ESM is broken.
import url from 'url';
if (import.meta.url === url.pathToFileURL(process.argv[1]).href) {
should.run();
}
should.runWhen(import.meta.url);
8 changes: 2 additions & 6 deletions test/utils.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { deepStrictEqual } from 'assert';
import { deepStrictEqual } from 'node:assert';
import { should, describe } from 'micro-should';
import { _tests } from '../esm/index.js';

Expand Down Expand Up @@ -223,8 +223,4 @@ describe('utils', () => {
});
});

// ESM is broken.
import url from 'url';
if (import.meta.url === url.pathToFileURL(process.argv[1]).href) {
should.run();
}
should.runWhen(import.meta.url);

0 comments on commit 9618631

Please # to comment.