This repository was archived by the owner on Sep 3, 2025. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.pre-commit-config.yaml
More file actions
249 lines (220 loc) · 8.44 KB
/
.pre-commit-config.yaml
File metadata and controls
249 lines (220 loc) · 8.44 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
# ======================================================================================
# __ ____ __ __ ____ ___
# ( ) (_ _)( \/ )( ___)/ __)
# )(__ _)(_ ) ( )__) \__ \
# (____)(____)(_/\/\_)(____)(___/
#
# This file is part of the Limes open source library and is licensed under the terms of the GNU Public License.
#
# Commercial licenses are available; contact the maintainers at ben.the.vining@gmail.com to inquire for details.
#
# ======================================================================================
# config file for pre-commit: https://pre-commit.com/
#
# These plugins are run before each git commit, but can also be run on demand using:
# `pre-commit run --all-files`
#
# To install the hooks to be automatically run by git when committing, run:
# `pre-commit install --install-hooks`
#
# This is the preferred way to run all of these tools -- clang-format, clang-tidy,
# cppcheck, cmake-format, etc -- 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 plugins 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: [commit, push]
fail_fast: false
minimum_pre_commit_version: 2.20.0
ci:
skip: [cppcheck, check-jsonschema] # clang-tidy
autofix_commit_msg: 'style: pre-commit autofixes [skip ci]'
autoupdate_commit_msg: 'chore: pre-commit autoupdate [skip ci]'
repos:
# pre-commit configuration meta-checks
- repo: meta
hooks:
- id: check-hooks-apply
always_run: true
- id: check-useless-excludes
always_run: true
# Local scripts
- repo: local
hooks:
# create logs directory
# if a hook with a log file specified fails, the logs directory must exist or another error will be thrown
- id: logs-dir
name: Create logs directory
entry: cmake -E make_directory logs/pre-commit
language: system
always_run: true
pass_filenames: false
# make sure compile_commands.json exists for linters
# - id: compile-commands
# name: Set up compile_commands.json
# entry: cmake -P scripts/CreateCompileCommands.cmake
# language: system
# always_run: true
# pass_filenames: false
# create build directory for cppcheck
- id: cppcheck-build-dir
name: Create cache dir for cppcheck
entry: cmake -E make_directory Builds/cppcheck
language: system
always_run: true
pass_filenames: false
# only .json files allowed in cmake/presets/
- id: json-xtn-in-toolchain-dir
name: Ensure only .json files in cmake/presets/
entry: Files in the cmake/presets/ directory must have the .json extension
language: fail
files: cmake/presets/.*(?<!\.json)$
# only .yml files allowed in .github/workflows/
- id: yml-xtn-in-workflow-dir
name: Ensure only .yml files in .github/workflows/
entry: Files in the .github/workflows/ directory must have the .yml extension
language: fail
files: .github/workflows/.*(?<!\.yml)$
# Insert license header
- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.5.5
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=config/limes_header.txt, --comment-style=/*| *| */, --detect-license-in-X-top-lines=16]
types_or: [c, c++, objective-c]
- id: insert-license
name: Insert license header in CMake and shell files
args: [--license-filepath=config/limes_header.txt, --comment-style=#, --detect-license-in-X-top-lines=16]
types_or: [cmake, shell, python, yaml, toml, ini]
- id: insert-license
name: Insert license header in other config files
args: [--license-filepath=config/limes_header.txt, --comment-style=#, --detect-license-in-X-top-lines=16]
files: .envrc|.tool-versions|.bumpversion.cfg|.editorconfig|.gitignore|.gitattributes|.clang-format|.clang-tidy|.pre-commit-config.yaml
# C++ formatting & linting
- repo: https://github.com/finsberg/clang-format-docs
rev: v0.3.0
hooks:
- id: clang-format-docs
additional_dependencies: [clang-format]
files: '\.(md|h|doc)$'
- repo: https://github.com/pocc/pre-commit-hooks
rev: v1.3.5
hooks:
- id: clang-format
args: [--no-diff, --style=file, -i]
additional_dependencies: [clang-format]
- id: cppcheck
args: [--cppcheck-build-dir=Builds/cppcheck, --quiet, --inline-suppr, --std=c++20, --language=c++, --force, --enable=warning, --enable=style, --enable=performance, --enable=portability, --suppress=missingIncludeSystem, --suppress=preprocessorErrorDirective, --suppress=unknownMacro]
log_file: logs/pre-commit/cppcheck.log
types_or: [c, c++]
exclude: .mm
- id: cpplint
args: [--verbose=0, '--filter=-whitespace,-legal,-build/include,+build/include_order,-build/c++11,-build/header_guard,-build/explicit_make_pair,-runtime/references,-readability/braces,-readability/todo']
log_file: logs/pre-commit/cpplint.log
additional_dependencies: [cpplint]
# - id: clang-tidy
# args: [-p=Builds/compile-commands]
# log_file: logs/pre-commit/clang-tidy.log
# additional_dependencies: [clang-tidy]
# 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, --disabled-codes, E1120]
log_file: logs/pre-commit/cmake-lint.log
# General
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-added-large-files
args: [--maxkb=64]
- id: check-case-conflict
- id: check-json
- id: check-merge-conflict
- id: check-shebang-scripts-are-executable
- id: check-vcs-permalinks
- id: check-yaml
- id: destroyed-symlinks
- id: detect-private-key
- id: end-of-file-fixer
exclude: tests/data/lines.txt
- 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]
# text file linters
- repo: https://github.com/sirosen/texthooks
rev: 0.6.4
hooks:
- id: fix-ligatures
- id: fix-smartquotes
- id: forbid-bidi-controls
# Markdown
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.39.0
hooks:
- id: markdownlint-fix
args: [--disable, MD033, MD010, MD013]
# exclude: CHANGELOG.md
# various other formatters
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks.git
rev: v2.12.0
hooks:
- id: pretty-format-ini
args: [--autofix]
- id: pretty-format-yaml
args: [--autofix, --preserve-quotes]
# validate JSON/YAML schemas
- repo: https://github.com/sirosen/check-jsonschema
rev: 0.28.0
hooks:
- id: check-github-workflows
# - id: check-dependabot
- id: check-jsonschema
name: Validate CMake presets
args: [--schemafile, 'https://cmake.org/cmake/help/latest/_downloads/3e2d73bff478d88a7de0de736ba5e361/schema.json']
files: CMakePresets.json|config/toolchains/
types: [json]
# Git linting
- repo: https://github.com/jorisroovers/gitlint
rev: v0.19.1
hooks:
- id: gitlint
args: [--config, config/.gitlint, --msg-filename]
always_run: true
- repo: https://github.com/jumanjihouse/pre-commit-hooks.git
rev: 3.0.0
hooks:
- id: check-mailmap
- id: git-check
# check editorconfig rules
- repo: https://github.com/editorconfig-checker/editorconfig-checker.python
rev: 2.7.3
hooks:
- id: editorconfig-checker
args: [-ignore-defaults, -config, config/.ecrc]
# sign commit
- repo: https://github.com/mattlqx/pre-commit-sign
rev: v1.1.3
hooks:
- id: sign-commit