-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Expand file tree
/
Copy path.pre-commit-config.yaml
More file actions
362 lines (340 loc) · 15.1 KB
/
Copy path.pre-commit-config.yaml
File metadata and controls
362 lines (340 loc) · 15.1 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
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
---
# Single source of truth for Opik's pre-commit checks across the monorepo.
# Each scope is gated by `files:` so a commit only runs the hooks for the paths
# it touches. Local commits and the unified lint CI workflow both drive off this.
#
# Versions of remote linters are pinned per `rev:` (the framework's design — it
# provisions each tool in an isolated env so contributors need no Python/JS/Java
# install to run the Python hooks). Keep them fresh with `pre-commit autoupdate`.
repos:
# ---------------------------------------------------------------------------
# Python SDK (sdks/python)
# ---------------------------------------------------------------------------
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v6.0.0
hooks:
- id: trailing-whitespace
name: 🐍 trim trailing whitespace — python sdk
files: ^sdks/python
exclude: "(sdks/python/src/opik/rest_api/)"
- id: end-of-file-fixer
name: 🐍 fix end of files — python sdk
files: ^sdks/python
exclude: "(sdks/python/src/opik/rest_api/)"
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.14.14
hooks:
- id: ruff
name: 🐍 ruff — python sdk
args: [--fix, --show-fixes]
files: ^sdks/python
exclude: "(sdks/python/src/opik/rest_api/)"
- id: ruff-format
name: 🐍 ruff-format — python sdk
files: ^sdks/python
exclude: "(sdks/python/src/opik/rest_api/)"
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.19.1
hooks:
- id: mypy
name: 🐍 mypy — python sdk
files: ^sdks/python
# `exclude` option will work only from here.
# The rest of mypy configuration can be moved to pyproject.toml
exclude: "(sdks/python/tests/)|(sdks/python/examples/)|(sdks/python/src/opik/rest_api/)|(sdks/python/.cursor/)"
args:
[
--config-file,
sdks/python/pyproject.toml,
--disable-error-code,
misc,
]
# ---------------------------------------------------------------------------
# Optimizer SDK (sdks/opik_optimizer)
# ---------------------------------------------------------------------------
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v6.0.0
hooks:
- id: trailing-whitespace
name: 🤖 trim trailing whitespace — optimizer
files: ^sdks/opik_optimizer
- id: end-of-file-fixer
name: 🤖 fix end of files — optimizer
files: ^sdks/opik_optimizer
- id: check-yaml
name: 🤖 check yaml — optimizer
files: ^sdks/opik_optimizer
- id: check-json
name: 🤖 check json — optimizer
files: ^sdks/opik_optimizer
- id: check-toml
name: 🤖 check toml — optimizer
files: ^sdks/opik_optimizer
- id: check-added-large-files
name: 🤖 check for added large files — optimizer
args: ['--maxkb=1000']
files: ^sdks/opik_optimizer
- id: detect-private-key
name: 🔐 detect private key — optimizer
files: ^sdks/opik_optimizer
- id: check-merge-conflict
name: 🤖 check for merge conflicts — optimizer
files: ^sdks/opik_optimizer
- id: check-case-conflict
name: 🤖 check for case conflicts — optimizer
files: ^sdks/opik_optimizer
- repo: https://github.com/asottile/pyupgrade
rev: v3.21.2
hooks:
- id: pyupgrade
name: 🤖 pyupgrade — optimizer
args: [--py310-plus]
files: ^sdks/opik_optimizer
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.14.14
hooks:
- id: ruff
name: 🤖 ruff — optimizer
args: [ --fix, --show-fixes]
files: ^sdks/opik_optimizer
- id: ruff-format
name: 🤖 ruff-format — optimizer
files: ^sdks/opik_optimizer
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.19.1
hooks:
- id: mypy
name: 🤖 mypy — optimizer
files: ^sdks/opik_optimizer
exclude: '(sdks/opik_optimizer/scripts/benchmarks/|sdks/opik_optimizer/benchmarks/benchmark_results/)'
args: [--config-file, sdks/opik_optimizer/pyproject.toml, --install-types, --non-interactive]
additional_dependencies: [types-requests, types-PySocks, types-Pygments, types-pexpect, types-protobuf, types-setuptools, types-ujson, pytest, pyrate_limiter, modal]
- repo: https://github.com/kynan/nbstripout
rev: 0.9.0
hooks:
- id: nbstripout
name: 📓 nbstripout — optimizer notebooks
files: ^sdks/opik_optimizer/.*\.ipynb$
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.47.0
hooks:
- id: markdownlint
name: 📝 markdownlint — optimizer
files: ^sdks/opik_optimizer/.*\.md$
exclude: '^sdks/opik_optimizer/scripts/arc_agi/prompts/.*\.md$'
args: ['--disable=MD013', '--disable=MD033', '--disable=MD060']
- repo: https://github.com/codespell-project/codespell
rev: v2.4.1
hooks:
- id: codespell
name: 🔤 codespell — optimizer
files: ^sdks/opik_optimizer
exclude: '(\.ipynb$)|(\.json$)|(\.jsonl$)|(benchmark_results/)'
args: ['--skip=*.ipynb,*.json,*.jsonl','--write-changes']
- repo: local
hooks:
- id: radon-cc
name: 📊 radon cc — optimizer
entry: radon cc -s -a -n C sdks/opik_optimizer/src
language: python
types: [python]
files: ^sdks/opik_optimizer/src/
pass_filenames: false
additional_dependencies: [radon==6.0.1]
- id: radon-raw
name: 📊 radon raw — optimizer
entry: radon raw -s
language: python
types: [python]
files: ^sdks/opik_optimizer/src/
pass_filenames: true
additional_dependencies: [radon==6.0.1]
- id: xenon
name: 📊 xenon — optimizer
entry: bash -c 'set -o pipefail; xenon --max-absolute D --max-average C --max-modules C sdks/opik_optimizer/src | head -n 200'
language: python
types: [python]
files: ^sdks/opik_optimizer/src/
pass_filenames: false
additional_dependencies: [xenon==0.9.3]
- id: lizard
name: 📊 lizard — optimizer
entry: bash -c 'set -o pipefail; lizard -C 25 -l python -w sdks/opik_optimizer/src | head -n 200'
language: python
types: [python]
files: ^sdks/opik_optimizer/src/
pass_filenames: false
additional_dependencies: [lizard==1.19.0]
- repo: https://github.com/jendrikseipp/vulture
rev: v2.14
hooks:
- id: vulture
name: 🧹 vulture — optimizer
files: ^sdks/opik_optimizer
args: ['sdks/opik_optimizer/src', 'sdks/opik_optimizer/benchmarks', '--min-confidence=80', '--exclude=benchmarks/.venv']
# ---------------------------------------------------------------------------
# Guardrails backend (apps/opik-guardrails-backend)
# ---------------------------------------------------------------------------
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v6.0.0
hooks:
- id: trailing-whitespace
name: 🛡️ trim trailing whitespace — guardrails
files: ^apps/opik-guardrails-backend
- id: end-of-file-fixer
name: 🛡️ fix end of files — guardrails
files: ^apps/opik-guardrails-backend
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.14.14
hooks:
- id: ruff
name: 🛡️ ruff — guardrails
args: [ --fix, --show-fixes]
files: ^apps/opik-guardrails-backend
- id: ruff-format
name: 🛡️ ruff-format — guardrails
files: ^apps/opik-guardrails-backend
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.19.1
hooks:
- id: mypy
name: 🛡️ mypy — guardrails
files: ^apps/opik-guardrails-backend
# `exclude` option will work only from here.
# The rest of mypy configuration can be moved to pyproject.toml
exclude: '(^apps/opik-guardrails-backend/tests/)|(^apps/opik-guardrails-backend/scripts/)'
args: [--config-file, apps/opik-guardrails-backend/pyproject.toml]
# ---------------------------------------------------------------------------
# Helm chart docs
# ---------------------------------------------------------------------------
- repo: local
hooks:
- id: helm-docs
name: ⚓ helm-docs
language: docker_image
entry: jnorwood/helm-docs:v1.14.2
args:
- --chart-search-root=deployment/helm_chart/opik
files: (README\.md\.gotmpl|values\.yaml|Chart\.yaml)$
pass_filenames: false
- id: no-private-fe-plugins
name: block non-public FE plugins
language: system
entry: scripts/check-public-fe-plugins.sh
files: ^apps/opik-frontend/src/plugins/
pass_filenames: false
# ---------------------------------------------------------------------------
# Backend (Java) — Spotless, on changed files only (language: system → uses
# the repo's own Maven/JDK; only triggers for commits that touch .java).
# ---------------------------------------------------------------------------
- repo: local
hooks:
- id: spotless
name: ☕ spotless — java backend
entry: scripts/precommit-spotless.sh
language: system
files: ^apps/opik-backend/.*\.java$
require_serial: true
# ---------------------------------------------------------------------------
# Self-check: smoke-test the pre-commit wrapper scripts when any of them change,
# so a broken wrapper (regex/routing/flags) is caught before it ships.
# ---------------------------------------------------------------------------
- repo: local
hooks:
- id: precommit-wrapper-tests
name: 🧪 pre-commit wrapper smoke tests
entry: scripts/test_precommit_wrappers.sh
language: system
# Retrigger on the wrapper scripts, the desc resolver + its TSV data, and
# the config itself — so adding a hook (or renaming one) without a
# matching description entry fails the coverage test.
files: ^scripts/precommit-.*\.(sh|py|tsv)$|^scripts/test_precommit_wrappers\.sh$|^\.pre-commit-config\.yaml$
pass_filenames: false
# ---------------------------------------------------------------------------
# Frontend (apps/opik-frontend) — eslint --fix on changed files; whole-project
# typecheck (tsc can't be per-file: path aliases + cross-file inference).
# language: system → uses the repo's own node_modules; files-gated to src.
# ---------------------------------------------------------------------------
- repo: local
hooks:
- id: fe-eslint
name: 🌐 eslint — frontend
entry: scripts/precommit-fe-lint.sh
language: system
files: ^apps/opik-frontend/src/.*\.(ts|tsx|js|jsx|css|scss|sass)$
- id: fe-typecheck
name: 🌐 typecheck — frontend
entry: npm --prefix apps/opik-frontend run typecheck
language: system
files: ^apps/opik-frontend/src/.*\.(ts|tsx)$
pass_filenames: false
# ---------------------------------------------------------------------------
# TypeScript SDK (sdks/typescript) — eslint + whole-project typecheck.
# ---------------------------------------------------------------------------
- repo: local
hooks:
- id: ts-sdk-eslint
name: 📘 eslint — typescript sdk
entry: scripts/precommit-ts-sdk-lint.sh
language: system
files: ^sdks/typescript/.*\.(ts|tsx)$
- id: ts-sdk-typecheck
name: 📘 typecheck — typescript sdk
entry: npm --prefix sdks/typescript run typecheck
language: system
files: ^sdks/typescript/.*\.(ts|tsx)$
pass_filenames: false
# ---------------------------------------------------------------------------
# GitHub Actions workflows / composite actions — actionlint. Runs at the default
# info+ severity (no SHELLCHECK_OPTS), matching the floor set by OPIK-6584. The
# `language: golang` hook builds actionlint from the pinned source, so this hook
# (run by code_quality.yml) replaces the standalone actionlint.yml as the SSOT.
# ---------------------------------------------------------------------------
- repo: https://github.com/rhysd/actionlint
rev: v1.7.12
hooks:
- id: actionlint
name: ⚙️ actionlint — github workflows
# Workflows only — actionlint cannot lint composite `action.yml` files
# directly (they have no `jobs:`/`on:`); those are validated transitively
# when a workflow that `uses:` them is linted. Matches actionlint's own
# default files pattern.
files: ^\.github/workflows/.+\.(yml|yaml)$
# ---------------------------------------------------------------------------
# Dockerfiles — hadolint. The docker-image hook needs only Docker (no local
# binary), matching CI runners. Runs hadolint's default rule set (failure
# threshold `info`); the few deliberate exceptions are `# hadolint ignore=`
# comments inline in the Dockerfiles, so no repo-level config file is needed.
# ---------------------------------------------------------------------------
- repo: https://github.com/hadolint/hadolint
rev: v2.14.0
hooks:
- id: hadolint-docker
name: 🐳 hadolint — dockerfiles
# Explicit files: regex (not the upstream `types: [dockerfile]`) so the
# CI matrix builder in scripts/precommit-detect-hooks.py can route a
# changed Dockerfile to this leg — it matches on paths, not content type.
files: (^|/)Dockerfile(\..+)?$
# ---------------------------------------------------------------------------
# GitHub Actions workflows / composite actions — zizmor (Trail of Bits). The
# security counterpart to actionlint: actionlint asks "will this YAML run?",
# zizmor asks "if it runs, can it be exploited?" (template injection, dangerous
# triggers, excessive GITHUB_TOKEN permissions, cache poisoning). Runs offline
# (no GitHub API calls → no rate limits) at high severity, regular persona (the
# low-false-positive default). Rule tuning lives in .github/zizmor.yml
# (auto-discovered), where unpinned-uses is disabled pending the SHA-pinning
# follow-up. The pre-commit repo tag pins the zizmor version (v1.27.0 →
# zizmor==1.27.0). See OPIK-6366.
# ---------------------------------------------------------------------------
- repo: https://github.com/zizmorcore/zizmor-pre-commit
rev: v1.27.0
hooks:
- id: zizmor
name: 🌈 zizmor — github workflows security
args: ["--offline", "--min-severity", "high", "--persona", "regular", "--no-progress"]
# Explicit files: regex (not the upstream `types: [yaml]`) so the CI
# matrix builder in scripts/precommit-detect-hooks.py can route a changed
# workflow / composite action to this leg by path. Covers both workflows
# and composite `action.yml`/`action.yaml` files (zizmor audits both).
files: (^\.github/workflows/.+\.(yml|yaml)$)|((^|/)action\.(yml|yaml)$)
...