-
Notifications
You must be signed in to change notification settings - Fork 60
Expand file tree
/
Copy path.pre-commit-config.yaml
More file actions
226 lines (207 loc) · 7.24 KB
/
Copy path.pre-commit-config.yaml
File metadata and controls
226 lines (207 loc) · 7.24 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
# Pre-commit configuration for mongodb-kubernetes
#
# Uses prek (https://github.com/j178/prek) with priority-based scheduling:
# - Hooks with lower priority run first, serially by ascending priority.
# - Hooks with the same priority run concurrently.
# - Hooks without an explicit priority get an implicit order-based value (sequential);
# all hooks here set priority explicitly.
#
# Dependency chain:
# P1 (concurrent): operator-version, manifests, mco-tests, RBAC, licenses, kubebuilder
# - P1 hooks are mutually file-independent; only update-release-json at P2 consumes
# release.json (written by update-mongodb-operator-version here). Do not add a P1
# hook that reads release.json without moving it to P2+.
# - generate-manifests (manifests) writes helm_chart/crds/ which generate-standalone-yaml
# (P4) reads, so manifests must precede standalone. P1 before P4 satisfies this.
# P2: update-release-json — reads/writes release.json
# P3: update-values-yaml — reads release.json, writes helm_chart/values.yaml
# P4: generate-standalone-yaml — reads helm_chart/values.yaml (P3) + helm_chart/crds/ (P1)
# P6: Lint/validate group — all linters and validators run concurrently
default_stages: [pre-commit]
repos:
# ── P1: concurrent generation (mutually file-independent) ──────────────────
- repo: local
hooks:
- id: update-mongodb-operator-version
name: update-mongodb-operator-version
entry: scripts/dev/generate_files.sh update_operator_version
language: system
pass_filenames: false
stages: [pre-commit]
priority: 1
- id: generate-manifests
name: generate-manifests
entry: scripts/dev/generate_files.sh generate_manifests
language: system
pass_filenames: false
stages: [pre-commit]
priority: 1
- id: update-mco-tests
name: update-mco-tests
entry: scripts/dev/generate_files.sh update_mco_tests
language: system
pass_filenames: false
stages: [pre-commit]
priority: 1
- id: regenerate-public-rbac-multi-cluster
name: regenerate-public-rbac-multi-cluster
entry: scripts/dev/generate_files.sh regenerate_public_rbac_multi_cluster
language: system
pass_filenames: false
stages: [pre-commit]
priority: 1
- id: update-licenses
name: update-licenses
entry: scripts/dev/generate_files.sh update_licenses
language: system
pass_filenames: false
stages: [pre-commit]
priority: 1
- id: check-kubebuilder-annotations
name: check-kubebuilder-annotations
entry: scripts/dev/generate_files.sh check_kubebuilder_annotations
language: system
pass_filenames: false
stages: [pre-commit]
priority: 1
# ── P2: serial — propagates mongodbOperator, writes release.json ───────────
- repo: local
hooks:
- id: update-release-json
name: update-release-json
entry: scripts/dev/generate_files.sh update_release
language: system
pass_filenames: false
stages: [pre-commit]
priority: 2
# ── P3: serial — reads release.json, writes helm_chart/values.yaml ────────
- repo: local
hooks:
- id: update-values-yaml
name: update-values-yaml
entry: scripts/dev/generate_files.sh update_values
language: system
pass_filenames: false
stages: [pre-commit]
priority: 3
# ── P4: serial — reads values.yaml (P3) + helm_chart/crds/ (P1) ────────────
- repo: local
hooks:
- id: generate-standalone-yaml
name: generate-standalone-yaml
entry: scripts/dev/generate_files.sh generate_standalone_yaml
language: system
pass_filenames: false
stages: [pre-commit]
priority: 4
# ── P6: linters & validators (all concurrent) ─────────────────────────────
- repo: local
hooks:
- id: validate-snippets
name: validate-snippets
entry: scripts/code_snippets/validate_snippets.py
language: system
pass_filenames: false
stages: [pre-commit]
priority: 6
- id: validate-helm-charts
name: validate-helm-charts
entry: scripts/dev/lint_helm_chart.sh
language: system
pass_filenames: false
stages: [pre-commit]
priority: 6
- id: validate-go-version
name: validate-go-version
entry: scripts/dev/update_go_version.sh
language: system
pass_filenames: false
stages: [pre-commit]
priority: 6
- id: ty
name: ty
entry: bash -c 'cd docker/mongodb-kubernetes-tests && uvx ty check tests/'
language: system
pass_filenames: false
files: docker/mongodb-kubernetes-tests/tests/.*\.py$
stages: [pre-commit]
priority: 6
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
# TODO: Enable these hooks in a follow-up PR - they modify 200+ files
# - id: trailing-whitespace
# exclude: |
# (?x)^(
# .*\.patch$|
# vendor/.*|
# testdata/.*|
# helm_chart/crds/.*|
# public/crds\.yaml$|
# config/crd/bases/.*
# )
# - id: end-of-file-fixer
# exclude: |
# (?x)^(
# .*\.patch$|
# vendor/.*|
# testdata/.*|
# helm_chart/crds/.*|
# public/crds\.yaml$|
# config/crd/bases/.*
# )
- id: check-added-large-files
exclude: |
(?x)^(
docker/mongodb-kubernetes-tests/tests/common/search/testdata/fixtures/.*\.log$
)
priority: 6
- id: check-merge-conflict
priority: 6
- id: check-json
exclude: |
(?x)^(
vendor/.*|
testdata/.*
)
priority: 6
- repo: https://github.com/psf/black
rev: 24.10.0
hooks:
- id: black
priority: 6
- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort
args: ["--profile", "black"]
priority: 6
- repo: https://github.com/koalaman/shellcheck-precommit
rev: v0.10.0
hooks:
- id: shellcheck
exclude: |
(?x)^(
vendor/.*|
scripts/dev/contexts/private-context.*
)
files: |
(?x)(
\.sh$|
^scripts/dev/contexts/[^/]+$|
^scripts/funcs/[^/]+$
)
priority: 6
- repo: https://github.com/golangci/golangci-lint
rev: v2.1.0
hooks:
# golangci-lint-full (not golangci-lint) runs on the entire module rather than only
# files changed since HEAD, so linters that need whole-program analysis (e.g. unused,
# staticcheck) see the full codebase and pre-existing violations are not silently skipped.
- id: golangci-lint-full
args: [--timeout=10m]
language_version: 1.26.6
priority: 6
- id: golangci-lint-fmt
language_version: 1.26.6
priority: 6