Skip to content

Commit bad7e32

Browse files
committed
Add test and gh action
1 parent 9a49078 commit bad7e32

File tree

7 files changed

+751
-2
lines changed

7 files changed

+751
-2
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: Test & Build
2+
3+
on:
4+
push:
5+
branches: [master, main]
6+
pull_request:
7+
branches: [master, main]
8+
9+
jobs:
10+
test:
11+
name: Test (Node ${{ matrix.node-version }})
12+
runs-on: ubuntu-latest
13+
14+
strategy:
15+
matrix:
16+
node-version: [18, 20, 22]
17+
18+
steps:
19+
- name: Checkout repository
20+
uses: actions/checkout@v4
21+
22+
- name: Install pnpm
23+
uses: pnpm/action-setup@v4
24+
with:
25+
version: 10
26+
27+
- name: Setup Node.js ${{ matrix.node-version }}
28+
uses: actions/setup-node@v4
29+
with:
30+
node-version: ${{ matrix.node-version }}
31+
cache: "pnpm"
32+
33+
- name: Install dependencies
34+
run: pnpm install --frozen-lockfile
35+
36+
- name: Type check
37+
run: pnpm tsc
38+
39+
- name: Run tests
40+
run: pnpm test
41+
42+
- name: Build
43+
run: pnpm build
44+
45+
format:
46+
name: Format Check
47+
runs-on: ubuntu-latest
48+
49+
steps:
50+
- name: Checkout repository
51+
uses: actions/checkout@v4
52+
53+
- name: Install pnpm
54+
uses: pnpm/action-setup@v4
55+
with:
56+
version: 10
57+
58+
- name: Setup Node.js
59+
uses: actions/setup-node@v4
60+
with:
61+
node-version: 20
62+
cache: "pnpm"
63+
64+
- name: Install dependencies
65+
run: pnpm install --frozen-lockfile
66+
67+
- name: Check formatting
68+
run: pnpm format && git diff --exit-code

package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@
1616
"build": "tsc && vite build && chmod +x dist/bin.js",
1717
"upload": "pnpm build && npm publish --access public",
1818
"format": "prettier --write \"src/**/*.ts\"",
19-
"clean": "rimraf dist"
19+
"clean": "rimraf dist",
20+
"test": "vitest run",
21+
"test:watch": "vitest",
22+
"test:coverage": "vitest run --coverage"
2023
},
2124
"keywords": [
2225
"sequence",
@@ -52,7 +55,8 @@
5255
"rimraf": "^4.4.1",
5356
"tsx": "^4.19.2",
5457
"typescript": "^5.6.3",
55-
"vite": "^5.4.11"
58+
"vite": "^5.4.11",
59+
"vitest": "^4.0.18"
5660
},
5761
"dependencies": {
5862
"0xsequence": "2.3.39",

0 commit comments

Comments
 (0)