Skip to content

Commit 16159c9

Browse files
authored
Add the Node.js CI workflow (#102)
1 parent 6ee7d03 commit 16159c9

File tree

2 files changed

+46
-5
lines changed

2 files changed

+46
-5
lines changed

.github/workflows/node.js.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
2+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs
3+
4+
name: Node.js CI
5+
6+
on:
7+
push:
8+
branches: [ "main" ]
9+
pull_request:
10+
branches: [ "main" ]
11+
12+
jobs:
13+
build:
14+
15+
runs-on: ubuntu-latest
16+
17+
strategy:
18+
matrix:
19+
node-version: [22.x, 24.x]
20+
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
21+
22+
steps:
23+
- uses: actions/checkout@v4
24+
- name: Use Node.js ${{ matrix.node-version }}
25+
- uses: pnpm/action-setup@0609f0983b7a228f052f81ef4c3d6510cae254ad
26+
with:
27+
version: 6.10.0
28+
- uses: actions/setup-node@v4
29+
with:
30+
node-version: ${{ matrix.node-version }}
31+
cache: 'pnpm'
32+
- run: pnpm install
33+
- run: pnpm ci:lint
34+
- run: pnpm ci:format
35+
- run: pnpm ci:coverage
36+
- run: pnpm test

package.json

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,25 @@
55
"type": "module",
66
"scripts": {
77
"clean": "rm -rf .nyc_output coverage dist",
8-
"test": "nyc mocha 'src/**/*.test.ts' --require=tsx",
8+
"test": "nyc --reporter html --reporter text mocha 'src/**/*.test.ts' --require=tsx",
99
"lint": "eslint --fix 'src/**/*.ts'",
1010
"format": "prettier --write --ignore-unknown .",
11-
"coverage": "nyc report --reporter html && open coverage/index.html",
12-
"coverage:check": "nyc check-coverage --lines 90 --branches 80 --statements 90",
13-
"prepare": "husky"
11+
"coverage": "open coverage/index.html",
12+
"prepare": "husky",
13+
"ci:lint": "eslint 'src/**/*.ts'",
14+
"ci:format": "prettier --check --ignore-unknown .",
15+
"ci:coverage": "nyc check-coverage --lines 90 --branches 80 --statements 90"
1416
},
17+
"engines": {
18+
"node": ">=22"
19+
},
20+
"packageManager": "[email protected]",
1521
"lint-staged": {
1622
"**/*": [
1723
"pnpm lint",
1824
"pnpm format"
1925
]
2026
},
21-
"packageManager": "[email protected]",
2227
"devDependencies": {
2328
"@eslint/js": "^9.31.0",
2429
"@types/chai": "^5.2.2",

0 commit comments

Comments
 (0)