-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.pre-commit-config.yaml
More file actions
210 lines (194 loc) · 7.19 KB
/
.pre-commit-config.yaml
File metadata and controls
210 lines (194 loc) · 7.19 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
# Pre-commit hooks configuration
# Install: pre-commit install && pre-commit install --hook-type commit-msg
# Run manually: pre-commit run --all-files
# Update hooks: pre-commit autoupdate
# Docs: https://pre-commit.com/
default_language_version:
python: python3.13
default_stages: [pre-commit]
repos:
# =============================================================================
# Code Quality - Ruff (Fast Python linter and formatter)
# =============================================================================
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.8.4
hooks:
- id: ruff
name: ruff-lint
args: [--fix, --exit-non-zero-on-fix]
types_or: [python, pyi]
- id: ruff-format
name: ruff-format
types_or: [python, pyi]
# =============================================================================
# Type Checking - MyPy
# =============================================================================
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.13.0
hooks:
- id: mypy
name: mypy-typecheck
additional_dependencies:
- pydantic>=2.9.0
- pydantic-settings>=2.6.0
- sqlmodel>=0.0.22
- fastapi>=0.115.0
- types-passlib
- types-redis
args: [--config-file=pyproject.toml]
pass_filenames: false
entry: mypy src/
stages: [pre-commit]
# =============================================================================
# General Hooks - File hygiene
# =============================================================================
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: trailing-whitespace
exclude: ^(.*\.md|.*\.lock|.*\.snap)$
- id: end-of-file-fixer
exclude: ^(.*\.lock|.*\.snap)$
- id: check-yaml
args: [--unsafe]
exclude: ^(deployments/helm/.*|\.github/workflows/.*)$
- id: check-toml
- id: check-json
exclude: ^(.*\.postman_.*)$
- id: check-added-large-files
args: [--maxkb=1000]
- id: check-merge-conflict
- id: detect-private-key
- id: debug-statements
- id: check-case-conflict
- id: check-ast
- id: check-docstring-first
- id: check-executables-have-shebangs
- id: check-shebang-scripts-are-executable
- id: check-symlinks
- id: destroyed-symlinks
- id: mixed-line-ending
args: [--fix=lf]
- id: no-commit-to-branch
args: [--branch, main, --branch, master, --branch, production]
# =============================================================================
# Security - Bandit SAST
# =============================================================================
- repo: https://github.com/PyCQA/bandit
rev: 1.8.0
hooks:
- id: bandit
name: bandit-security
args: [-c, pyproject.toml, -r, src/, -ll]
additional_dependencies: ["bandit[toml]"]
# =============================================================================
# Security - Detect Secrets
# =============================================================================
- repo: https://github.com/Yelp/detect-secrets
rev: v1.5.0
hooks:
- id: detect-secrets
name: detect-secrets
args: [--baseline, .secrets.baseline]
exclude: |
(?x)^(
uv\.lock|
.*\.postman_.*\.json|
tests/.*|
\.secrets\.baseline
)$
# =============================================================================
# Commit Message - Conventional Commits
# =============================================================================
- repo: https://github.com/commitizen-tools/commitizen
rev: v4.1.0
hooks:
- id: commitizen
name: commitizen-check
stages: [commit-msg]
# =============================================================================
# GitHub Actions/Workflows Validation
# =============================================================================
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.30.0
hooks:
- id: check-github-workflows
name: validate-github-workflows
args: [--verbose]
- id: check-github-actions
name: validate-github-actions
args: [--verbose]
# =============================================================================
# Markdown Linting
# =============================================================================
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.43.0
hooks:
- id: markdownlint
name: markdownlint
args: [--fix, --disable, MD013, MD033, MD041, --]
exclude: |
(?x)^(
CHANGELOG\.md|
docs/.*
)$
# =============================================================================
# Dockerfile Linting
# =============================================================================
- repo: https://github.com/hadolint/hadolint
rev: v2.12.0
hooks:
- id: hadolint-docker
name: hadolint
args: [--ignore, DL3008, --ignore, DL3009, --ignore, DL3013]
# =============================================================================
# YAML Linting
# =============================================================================
- repo: https://github.com/adrienverge/yamllint
rev: v1.35.1
hooks:
- id: yamllint
name: yamllint
args: [-c, .yamllint.yml]
exclude: |
(?x)^(
deployments/helm/.*|
\.github/workflows/.*
)$
# =============================================================================
# Shell Script Linting
# =============================================================================
- repo: https://github.com/shellcheck-py/shellcheck-py
rev: v0.10.0.1
hooks:
- id: shellcheck
name: shellcheck
args: [--severity=warning]
# =============================================================================
# Terraform Validation (if applicable)
# =============================================================================
- repo: https://github.com/antonbabenko/pre-commit-terraform
rev: v1.96.2
hooks:
- id: terraform_fmt
name: terraform-fmt
- id: terraform_validate
name: terraform-validate
args: [--hook-config=--retry-once-with-cleanup=true]
- id: terraform_tflint
name: terraform-tflint
args: [--args=--config=__GIT_WORKING_DIR__/.tflint.hcl]
# =============================================================================
# Python Import Sorting (backup if ruff misses)
# =============================================================================
- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort
name: isort-imports
args: [--profile, black, --skip-glob, "**/generated/*"]
ci:
autofix_commit_msg: "style: auto-fix by pre-commit hooks [skip ci]"
autoupdate_commit_msg: "chore(deps): update pre-commit hooks"
skip: [no-commit-to-branch, mypy, terraform_validate, terraform_tflint]
autoupdate_schedule: weekly