forked from ENTERPILOT/GoModel
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.pre-commit-config.yaml
More file actions
87 lines (84 loc) · 4.23 KB
/
Copy path.pre-commit-config.yaml
File metadata and controls
87 lines (84 loc) · 4.23 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
repos:
# 1. Standard hooks for file hygiene (trailing whitespace, newlines, etc.)
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v6.0.0 # Latest as of this update (Aug 9, 2025)
hooks:
# The embedded dashboard bundle is generated by Vite (make frontend);
# hygiene hooks must not mutate it and the minified chunk exceeds the
# large-file limit by design.
- id: trailing-whitespace
exclude: ^internal/admin/dashboard/static/dist/
- id: end-of-file-fixer
exclude: ^internal/admin/dashboard/static/dist/
- id: check-yaml
exclude: ^helm/templates/
- id: check-json
- id: check-added-large-files
exclude: ^internal/admin/dashboard/static/dist/
# 2. Go-specific hooks for formatting and tidying
# The pre-commit-golang repo has a v1.0.0+ fork which is more actively maintained.
- repo: https://github.com/Bahjat/pre-commit-golang
rev: v1.0.6
hooks:
- id: go-fmt-import # Runs goimports + gofmt on staged .go files
# 2b. Go module tidying (local hook)
- repo: local
hooks:
- id: go-unit-tests
name: make test-race
entry: make test-race
language: system
pass_filenames: false
files: '^((cmd|config|internal)/.*\.go|go\.(mod|sum)|Makefile|\.github/workflows/test\.yml)$'
- id: go-mod-tidy
name: go mod tidy
entry: go mod tidy
language: system
pass_filenames: false
files: '(\.go$|^go\.(mod|sum)$)'
- id: dashboard-js-tests
name: dashboard JavaScript unit tests
entry: make test-dashboard
language: system
pass_filenames: false
files: '^(web/dashboard/(src|tests)/.*\.(js|svelte)|web/dashboard/package\.json|Makefile|\.github/workflows/test\.yml)$'
# Rebuilds the embedded dist and fails when it differs from the staged
# copy, so frontend commits can't drift from the go:embed'ed bundle
# (CI enforces the same check; this catches it before the push).
- id: dashboard-dist-sync
name: dashboard dist in sync with sources
entry: bash -c 'cd web/dashboard && npm run build >/dev/null 2>&1; cd ../..; if ! git diff --quiet -- internal/admin/dashboard/static/dist || [ -n "$(git ls-files --others --exclude-standard internal/admin/dashboard/static/dist)" ]; then echo "Embedded dist is out of sync with web/dashboard sources."; echo "It has been rebuilt — stage internal/admin/dashboard/static/dist and commit again."; exit 1; fi'
language: system
pass_filenames: false
files: '^web/dashboard/(src/|index\.html|vite\.config\.js|svelte\.config\.js|package(-lock)?\.json)'
- id: perf-hotpath-guard
name: hot-path performance guard (alloc/byte thresholds)
entry: make perf-check
language: system
pass_filenames: false
files: '^(internal/(auditlog|core|providers|server|usage)/.*\.go|tests/perf/.*\.go|Makefile|\.github/workflows/test\.yml)$'
# Reports Go modernizations (maps.Copy, slices.Contains, min/max, new(expr),
# range-over-int, ...) that `go fix` would apply. Check-only, by design:
# `go fix` rewrites source in place, and when it marks a helper
# `//go:fix inline` it only inlines the callers on a *later* run, leaving the
# helper orphaned and tripping the `unused` linter. An auto-applying hook
# would therefore mutate the commit and still fail it. Run `make fix` to
# apply, re-run until clean, then delete any now-unused helper.
- id: go-fix-check
name: make fix-check
entry: make fix-check
language: system
pass_filenames: false
files: '(\.go$|^go\.(mod|sum)$|^Makefile$)'
- id: go-lint
name: make lint
entry: make lint
language: system
pass_filenames: false
files: '^(\.golangci\.yml|Makefile|\.github/workflows/test\.yml|.*\.go)$'
- id: mint-validate
name: mint validate
entry: bash -c 'if command -v mint >/dev/null 2>&1; then cd docs && mint validate; else echo "mint not found; skipping docs validation"; fi'
language: system
pass_filenames: false
files: '^(docs/(docs\.json|openapi\.json|.*\.(mdx|md|jsx|tsx|css|svg|png|jpg|jpeg|webp))|\.pre-commit-config\.yaml)$'