-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path.pre-commit-config.yaml
More file actions
113 lines (105 loc) · 3.25 KB
/
.pre-commit-config.yaml
File metadata and controls
113 lines (105 loc) · 3.25 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
repos:
# Essential file checks (fast)
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
args: ['--allow-multiple-documents']
exclude: ^(config/manager/|\.github/workflows/|charts/).*\.ya?ml$
# - id: check-added-large-files
# args: ['--maxkb=1000'] # Limit to 1MB
- id: check-case-conflict
- id: check-merge-conflict
- id: debug-statements
# Fast Go code quality checks
- repo: local
hooks:
- id: go-fmt
name: go fmt
entry: gofmt
args: [-w, -s]
language: system
files: \.go$
- id: go-imports
name: go imports
entry: bash
args:
- -c
- |
GOPATH=$(go env GOPATH)
if [ -f "$GOPATH/bin/goimports" ]; then
"$GOPATH/bin/goimports" -w .
else
go install golang.org/x/tools/cmd/goimports@latest && "$GOPATH/bin/goimports" -w .
fi
language: system
files: \.go$
pass_filenames: false
- id: go-mod-tidy
name: go mod tidy
entry: go mod tidy
language: system
files: ^go\.(mod|sum)$
pass_filenames: false
- id: golangci-lint-fast
name: golangci-lint (fast)
entry: bash
args:
- -c
- |
if [ ! -f ./bin/golangci-lint ]; then
echo "Installing golangci-lint..."
make golangci-lint >/dev/null 2>&1 || {
echo "Warning: Could not install golangci-lint, skipping"
exit 0
}
fi
echo "Running golangci-lint..."
./bin/golangci-lint run --config .golangci-precommit.yml --timeout=2m || {
echo "Note: golangci-lint found issues. Run 'make lint' for full details."
exit 0
}
language: system
files: \.go$
pass_filenames: false
- id: staticcheck-fast
name: staticcheck (essential checks)
entry: bash
args:
- -c
- |
if [ ! -f ./bin/staticcheck ]; then
echo "Installing staticcheck..."
make staticcheck >/dev/null 2>&1 || {
echo "Warning: Could not install staticcheck, skipping"
exit 0
}
fi
echo "Running staticcheck (essential checks only)..."
./bin/staticcheck -checks=inherit,-ST1000,-ST1003,-ST1016,-ST1020,-ST1021,-ST1022 ./... || {
echo "Note: staticcheck found issues. Run 'make lint-staticcheck' for full details."
exit 0
}
language: system
files: \.go$
pass_filenames: false
# Security checks (fast)
- repo: https://github.com/gitleaks/gitleaks
rev: v8.21.2
hooks:
- id: gitleaks
# YAML validation (fast)
- repo: https://github.com/adrienverge/yamllint.git
rev: v1.35.1
hooks:
- id: yamllint
args: [-c=.yamllint.yaml]
files: \.(yaml|yml)$
# Commit message validation
- repo: https://github.com/commitizen-tools/commitizen
rev: v3.29.1
hooks:
- id: commitizen
stages: [commit-msg]