Skip to content

Commit 812f3f7

Browse files
ci: add GitHub Actions workflows and git hooks for automated testing
- Add CI workflow for testing on Node.js 20.x and 22.x - Add PR checks for title validation, security audit, and bundle size - Add pre-commit hook for linting and testing staged files - Add pre-push hook for full test suite validation - Configure husky and lint-staged for git hook management 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent b58eb25 commit 812f3f7

File tree

6 files changed

+935
-125
lines changed

6 files changed

+935
-125
lines changed

.github/workflows/ci.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ master, main ]
6+
pull_request:
7+
branches: [ master, main ]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
13+
strategy:
14+
matrix:
15+
node-version: [20.x, 22.x]
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Use Node.js ${{ matrix.node-version }}
21+
uses: actions/setup-node@v4
22+
with:
23+
node-version: ${{ matrix.node-version }}
24+
cache: 'npm'
25+
26+
- name: Install dependencies
27+
run: npm ci
28+
29+
- name: Run linter
30+
run: npm run lint
31+
32+
- name: Run tests with coverage
33+
run: npm run coverage
34+
35+
- name: Upload coverage reports
36+
uses: codecov/codecov-action@v4
37+
with:
38+
file: ./coverage/lcov.info
39+
flags: unittests
40+
name: codecov-umbrella
41+
fail_ci_if_error: true
42+
if: matrix.node-version == '20.x'
43+
44+
build:
45+
runs-on: ubuntu-latest
46+
needs: test
47+
48+
steps:
49+
- uses: actions/checkout@v4
50+
51+
- name: Use Node.js 20.x
52+
uses: actions/setup-node@v4
53+
with:
54+
node-version: 20.x
55+
cache: 'npm'
56+
57+
- name: Install dependencies
58+
run: npm ci
59+
60+
- name: Build TypeScript
61+
run: npm run build
62+
63+
- name: Check TypeScript types
64+
run: npm run type-check

.github/workflows/pr-checks.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: PR Checks
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened]
6+
7+
jobs:
8+
lint-pr-title:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Check PR title
12+
uses: amannn/action-semantic-pull-request@v5
13+
env:
14+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
15+
with:
16+
types: |
17+
feat
18+
fix
19+
docs
20+
style
21+
refactor
22+
test
23+
chore
24+
perf
25+
ci
26+
revert
27+
28+
security-audit:
29+
runs-on: ubuntu-latest
30+
steps:
31+
- uses: actions/checkout@v4
32+
33+
- name: Use Node.js 20.x
34+
uses: actions/setup-node@v4
35+
with:
36+
node-version: 20.x
37+
cache: 'npm'
38+
39+
- name: Install dependencies
40+
run: npm ci
41+
42+
- name: Run security audit
43+
run: npm audit --audit-level=moderate
44+
45+
size-check:
46+
runs-on: ubuntu-latest
47+
steps:
48+
- uses: actions/checkout@v4
49+
50+
- name: Use Node.js 20.x
51+
uses: actions/setup-node@v4
52+
with:
53+
node-version: 20.x
54+
cache: 'npm'
55+
56+
- name: Install dependencies
57+
run: npm ci
58+
59+
- name: Check bundle size
60+
run: npm run cost

.husky/pre-commit

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
npx lint-staged

.husky/pre-push

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
npm run lint
2+
npm run coverage
3+
npm run type-check

0 commit comments

Comments
 (0)