forked from drivendataorg/cookiecutter-data-science
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.pre-commit-config.yaml
267 lines (242 loc) · 8.38 KB
/
.pre-commit-config.yaml
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
exclude: |
(?x)^(
docs/site/.*| # Exclude mkdocs compiled files
docs/docs/jupyter-notebooks_files/.*| # Exclude Jupyter Notebooks files
jupyter-experiments/.*| # Exclude jupyter-experiments
\.history/.*| # Exclude history files
.*cache.*/.*| # Exclude cache directories
.*venv.*/.*| # Exclude virtual environment directories
)$
fail_fast: true
default_language_version:
python: python3.12
default_install_hook_types:
- pre-commit
- commit-msg
repos:
#
# Documentation Here:
# https://gatlenculp.github.io/gatlens-opinionated-template/precommit/
#
# ---------------------------------------------------------------------------- #
# 🔄 Pre-Commit Hooks #
# ---------------------------------------------------------------------------- #
# ----------------------------- 🔒 Security Tools ---------------------------- #
- repo: https://github.com/gitleaks/gitleaks
rev: v8.22.1
hooks:
- id: gitleaks
name: "🔒 security · Detect hardcoded secrets"
# --------------------------- 🔍 Code Quality Tools -------------------------- #
### Python Tools ###
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.9.1
hooks:
- id: ruff-format
name: "🐍 python · Format with Ruff"
exclude: |
(?x)^(
.*\{\{.*\}\}.*| # Exclude any files with cookiecutter variable, this is an issue with ruff
)$
# STRICT
# - id: ruff
# name: "🐍 python · Lint and perform safe auto-fixes with Ruff"
# args: [--fix]
# STRICT
# - repo: https://github.com/RobertCraigie/pyright-python
# rev: v1.1.391
# hooks:
# - id: pyright
# name: "🐍 python · Check types"
- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.23
hooks:
- id: validate-pyproject
name: "🐍 python · Validate pyproject.toml"
additional_dependencies: ["validate-pyproject-schema-store[all]"]
### Javascript & Web Tools ###
- repo: https://github.com/biomejs/pre-commit
rev: "v0.6.1"
hooks:
- id: biome-check
name: "🟨 javascript · Lint, format, and safe fixes with Biome"
additional_dependencies: ["@biomejs/[email protected]"]
# Exclude FastAPI directories for now
exclude: |
(?x)^(
.*\{\{.*\}\}.*|
)$
### Data & Config Validation ###
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.31.0
hooks:
- id: check-github-workflows
name: "🐙 github-actions · Validate gh workflow files"
args: ["--verbose"]
- id: check-taskfile
name: "✅ taskfile · Validate Task configuration"
### Markdown ###
- repo: https://github.com/hukkin/mdformat
rev: 0.7.21
hooks:
- id: mdformat
name: "📝 markdown · Format markdown"
# Mdformat messes up jinja tags
exclude: |
(?x)^(
.*\{\{.*\}\}.*|
)$
additional_dependencies:
- mdformat-gfm
- mdformat-ruff
- mdformat-frontmatter
- ruff
# STRICT
# - repo: https://github.com/markdownlint/markdownlint
# rev: v0.12.0
# hooks:
# - id: markdownlint
# name: "📝 markdown · Lint markdown"
### Shell ###
# STRICT
# - repo: https://github.com/shellcheck-py/shellcheck-py
# rev: v0.10.0.1
# hooks:
# - id: shellcheck
# name: "🐚 shell · Lint shell scripts"
# STRICT
# - repo: https://github.com/openstack/bashate
# rev: 2.1.1
# hooks:
# - id: bashate
# name: "🐚 shell · Check shell script code style"
### Makefile ###
- repo: https://github.com/mrtazz/checkmake.git
rev: 0.2.2
hooks:
- id: checkmake
name: "🐮 Makefile · Lint Makefile"
# No clear documentation on how to skip certain checks.
# Fixed as many as I could, but best option is to ignore the file.
exclude: |
(?x)^(
.*\{\{.*\}\}.*|
)$
### SQL ###
- repo: https://github.com/sqlfluff/sqlfluff
rev: 3.3.0
hooks:
- id: sqlfluff-fix
name: "📊 SQL · Attempts to fix rule violations."
# STRICT
# - id: sqlfluff-lint
# name: "📊 SQL · Lint SQL code files"
### Notebooks ###
- repo: https://github.com/nbQA-dev/nbQA
rev: 1.9.1
hooks:
- id: nbqa
entry: nbqa mdformat
name: "📓 notebook · Format markdown cells"
args: ["--nbqa-md"]
types: [jupyter]
# Reading pyproject.toml in the template throws errors
exclude: |
(?x)^(
.*\{\{.*\}\}.*|
)$
additional_dependencies:
- mdformat
- mdformat-gfm
- mdformat-ruff
- mdformat-frontmatter
- ruff
# STRICT
# TODO: Convert to pyright
# - id: nbqa-mypy
# name: "📓 notebook · Type-check cells"
### PNG Images ###
- repo: https://github.com/shssoichiro/oxipng
rev: v9.1.3
hooks:
- id: oxipng
name: "🖼️ images · Optimize PNG files"
args: ["-o", "4", "--strip", "safe", "--alpha"]
### Additional File Types ###
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v4.0.0-alpha.8
hooks:
- id: prettier
name: "✨ misc-files · Format misc web files"
types_or: [yaml, html, scss]
additional_dependencies:
# ---------------------------- 📁 Filesystem Tools --------------------------- #
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
# Filesystem Checks
- id: check-executables-have-shebangs
name: "📁 filesystem/⚙️ exec · Verify shebang presence"
# Exclude FastAPI directories for now
exclude: |
(?x)^(
.*\{\{.*\}\}.*|
)$
- id: check-shebang-scripts-are-executable
name: "📁 filesystem/⚙️ exec · Verify script permissions"
- id: check-case-conflict
name: "📁 filesystem/📝 names · Check case sensitivity"
- id: check-illegal-windows-names
name: "📁 filesystem/📝 names · Validate Windows filenames"
- id: check-symlinks
name: "📁 filesystem/🔗 symlink · Check symlink validity"
- id: destroyed-symlinks
name: "📁 filesystem/🔗 symlink · Detect broken symlinks"
# ------------------------------- 🌳 Git Tools ------------------------------- #
- id: check-merge-conflict
name: "🌳 git · Detect conflict markers"
- id: forbid-new-submodules
name: "🌳 git · Prevent submodule creation"
- id: check-added-large-files
name: "🌳 git · Block large file commits"
args: ["--maxkb=5000"]
- id: no-commit-to-branch
alias: protect-main
name: "🌳 git · Protect main branches"
args: ["--branch", "main", "--branch", "master"]
# ---------------------------------------------------------------------------- #
# 📝 Commit Message Hooks #
# ---------------------------------------------------------------------------- #
#
# --------------------------- ✍️ Git Commit Quality -------------------------- #
### Commit Message Standards ###
- repo: https://github.com/commitizen-tools/commitizen
rev: v4.1.0
hooks:
- id: commitizen
name: "🌳 git · Validate commit message"
stages: [commit-msg]
additional_dependencies: [cz-conventional-gitmoji]
# ---------------------------------------------------------------------------- #
# 🧪 Fast Tests (Local) #
# ---------------------------------------------------------------------------- #
- repo: local
hooks:
- id: pytest-collect
name: 🧪 test · Validate test formatting
entry: ./.venv/bin/pytest tests
language: system
types: [python]
args: ["--collect-only"]
pass_filenames: false
always_run: true
# STRICT
- id: pytest-fast
name: 🧪 test · Run fast tests
entry: ./.venv/bin/pytest tests
language: system
types: [python]
args: ["--max-timeout=3"]
pass_filenames: false
always_run: true