From 3e0ccf7ccc91e2d724be5dd0837cf2895be4deab Mon Sep 17 00:00:00 2001 From: Rod Vagg Date: Fri, 10 Dec 2021 11:06:25 +1100 Subject: [PATCH] chore: update testing, sync with latest patterns * update polendina w/ webpack 5 and better esm support * make package.json and semantic-release config more consistent with js-multiformats --- .github/workflows/test-and-release.yml | 37 ++++++-------------- package.json | 48 +++++++++++++++++--------- test/test-basics.js | 2 +- 3 files changed, 42 insertions(+), 45 deletions(-) diff --git a/.github/workflows/test-and-release.yml b/.github/workflows/test-and-release.yml index 3da6f88..b80a9a5 100644 --- a/.github/workflows/test-and-release.yml +++ b/.github/workflows/test-and-release.yml @@ -6,49 +6,32 @@ jobs: fail-fast: false matrix: node: [14.x, 16.x] - os: [macos-latest, ubuntu-latest] + os: [macos-latest, ubuntu-latest, windows-latest] runs-on: ${{ matrix.os }} steps: - name: Checkout Repository - uses: actions/checkout@v2.3.4 + uses: actions/checkout@v2.4.0 - name: Use Node.js ${{ matrix.node }} uses: actions/setup-node@v2.5.0 with: node-version: ${{ matrix.node }} - name: Install Dependencies run: | - npm install --no-progress --no-package-lock + npm install --no-progress - name: Run tests run: | - npm test - test-windows: - strategy: - fail-fast: false - matrix: - node: [14.x, 16.x] - os: [windows-latest] - runs-on: ${{ matrix.os }} - steps: - - name: Checkout Repository - uses: actions/checkout@v2.3.4 - - name: Use Node.js ${{ matrix.node }} - uses: actions/setup-node@v2.5.0 - with: - node-version: ${{ matrix.node }} - - name: Install Dependencies - run: | - npm install --no-progress --no-package-lock - - name: Run tests - run: | - npm run test:node + npm config set script-shell bash + npm run test:ci + - name: Typecheck + uses: gozala/typescript-error-reporter-action@v1.0.8 release: name: Release - needs: [test, test-windows] + needs: test runs-on: ubuntu-latest if: github.event_name == 'push' && github.ref == 'refs/heads/master' steps: - name: Checkout - uses: actions/checkout@v2.3.4 + uses: actions/checkout@v2.4.0 with: fetch-depth: 0 - name: Setup Node.js @@ -75,6 +58,6 @@ jobs: - name: Release env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - NPM_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} run: npx semantic-release diff --git a/package.json b/package.json index eef6ce4..6d6c25c 100644 --- a/package.json +++ b/package.json @@ -5,23 +5,24 @@ "main": "blake2.js", "type": "module", "scripts": { + "lint": "standard", "build": "npm run build:source && npm run build:js && npm run build:types", "build:js": "ipjs build --tests --main && npm run build:copy", "build:source": "node build.js", "build:copy": "cp -a tsconfig.json *.js test dist/", "build:types": "tsc --build && mv types dist", - "publish": "ipjs publish", - "lint": "standard", "test:cjs": "npm run build && mocha dist/cjs/node-test/test-*.js && npm run test:cjs:browser", + "test:esm": "npm run build && mocha dist/esm/node-test/test-*.js && npm run test:esm:browser", "test:node": "c8 --check-coverage --branches 100 --functions 100 --lines 100 mocha test/test-*.js", - "test:cjs:browser": "polendina --cleanup dist/cjs/browser-test/test-*.js", - "test": "npm run build:source && npm run lint && npm run test:node && npm run test:cjs", - "test:node-v12": "npm run build:source && mocha test/test-*.js && npm run test:cjs", + "test:cjs:browser": "polendina --page --worker --serviceworker --cleanup dist/cjs/browser-test/test-*.js", + "test:esm:browser": "polendina --page --worker --serviceworker --cleanup dist/esm/browser-test/test-*.js", + "test": "npm run build:source && npm run lint && npm run test:node && npm run test:esm", + "test:ci": "npm run build:source && npm run lint && npm run test:node && npm run test:esm && npm run test:cjs", "coverage": "c8 --reporter=html mocha test/test-*.js && npm_config_yes=true npx st -d coverage -p 8080" }, "keywords": [ - "IPFS", - "IPLD", + "ipfs", + "ipld", "multiformats", "hash", "multihash", @@ -40,23 +41,36 @@ "import": "./blake2s.js" } }, - "devDependencies": { - "@ipld/dag-cbor": "^6.0.6", - "c8": "^7.7.3", - "ipjs": "^5.0.3", - "mocha": "^9.0.3", - "polendina": "^1.1.0", - "standard": "^16.0.3", - "typescript": "^4.3.5" - }, "dependencies": { "blakejs": "^1.1.1", - "multiformats": "^9.4.3" + "multiformats": "^9.5.4" + }, + "devDependencies": { + "@ipld/dag-cbor": "^6.0.15", + "c8": "^7.10.0", + "chai": "^4.3.4", + "ipjs": "^5.2.0", + "mocha": "^9.1.3", + "polendina": "^2.0.1", + "standard": "^16.0.4", + "typescript": "^4.5.3" + }, + "standard": { + "ignore": [ + "dist" + ] + }, + "directories": { + "test": "test" }, "repository": { "type": "git", "url": "git+https://github.com/multiformats/js-blake2.git" }, + "bugs": { + "url": "https://github.com/multiformats/js-blake2/issues" + }, + "homepage": "https://github.com/multiformats/js-blake2#readme", "typesVersions": { "*": { "*": [ diff --git a/test/test-basics.js b/test/test-basics.js index befb6cf..3028634 100644 --- a/test/test-basics.js +++ b/test/test-basics.js @@ -2,7 +2,7 @@ import * as blake2b from '@multiformats/blake2/blake2b' import * as blake2s from '@multiformats/blake2/blake2s' import blake2 from '@multiformats/blake2' -import assert from 'assert' +import { assert } from 'chai' import { bytes } from 'multiformats' import table from './table.csv.js'