-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy path.pre-commit-config.yaml
More file actions
150 lines (140 loc) · 5.13 KB
/
Copy path.pre-commit-config.yaml
File metadata and controls
150 lines (140 loc) · 5.13 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
default_install_hook_types: [pre-commit, pre-push, commit-msg]
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.15.7
hooks:
# Run the linter.
- id: ruff
args: [--fix]
exclude: "sdk/python|.*\\.ipynb$"
# Run the formatter.
- id: ruff-format
exclude: "sdk/python"
- repo: local
hooks:
- id: ty
name: Run ty typechecks
entry: bash tools/lint/run-ty-check.sh
language: system
pass_filenames: false
types: [python]
- repo: local
hooks:
- id: openapi-generator
# Generate openapi spec for platform
name: Generate NeMo Platform OpenAPI Specification
language: system
entry: bash script/generate-openapi-spec.sh
pass_filenames: false
# The list below does necessarily need to be comprehensive.
# The more comprehensive the list, the lower the likelihood of pushing changes without OpenAPI spec updates,
# which results in failed CI pipelines.
files: |
(?x)^(
# NMP Common schemas
packages/nmp_common/src/nmp_common/datamodel/.*|
packages/nmp_common/src/nmp_common/api/.*|
# Individual microservices
services/evaluator/src/evaluator/api/.*|
services/guardrails/src/guardrails/api/.*|
services/core/infrastructure/jobs/src/jobs/api/.*|
# First-party plugins — each plugin's spec lands in plugins/<dir>/openapi/openapi.yaml.
# pyproject.toml is included because [tool.nemo.openapi] there controls opt-in.
plugins/[^/]+/src/.*|
plugins/[^/]+/pyproject\.toml|
)$
stages: [manual]
- repo: local
hooks:
- id: config-reference-docs
name: Check config reference doc is up to date
entry: bash -c 'uv run generate-config-docs && git diff --exit-code docs/set-up/config-reference.mdx'
language: system
pass_filenames: false
files: |
(?x)^(
script/generate_config_docs\.py|
packages/nmp_common/.*|
services/.*/src/.*/config\.py|
docs/set-up/config-reference\.mdx
)$
- repo: https://github.com/norwoodj/helm-docs
# The container itself is 'latest' no matter what here
rev: "v1.14.2"
hooks:
- id: helm-docs-container
files: |
(?x)^(
k8s/helm/values\.yaml|
k8s/helm/Chart\.yaml|
k8s/helm/helm-docs-template/nemo-helm-readme\.md\.gotmpl
)$
args:
- --chart-search-root=k8s/helm/
- --template-files=k8s/helm/helm-docs-template/nemo-helm-readme.md.gotmpl
- repo: local
hooks:
- id: uv-lock
name: Run uv lock
entry: uv lock
language: system
files: 'pyproject\.toml$'
pass_filenames: false
verbose: true
- id: uv-lock-check
name: Check for uv.lock drift
entry: git diff --exit-code uv.lock
language: system
files: 'pyproject\.toml$'
pass_filenames: false
verbose: true
- id: copyright-fix
name: Fix copyright headers
entry: uv run script/copyright_fixer.py
language: system
pass_filenames: true
files: '\.(py|ts)$'
- id: check-signoff
name: Check commit is signed off (DCO)
entry: "grep -qE '^Signed-off-by: .+ <.+>'"
language: system
stages: [commit-msg]
always_run: true
# Studio
- repo: local
hooks:
- id: studio-lint-staged
name: Run UI lint-staged
entry: bash -c '[ -n "$CI" ] && exit 0; command -v pnpm >/dev/null 2>&1 || { echo "pnpm not installed, skipping lint-staged (see web/README.md for setup)"; exit 0; }; cd web && pnpm lint-staged'
language: system
files: ^web/
pass_filenames: false
stages: [pre-commit]
- repo: local
hooks:
- id: studio-typecheck
name: Run UI typecheck
entry: bash -c '[ -n "$CI" ] && exit 0; command -v pnpm >/dev/null 2>&1 || { echo "pnpm not installed, skipping typecheck (see web/README.md for setup)"; exit 0; }; cd web && pnpm --filter="...[origin/main]" run --parallel --if-present typecheck'
language: system
files: ^web/
pass_filenames: false
stages: [pre-push]
- repo: local
hooks:
- id: no-nmp-common-in-plugins
name: Plugins must not import from nmp-common
# If this fails: check whether the function/class you need already exists in
# nemo_platform_plugin (packages/nemo_platform_plugin). If it does, import
# from there instead. If it doesn't, move the code from nmp_common into
# nemo_platform_plugin so plugins can access it without depending on nmp_common.
entry: 'from nmp\.common|from nmp_common|import nmp\.common|import nmp_common'
language: pygrep
files: ^plugins/.*\.py$
exclude: __pycache__
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v6.0.0
hooks:
- id: check-merge-conflict
args:
- --assume-in-merge