-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.pre-commit-config.yaml
More file actions
259 lines (230 loc) · 9.61 KB
/
.pre-commit-config.yaml
File metadata and controls
259 lines (230 loc) · 9.61 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
# ======================================================================================
#
# ░▒▓███████▓▒░░▒▓████████▓▒░▒▓███████▓▒░ ░▒▓███████▓▒░ ░▒▓██████▓▒░▒▓████████▓▒░
# ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░
# ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░
# ░▒▓███████▓▒░░▒▓██████▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓███████▓▒░░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░
# ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░
# ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░
# ░▒▓███████▓▒░░▒▓████████▓▒░▒▓█▓▒░░▒▓█▓▒░ ░▒▓███████▓▒░ ░▒▓██████▓▒░ ░▒▓█▓▒░
#
# ======================================================================================
# config file for pre-commit: https://pre-commit.com/
#
# These hooks are run before each git commit, but can also be run on demand using
# `pre-commit run [--all-files]` or `just pc`
#
# To install the hooks to be automatically run by git when committing, run:
# `pre-commit install --install-hooks` or `just install`
#
# This is the preferred way to run all of these tools, because it is convenient to
# define configuration for all of them in this single file, and to define the order
# in which they should be run (we always auto-format *before* linting). In general,
# any tools that are available as pre-commit hooks are run using pre-commit, and for
# these tools, any configuration options settable as command-line arguments are
# specified in this file using the args: key. When a tool requires configuration file(s),
# then if it is possible to specify a custom filepath, we put the config file(s) in the
# config/ directory and specify that path as a command-line argument. Only if specifying
# a custom config file is not possible do we resort to putting it in the repo root.
#
# Note that running pre-commit may change files in the source tree. If a hook changes
# files, the pre-commit run exits with a failure code, and if a git commit was in
# progress, it is aborted.
default_language_version:
python: python3
default_install_hook_types: [pre-commit, pre-push, commit-msg]
default_stages: [pre-commit, pre-push]
fail_fast: false
minimum_pre_commit_version: 4.0.1
repos:
# pre-commit configuration meta-checks
- repo: meta
hooks:
- id: check-hooks-apply
always_run: true
- id: check-useless-excludes
always_run: true
# sync additional-dependencies version with repo rev where relevant
- repo: https://github.com/pre-commit/sync-pre-commit-deps
rev: v0.0.3
hooks:
- id: sync-pre-commit-deps
# local scripts
- repo: local
hooks:
# create build directory for cppcheck & logs directory
- id: cppcheck-build-dir
name: Create cache dir for cppcheck
language: system
entry: cmake -E make_directory Builds/cppcheck/ logs/
always_run: true
pass_filenames: false
# insert license header
- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.5.6
hooks:
# we have to run this step once for each different comment style
- id: insert-license
name: Insert license header in C++ source files
args: [--license-filepath=libbenbot/resources/res/license_header.txt, --comment-style=/*| *| */, --detect-license-in-X-top-lines=16]
types_or: [c, c++]
- id: insert-license
name: Insert license header in CMake files
args: [--license-filepath=libbenbot/resources/res/license_header.txt, --comment-style=#, --detect-license-in-X-top-lines=16]
types_or: [cmake, yaml, toml, ini, python, dockerfile, shell]
- id: insert-license
name: Insert license header in CMake and shell files
args: [--license-filepath=libbenbot/resources/res/license_header.txt, --comment-style=#, --detect-license-in-X-top-lines=16]
files: .git|.clang|.cfg|justfile|.editorconfig|requirements.txt|.dockerignore
exclude: config/.editorconfig-checker.json|.md|dependencies.txt
# auto-fix spelling mistakes
- repo: https://github.com/codespell-project/codespell
rev: v2.4.2
hooks:
- id: codespell
args: [--write-changes, --ignore-words=config/codespell_ignore.txt]
# C++ formatting & linting
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v22.1.4
hooks:
- id: clang-format
exclude_types: [json]
additional_dependencies: [clang-format>=22.1.4]
- repo: https://github.com/pocc/pre-commit-hooks
rev: v1.3.5
hooks:
- id: cppcheck
args: [--cppcheck-build-dir=Builds/cppcheck, --inline-suppr, --std=c++23, --check-level=exhaustive, --enable=all, --suppress=unusedFunction, --suppress=unusedStructMember, --suppress=unmatchedSuppression, --suppress=class_X_Y, --suppress=missingIncludeSystem, --suppress=missingInclude]
additional_dependencies: [cppcheck>=1.5.1]
exclude: .mm
- id: cpplint
args: [--verbose=0]
additional_dependencies: [cpplint>=2.0.2]
# CMake formatting & linting
- repo: https://github.com/cheshirekow/cmake-format-precommit
rev: v0.6.13
hooks:
- id: cmake-format
args: [--config-files, config/.cmake-format.json, --in-place]
- id: cmake-lint
args: [--config-files, config/.cmake-format.json]
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.37.2
hooks:
- id: check-github-workflows
- id: check-jsonschema
name: Validate CMake presets
args: [--schemafile, 'https://cmake.org/cmake/help/latest/_downloads/3e2d73bff478d88a7de0de736ba5e361/schema.json']
files: CMakePresets.json
# Python formatting & linting
- repo: https://github.com/asottile/pyupgrade
rev: v3.21.2
hooks:
- id: pyupgrade
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 26.3.1
hooks:
- id: black
# Dockerfile
- repo: https://github.com/hadolint/hadolint
rev: v2.14.0
hooks:
- id: hadolint
args: [--ignore, DL3003, --ignore, DL3008, --ignore, DL3045]
exclude: .dockerignore
# Bash scripts
- repo: https://github.com/shellcheck-py/shellcheck-py
rev: v0.11.0.1
hooks:
- id: shellcheck
# format justfile
- repo: local
hooks:
- id: format_justfile
name: Autoformat justfile
language: system
entry: just --fmt --unstable
files: justfile
pass_filenames: false
- id: pin_github_actions
name: Pin GitHub Action dependencies to commit hashes
language: system
entry: pin-github-action
args: [--continue-on-error]
files: .github/workflows/
types: [yaml]
# format .bib file
- repo: https://github.com/FlamingTempura/bibtex-tidy
rev: v1.14.0
hooks:
- id: bibtex-tidy
args: [--modify, --curly, --numeric, --months, --space=2, --blank-lines, --duplicates, --merge=combine, --strip-enclosing-braces, --drop-all-caps, --sort-fields, --no-strip-comments, --no-trailing-commas, --remove-empty-fields, --wrap=80]
# general
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v6.0.0
hooks:
- id: check-added-large-files
args: [--maxkb=64]
- id: check-case-conflict
- id: check-illegal-windows-names
- id: check-json
- id: check-merge-conflict
- id: check-shebang-scripts-are-executable
- id: check-toml
- id: check-vcs-permalinks
- id: check-yaml
- id: destroyed-symlinks
- id: detect-private-key
- id: end-of-file-fixer
- id: fix-byte-order-marker
- id: forbid-submodules
- id: mixed-line-ending
args: [--fix=lf]
- id: pretty-format-json
args: [--autofix, --indent=2]
- id: trailing-whitespace
args: [--markdown-linebreak-ext=md]
- repo: https://github.com/sirosen/texthooks
rev: 0.7.1
hooks:
- id: fix-ligatures
- id: fix-smartquotes
- id: fix-spaces
- id: forbid-bidi-controls
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks.git
rev: v2.16.0
hooks:
- id: pretty-format-ini
args: [--autofix]
- id: pretty-format-yaml
args: [--autofix, --preserve-quotes]
# check for dead links in markdown
- repo: https://github.com/AlexanderDokuchaev/md-dead-link-check
rev: "v1.3.0"
hooks:
- id: md-dead-link-check
args: [--config, config/link-checker.toml]
always_run: true
# check editorconfig rules
- repo: https://github.com/editorconfig-checker/editorconfig-checker.python
rev: 3.6.1
hooks:
- id: editorconfig-checker
args: [-config, config/.editorconfig-checker.json]
# lint commit message
- repo: https://github.com/jorisroovers/gitlint
rev: v0.19.1
hooks:
- id: gitlint
args: [--config, config/.gitlint, --msg-filename]
# manual-only hook
- repo: https://github.com/codingjoe/relint
rev: 3.3.1
hooks:
- id: relint
args: [-c, config/relint.yml]
stages: [manual]
ci:
autofix_commit_msg: 'chore: pre-commit autofix'
autoupdate_commit_msg: 'chore(deps): pre-commit autoupdate'
skip: [hadolint, format_justfile, bibtex-tidy, pin_github_actions, check-jsonschema, md-dead-link-check]