forked from iflytek/astron-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.pre-commit-config.yaml
More file actions
323 lines (287 loc) · 13.4 KB
/
.pre-commit-config.yaml
File metadata and controls
323 lines (287 loc) · 13.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
# =============================================================================
# Pre-commit Configuration for Multi-language Project
# Fast code quality checks for changed files only
# =============================================================================
# Install: pip install pre-commit && pre-commit install
# pre-commit install --hook-type commit-msg
#
# Usage: pre-commit run --all-files (check all files)
# pre-commit run (check staged files)
# git commit (auto trigger)
#
# Mode: CHECK ONLY - Reports issues without auto-fixing
# To fix issues manually:
# - Python: black . && isort .
# - TypeScript: npm run format
# - Go: gofmt -w . && goimports -w .
# - Java: mvn spotless:apply
# =============================================================================
default_language_version:
python: python3.11
node: 20.0.0
repos:
# =============================================================================
# Common Checks (All Languages) - Check Only Mode
# =============================================================================
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-yaml
exclude: 'console/frontend/node_modules|helm/'
- id: check-json
exclude: 'console/frontend/node_modules'
- id: check-added-large-files
args: ['--maxkb=1000']
- id: check-merge-conflict
# =============================================================================
# Python Code Quality - Check Only Mode
# =============================================================================
- repo: https://github.com/psf/black
rev: 24.4.2
hooks:
- id: black
name: Check Python code format with Black
language_version: python3.11
args: ['--check']
files: ^(core/agent|core/workflow|core/knowledge|core/plugin|core/memory/database)/.*\.py$
- repo: local
hooks:
- id: isort-knowledge
name: Check Python imports (knowledge)
entry: bash -c 'cd core/knowledge && python3 -m isort --check-only --profile black .'
language: system
files: ^core/knowledge/.*\.py$
pass_filenames: false
- id: isort-workflow
name: Check Python imports (workflow)
entry: bash -c 'cd core/workflow && python3 -m isort --check-only --profile black .'
language: system
files: ^core/workflow/.*\.py$
pass_filenames: false
- id: isort-agent
name: Check Python imports (agent)
entry: bash -c 'cd core/agent && python3 -m isort --check-only --profile black .'
language: system
files: ^core/agent/.*\.py$
pass_filenames: false
- id: isort-plugin
name: Check Python imports (plugin)
entry: bash -c 'cd core/plugin/aitools && python3 -m isort --check-only --profile black .'
language: system
files: ^core/plugin/.*\.py$
pass_filenames: false
- repo: local
hooks:
- id: flake8-agent
name: Lint Python with Flake8 (agent)
entry: bash -c 'cd core/agent && python3 -m flake8 .'
language: system
files: ^core/agent/.*\.py$
pass_filenames: false
- id: flake8-workflow
name: Lint Python with Flake8 (workflow)
entry: bash -c 'cd core/workflow && python3 -m flake8 --max-line-length 88 --ignore=E203,W503,E501 --max-complexity 10 .'
language: system
files: ^core/workflow/.*\.py$
pass_filenames: false
- id: flake8-knowledge
name: Lint Python with Flake8 (knowledge)
entry: bash -c 'cd core/knowledge && python3 -m flake8 --max-line-length 88 --ignore=E203,W503,E501 --max-complexity 10 .'
language: system
files: ^core/knowledge/.*\.py$
pass_filenames: false
- id: flake8-plugin
name: Lint Python with Flake8 (plugin)
entry: bash -c 'cd core/plugin/rpa && python3 -m flake8 --max-line-length 88 --ignore=E203,W503,E501 --max-complexity 10 .'
language: system
files: ^core/plugin/rpa/.*\.py$
pass_filenames: false
- repo: local
hooks:
- id: mypy-agent
name: Type check Python with mypy (agent)
entry: bash -c 'cd core/agent && python3 -m mypy --disallow-untyped-defs --disallow-incomplete-defs --check-untyped-defs --no-implicit-optional --ignore-missing-imports --explicit-package-bases .'
language: system
files: ^core/agent/.*\.py$
pass_filenames: false
- id: mypy-workflow
name: Type check Python with mypy (workflow)
entry: bash -c 'cd core/workflow && python3 -m mypy --disallow-untyped-defs --disallow-incomplete-defs --check-untyped-defs --no-implicit-optional --ignore-missing-imports --explicit-package-bases .'
language: system
files: ^core/workflow/.*\.py$
pass_filenames: false
- id: mypy-knowledge
name: Type check Python with mypy (knowledge)
entry: bash -c 'cd core/knowledge && python3 -m mypy --disallow-untyped-defs --disallow-incomplete-defs --check-untyped-defs --no-implicit-optional --ignore-missing-imports --explicit-package-bases .'
language: system
files: ^core/knowledge/.*\.py$
pass_filenames: false
- id: mypy-database
name: Type check Python with mypy (database)
entry: bash -c 'cd core/memory/database && python3 -m mypy --disallow-untyped-defs --disallow-incomplete-defs --check-untyped-defs --no-implicit-optional --ignore-missing-imports --explicit-package-bases .'
language: system
files: ^core/memory/database/.*\.py$
pass_filenames: false
- id: mypy-aitools
name: Type check Python with mypy (aitools)
entry: bash -c 'cd core/plugin/aitools && python3 -m mypy --disallow-untyped-defs --disallow-incomplete-defs --check-untyped-defs --no-implicit-optional --ignore-missing-imports --explicit-package-bases .'
language: system
files: ^core/plugin/aitools/.*\.py$
pass_filenames: false
- id: mypy-link
name: Type check Python with mypy (link)
entry: bash -c 'cd core/plugin/link && python3 -m mypy --disallow-untyped-defs --disallow-incomplete-defs --check-untyped-defs --no-implicit-optional --ignore-missing-imports --explicit-package-bases .'
language: system
files: ^core/plugin/link/.*\.py$
pass_filenames: false
- id: mypy-rpa
name: Type check Python with mypy (rpa)
entry: bash -c 'cd core/plugin/rpa && python3 -m mypy --disallow-untyped-defs --disallow-incomplete-defs --check-untyped-defs --no-implicit-optional --ignore-missing-imports --explicit-package-bases .'
language: system
files: ^core/plugin/rpa/.*\.py$
pass_filenames: false
- repo: local
hooks:
- id: pylint-agent
name: Analyze Python with Pylint (agent)
entry: bash -c 'cd core/agent && python3 -m pylint --disable=import-error --max-line-length=88 --max-args=7 --max-locals=15 --max-returns=6 --max-branches=12 --max-statements=50 --fail-under=8.0 *.py'
language: system
files: ^core/agent/.*\.py$
pass_filenames: false
- id: pylint-workflow
name: Analyze Python with Pylint (workflow)
entry: bash -c 'cd core/workflow && python3 -m pylint --disable=import-error --max-line-length=88 --max-args=7 --max-locals=15 --max-returns=6 --max-branches=12 --max-statements=50 --fail-under=8.0 *.py'
language: system
files: ^core/workflow/.*\.py$
pass_filenames: false
- id: pylint-knowledge
name: Analyze Python with Pylint (knowledge)
entry: bash -c 'cd core/knowledge && python3 -m pylint --disable=import-error --max-line-length=88 --max-args=7 --max-locals=15 --max-returns=6 --max-branches=12 --max-statements=50 --fail-under=8.0 *.py'
language: system
files: ^core/knowledge/.*\.py$
pass_filenames: false
- id: pylint-database
name: Analyze Python with Pylint (database)
entry: bash -c 'cd core/memory/database && python3 -m pylint --disable=import-error --max-line-length=88 --max-args=7 --max-locals=15 --max-returns=6 --max-branches=12 --max-statements=50 --fail-under=8.0 *.py'
language: system
files: ^core/memory/database/.*\.py$
pass_filenames: false
- id: pylint-aitools
name: Analyze Python with Pylint (aitools)
entry: bash -c 'cd core/plugin/aitools && python3 -m pylint --disable=import-error --max-line-length=88 --max-args=7 --max-locals=15 --max-returns=6 --max-branches=12 --max-statements=50 --fail-under=8.0 *.py'
language: system
files: ^core/plugin/aitools/.*\.py$
pass_filenames: false
- id: pylint-link
name: Analyze Python with Pylint (link)
entry: bash -c 'cd core/plugin/link && python3 -m pylint --disable=import-error --max-line-length=88 --max-args=7 --max-locals=15 --max-returns=6 --max-branches=12 --max-statements=50 --fail-under=8.0 *.py'
language: system
files: ^core/plugin/link/.*\.py$
pass_filenames: false
- id: pylint-rpa
name: Analyze Python with Pylint (rpa)
entry: bash -c 'cd core/plugin/rpa && python3 -m pylint --disable=import-error --max-line-length=88 --max-args=7 --max-locals=15 --max-returns=6 --max-branches=12 --max-statements=50 --fail-under=8.0 *.py'
language: system
files: ^core/plugin/rpa/.*\.py$
pass_filenames: false
# =============================================================================
# TypeScript/JavaScript Code Quality - Check Only Mode
# =============================================================================
- repo: local
hooks:
- id: prettier-check
name: Check TypeScript/JavaScript format with Prettier
entry: bash -c 'cd console/frontend && npx prettier --check "src/**/*.{ts,tsx,js,jsx,json,md}" --ignore-path .gitignore'
language: system
files: ^console/frontend/src/.*\.(ts|tsx|js|jsx|json|md)$
pass_filenames: false
- id: eslint-check
name: Lint TypeScript with ESLint
entry: bash -c 'cd console/frontend && npx eslint "src/**/*.{ts,tsx}" --quiet'
language: system
files: ^console/frontend/src/.*\.(ts|tsx)$
pass_filenames: false
# =============================================================================
# Go Code Quality - Check Only Mode
# =============================================================================
- repo: local
hooks:
- id: golangci-lint
name: Lint Go with golangci-lint
entry: bash -c 'cd core/tenant && golangci-lint run --timeout=5m ./...'
language: system
files: ^core/tenant/.*\.go$
pass_filenames: false
- id: go-fmt-check
name: Check Go code format with gofmt
entry: bash -c 'cd core/tenant && gofmt -l . | tee /dev/stderr | test -z "$(cat)"'
language: system
files: ^core/tenant/.*\.go$
pass_filenames: false
- id: go-imports-check
name: Check Go imports with goimports
entry: bash -c 'cd core/tenant && goimports -l . | tee /dev/stderr | test -z "$(cat)"'
language: system
files: ^core/tenant/.*\.go$
pass_filenames: false
- id: go-vet
name: Check Go code with go vet
entry: bash -c 'cd core/tenant && go vet ./...'
language: system
files: ^core/tenant/.*\.go$
pass_filenames: false
# =============================================================================
# Java Code Quality (requires local Maven)
# =============================================================================
- repo: local
hooks:
- id: spotless-check
name: Check Java formatting with Spotless
entry: bash -c 'cd console/backend && mvn spotless:check'
language: system
files: ^console/backend/.*\.java$
pass_filenames: false
- id: checkstyle
name: Check Java style with Checkstyle
entry: bash -c 'cd console/backend && mvn checkstyle:check'
language: system
files: ^console/backend/.*\.java$
pass_filenames: false
# =============================================================================
# Security Scanning
# =============================================================================
- repo: https://github.com/gitleaks/gitleaks
rev: v8.21.2
hooks:
- id: gitleaks
name: Detect secrets with gitleaks
# =============================================================================
# Commit Message Validation
# =============================================================================
- repo: https://github.com/compilerla/conventional-pre-commit
rev: v3.1.0
hooks:
- id: conventional-pre-commit
name: Check commit message format
stages: [commit-msg]
args:
- feat
- fix
- docs
- style
- refactor
- perf
- test
- build
- ci
- chore
- revert
# =============================================================================
# CI Integration Config
# =============================================================================
ci:
autofix_commit_msg: 'ci: auto fixes from pre-commit hooks'
autofix_prs: true
autoupdate_commit_msg: 'ci: pre-commit autoupdate'
autoupdate_schedule: weekly
skip: [spotless-check, checkstyle]