Skip to content

Commit b110a5a

Browse files
committed
chore: add pre-push
1 parent 89f4a7c commit b110a5a

7 files changed

Lines changed: 1842 additions & 12 deletions

File tree

.eslintrc.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"extends": ["@typescript-eslint/recommended"],
3+
"parser": "@typescript-eslint/parser",
4+
"parserOptions": {
5+
"ecmaVersion": 2020,
6+
"sourceType": "module",
7+
"project": "./tsconfig.json"
8+
},
9+
"plugins": ["@typescript-eslint"],
10+
"rules": {
11+
"@typescript-eslint/no-unused-vars": "error",
12+
"@typescript-eslint/no-explicit-any": "warn",
13+
"@typescript-eslint/explicit-function-return-type": "off",
14+
"@typescript-eslint/explicit-module-boundary-types": "off",
15+
"@typescript-eslint/ban-ts-comment": "warn",
16+
"no-console": "warn"
17+
},
18+
"ignorePatterns": ["build/**/*", "coverage/**/*", "node_modules/**/*", "*.js"]
19+
}

.github/workflows/test.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Test
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main, develop ]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
13+
strategy:
14+
matrix:
15+
node-version: [18.x, 20.x]
16+
17+
steps:
18+
- uses: actions/checkout@v3
19+
20+
- name: Use Node.js ${{ matrix.node-version }}
21+
uses: actions/setup-node@v3
22+
with:
23+
node-version: ${{ matrix.node-version }}
24+
cache: 'npm'
25+
26+
- name: Install dependencies
27+
run: npm ci
28+
29+
- name: Run type check
30+
run: npm run type-check
31+
32+
- name: Run linting
33+
run: npm run lint
34+
35+
- name: Run tests
36+
run: npm run test:ci
37+
38+
- name: Upload coverage to Codecov
39+
uses: codecov/codecov-action@v3
40+
with:
41+
file: ./coverage/lcov.info
42+
flags: unittests
43+
name: codecov-umbrella

.gitignore

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,51 @@
1+
# Dependencies
12
node_modules/
3+
npm-debug.log*
4+
yarn-debug.log*
5+
yarn-error.log*
6+
7+
# Build output
28
build/
9+
dist/
10+
11+
# Coverage directory used by tools like istanbul
12+
coverage/
13+
14+
# nyc test coverage
15+
.nyc_output
16+
17+
# Environment variables
18+
.env
19+
.env.local
20+
.env.development.local
21+
.env.test.local
22+
.env.production.local
23+
24+
# IDE
25+
.vscode/
26+
.idea/
27+
*.swp
28+
*.swo
29+
*~
30+
31+
# OS
32+
.DS_Store
33+
Thumbs.db
34+
35+
# Logs
336
*.log
4-
.env*
37+
38+
# Runtime data
39+
pids
40+
*.pid
41+
*.seed
42+
*.pid.lock
43+
44+
# Optional npm cache directory
45+
.npm
46+
47+
# Optional eslint cache
48+
.eslintcache
49+
50+
# Husky
51+
.husky/_

.husky/pre-push

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/sh
2+
3+
. "$(dirname -- "$0")/_/husky.sh"
4+
5+
echo "🔍 Running pre-push checks..."
6+
7+
# 1. 类型检查
8+
echo "📝 Type checking..."
9+
npm run type-check
10+
if [ $? -ne 0 ]; then
11+
echo "❌ Type check failed. Push aborted."
12+
exit 1
13+
fi
14+
15+
# 2. 代码风格检查
16+
echo "🎨 Linting..."
17+
npm run lint
18+
if [ $? -ne 0 ]; then
19+
echo "❌ Linting failed. Push aborted."
20+
exit 1
21+
fi
22+
23+
# 3. 构建测试
24+
echo "🏗️ Building..."
25+
npm run build
26+
if [ $? -ne 0 ]; then
27+
echo "❌ Build failed. Push aborted."
28+
exit 1
29+
fi
30+
31+
# 4. 运行测试
32+
echo "🧪 Running tests..."
33+
npm run test:ci
34+
if [ $? -ne 0 ]; then
35+
echo "❌ Tests failed. Push aborted."
36+
exit 1
37+
fi
38+
39+
echo "✅ All checks passed! Pushing..."

0 commit comments

Comments
 (0)