Skip to content

Commit eff0586

Browse files
committed
ci: use github actions
1 parent c80044f commit eff0586

File tree

11 files changed

+431
-1097
lines changed

11 files changed

+431
-1097
lines changed

.ava.bench.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export default {
2-
files: ['build/main/**/*.bench.js'],
2+
files: ['build/**/*.bench.js'],
33
workerThreads: false,
44
verbose: true,
55
};

.circleci/config.yml

Lines changed: 0 additions & 88 deletions
This file was deleted.

.github/ISSUE_TEMPLATE.md

Whitespace-only changes.

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 0 additions & 13 deletions
This file was deleted.

.github/workflows/benchmark.yaml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Libauth Benchmarks
2+
on:
3+
push:
4+
branches:
5+
- v2
6+
7+
permissions:
8+
contents: write
9+
deployments: write
10+
11+
jobs:
12+
benchmark:
13+
name: Run Benchmarks
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v3
17+
- name: Setup node
18+
uses: actions/setup-node@v3
19+
with:
20+
node-version: 16
21+
- name: Run benchmark
22+
run: yarn && yarn bench
23+
- name: Push benchmark result to gh-pages
24+
uses: benchmark-action/github-action-benchmark@3d3bca03e83647895ef4f911fa57de3c7a391aaf
25+
with:
26+
name: Benchmark.js Benchmark
27+
tool: 'benchmarkjs'
28+
output-file-path: bench.log
29+
github-token: ${{ secrets.GITHUB_TOKEN }}
30+
auto-push: true
31+
# Show alert with commit comment on detecting possible performance regression
32+
alert-threshold: '200%'
33+
comment-on-alert: true
34+
fail-on-alert: true
35+
alert-comment-cc-users: '@bitjson'

.github/workflows/ci.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Lint, Build, and Test Libauth
2+
on: [push, pull_request]
3+
4+
jobs:
5+
6+
build-and-test:
7+
runs-on: ubuntu-latest
8+
strategy:
9+
matrix:
10+
node: [ 16 ]
11+
name: Test Node ${{ matrix.node }}
12+
steps:
13+
- uses: actions/checkout@v3
14+
- name: Setup node
15+
uses: actions/setup-node@v3
16+
with:
17+
node-version: ${{ matrix.node }}
18+
cache: 'yarn'
19+
- run: yarn --frozen-lockfile --ignore-engines
20+
- run: yarn test
21+
22+
build-and-test-node18:
23+
runs-on: ubuntu-latest
24+
strategy:
25+
matrix:
26+
node: [ 18 ]
27+
name: Test Node ${{ matrix.node }}
28+
steps:
29+
- uses: actions/checkout@v3
30+
- name: Setup node
31+
uses: actions/setup-node@v3
32+
with:
33+
node-version: ${{ matrix.node }}
34+
cache: 'yarn'
35+
- run: yarn --frozen-lockfile --ignore-engines
36+
- run: yarn test-node18
37+
- name: Upload test coverage
38+
uses: codecov/codecov-action@v2

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040

4141
# Libauth
4242

43-
**An ultra-lightweight JavaScript library for Bitcoin, Bitcoin Cash, and Bitauth applications.**
43+
**An ultra-lightweight JavaScript library for Bitcoin Cash, Bitcoin, and Bitauth applications.**
4444

4545
Libauth has **no dependencies** and works in all JavaScript environments, including [Node.js](https://nodejs.org/), [Deno](https://deno.land/), and browsers.
4646

package.json

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -52,31 +52,31 @@
5252
"gen:schema:authentication-template": "ts-json-schema-generator --no-ref-encode --path 'src/lib/compiler/template-types.ts' --type 'AuthenticationTemplate' > src/lib/schema/authentication-template.schema.json && prettier 'src/lib/schema/authentication-template.schema.json' --write && ajv compile -s src/lib/schema/authentication-template.schema.json --allowUnionTypes -o src/lib/schema/ajv/validate-authentication-template.js && prettier 'src/lib/schema/ajv/validate-authentication-template.js' --write && node -e \"const fs = require('fs'), path = 'src/lib/schema/ajv/validate-authentication-template.js'; fs.writeFileSync(path, fs.readFileSync(path, 'utf8').replace(/'use strict'[\\s\\S]*module.exports.default =/, 'export default'), 'utf8')\"",
5353
"gen:schema-TODO": "//TODO: use ajv compile --code-esm option after merge: https://github.com/ajv-validator/ajv-cli/pull/200",
5454
"gen:templates": "run-s build && node 'build/lib/transaction/fixtures/generate-templates.spec.helper.js' 'p2pkh' > src/lib/transaction/fixtures/templates/p2pkh.json && node 'build/lib/transaction/fixtures/generate-templates.spec.helper.js' '2-of-3' > src/lib/transaction/fixtures/templates/2-of-3.json && node 'build/lib/transaction/fixtures/generate-templates.spec.helper.js' '2-of-2-recoverable' > src/lib/transaction/fixtures/templates/2-of-2-recoverable.json && node 'build/lib/transaction/fixtures/generate-templates.spec.helper.js' 'sig-of-sig' > src/lib/transaction/fixtures/templates/sig-of-sig.json && node 'build/lib/transaction/fixtures/generate-templates.spec.helper.js' 'cash-channels' > src/lib/transaction/fixtures/templates/cash-channels.json && prettier 'src/lib/transaction/fixtures/templates/*.json' --write",
55+
"gen:graph": "mkdir -p scratch && madge --image scratch/deps-$(date +\"%FT%H%M\").svg build/index.js",
5556
"test": "run-s build test:*",
57+
"test-node18": "NODE_OPTIONS=--openssl-legacy-provider run-s build test:*",
5658
"test:deps": "node -e \"if(Object.keys(require('./package.json').dependencies).length > 0) { console.error('Dependencies are not allowed.'); process.exit(1); }\"",
5759
"test:schemas": "run-s gen:schema && if [ `git status src/lib/schema --porcelain | head -c1 | wc -c` -gt 0 ]; then echo \"Error: one or more schemas are outdated. Please review and commit the changes in src/lib/schema.\" && false; fi && echo \"Schemas are up to date.\"",
5860
"test:lint": "eslint . --ext .ts",
5961
"test:prettier": "prettier \"src/**/*.ts\" --list-different",
6062
"test:spelling": "cspell \"{README.md,.github/*.md,src/**/*.ts}\"",
6163
"test:cycles": "madge --circular build/index.js",
62-
"test:unit": "NODE_OPTIONS=--openssl-legacy-provider nyc --silent ava",
63-
"test:unit:fast": "nyc --silent ava --match='!*[fast-check]*' --match='!*[crypto]*' --match='!*[script_tests]*' --match='!*[signing-serialization tests]*' --match='!*[BCH compiler]*' --match='!*[BCH VM]*'",
64-
"test:unit:fast-check": "nyc --silent ava --match='*[fast-check]*",
65-
"test:unit:script_tests": "nyc --silent ava --match='*[script_tests]*' --serial",
66-
"test:unit:vmb_tests": "nyc --silent ava src/lib/vmb-tests/bch-vmb-tests.spec.ts --serial",
64+
"test:unit": "c8 ava",
65+
"test:unit:script_tests": "c8 ava --match='*[script_tests]*' --serial",
66+
"test:unit:vmb_tests": "c8 ava src/lib/vmb-tests/bch-vmb-tests.spec.ts --serial",
6767
"test:unit:vmb_test": "node 'build/lib/vmb-tests/bch-vmb-test.spec.helper.js'",
6868
"bench": "run-s build bench:browser-deps bench:test",
69-
"bench:test": "NODE_OPTIONS=--openssl-legacy-provider ava --config .ava.bench.config.js --serial --timeout=2m",
69+
"bench:test": "ava --config .ava.bench.config.js --serial --timeout=2m 2>&1 | tee bench.log",
7070
"bench:browser-deps": "browserify node_modules/chuhai/index.js --standalone chuhai -o build/bench/chuhai.js && browserify node_modules/hash.js/lib/hash.js --standalone hash -o build/bench/hash.js",
7171
"watch": "run-s build:tsc build:wasm && yarn build:tsc -- -w",
7272
"watch:single": "echo 'Usage: yarn watch:single --match=\"*pattern*\"' && ava -v --watch",
7373
"watch:test": "yarn test:unit:fast -- --watch -v",
7474
"watch:test-slow": "yarn test:unit -- --watch -v",
7575
"cov": "run-s build test:unit cov:html cov:lcov && open-cli coverage/index.html",
76-
"cov:html": "nyc report --reporter=html",
77-
"cov:lcov": "nyc report --reporter=lcov",
76+
"cov:html": "c8 report --reporter=html",
77+
"cov:lcov": "c8 report --reporter=lcov",
7878
"cov:send": "run-s cov:lcov && codecov",
79-
"cov:check": "nyc report && nyc check-coverage --lines 85 --functions 80 --branches 65",
79+
"cov:check": "c8 report && c8 check-coverage --lines 90 --functions 90 --branches 90",
8080
"doc": "run-s doc:html && open-cli build/docs/index.html",
8181
"doc:logo": "cpy assets/libauth.svg build/docs",
8282
"doc:cname": "node -e \"console.log('libauth.org')\" > build/docs/CNAME",
@@ -88,17 +88,17 @@
8888
"doc:check-api": "api-extractor run --typescript-compiler-folder node_modules/typescript",
8989
"doc:publish": "gh-pages -m \"[ci skip] Updates\" -d build/docs",
9090
"version": "standard-version",
91+
"version:alpha": "standard-version --prerelease alpha",
9192
"reset": "git clean -dfx && git reset --hard && yarn",
92-
"prepare-release": "run-s reset test cov:check doc:html doc:logo doc:cname version doc:publish"
93+
"prepare-release": "run-s reset test cov:check doc:html doc:logo doc:cname version doc:publish",
94+
"prepare-release:alpha": "run-s reset test cov:check version:alpha"
9395
},
9496
"engines": {
9597
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
9698
},
9799
"dependencies": {},
98100
"devDependencies": {
99101
"@ava/typescript": "^3.0.1",
100-
"@bitjson/npm-scripts-info": "^1.0.0",
101-
"@istanbuljs/nyc-config-typescript": "^1.0.2",
102102
"@microsoft/api-documenter": "^7.17.13",
103103
"@microsoft/api-extractor": "^7.23.2",
104104
"@rollup/plugin-alias": "^3.1.9",
@@ -116,14 +116,16 @@
116116
"ava-fast-check": "^5.0.0",
117117
"bcrypto": "^5.4.0",
118118
"bitcore-lib-cash": "^8.25.28",
119-
"browserify": "17.0.0",
119+
"browserify": "16.5.1",
120+
"c8": "^7.11.2",
120121
"chuhai": "^1.2.0",
121122
"codecov": "^3.8.3",
122123
"cpy-cli": "^4.1.0",
123124
"cspell": "^5.20.0",
124125
"cz-conventional-changelog": "^3.3.0",
125126
"elliptic": "^6.5.4",
126127
"eslint": "8.15.0",
128+
"eslint-config-bitauth": "^3.0.0",
127129
"eslint-config-prettier": "^8.5.0",
128130
"eslint-plugin-eslint-comments": "^3.2.0",
129131
"eslint-plugin-functional": "^4.2.1",
@@ -136,17 +138,14 @@
136138
"hash.js": "^1.1.5",
137139
"madge": "^5.0.1",
138140
"npm-run-all": "^4.1.5",
139-
"nyc": "^15.1.0",
140141
"open-cli": "^7.0.1",
141142
"prettier": "^2.6.2",
142143
"puppeteer": "^14.1.0",
143144
"rollup": "^2.73.0",
144145
"secp256k1": "^4.0.3",
145146
"source-map-support": "^0.5.21",
146147
"standard-version": "^9.3.2",
147-
"trash-cli": "^5.0.0",
148148
"ts-json-schema-generator": "^1.0.0",
149-
"ts-node": "^10.7.0",
150149
"typedoc": "^0.22.13",
151150
"typescript": "^4.6.4"
152151
},
@@ -205,13 +204,11 @@
205204
}
206205
]
207206
},
208-
"nyc": {
209-
"extends": "@istanbuljs/nyc-config-typescript",
207+
"c8": {
210208
"exclude": [
211209
"**/*.bench.js",
212210
"**/*.spec.js",
213-
"**/*.spec.helper.js",
214-
"**/*.spec.debug.js"
211+
"**/*.spec.helper.js"
215212
]
216213
},
217214
"sideEffects": false

src/lib/crypto/hash.browser.bench.helper.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* global window, crypto */
22
/* eslint-disable functional/no-let, @typescript-eslint/init-declarations, functional/no-expression-statement, functional/no-conditional-statement, functional/no-return-void */
3-
import asmCrypto from 'asmcrypto.js';
3+
import * as asmCrypto from 'asmcrypto.js';
44
import suite from 'chuhai';
55
import hashJs from 'hash.js';
66

src/lib/crypto/hash.browser.bench.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import alias from '@rollup/plugin-alias';
44
import commonjs from '@rollup/plugin-commonjs';
55
import nodeResolve from '@rollup/plugin-node-resolve';
66
import test from 'ava';
7-
import { launch } from 'puppeteer';
7+
import puppeteer from 'puppeteer';
88
import { rollup } from 'rollup';
99

1010
const prepareCode = async () => {
@@ -25,8 +25,8 @@ const prepareCode = async () => {
2525
plugins: [
2626
alias({
2727
entries: {
28-
chuhai: './../../../bench/chuhai.js',
29-
'hash.js': './../../../bench/hash.js',
28+
chuhai: './../../bench/chuhai.js',
29+
'hash.js': './../../bench/hash.js',
3030
},
3131
}),
3232
commonjs(),
@@ -43,7 +43,7 @@ const prepareCode = async () => {
4343
};
4444

4545
const preparePage = async () => {
46-
const browser = await launch({
46+
const browser = await puppeteer.launch({
4747
args: ['--no-sandbox', '--disable-setuid-sandbox'],
4848
// devtools: true
4949
});

0 commit comments

Comments
 (0)