-
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 (234 loc) · 8.59 KB
/
.pre-commit-config.yaml
File metadata and controls
259 lines (234 loc) · 8.59 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
# SPDX-FileCopyrightText: Contributors to the HPCToolkit Project
#
# SPDX-License-Identifier: Apache-2.0
default_language_version:
python: python3
default_install_hook_types: [pre-commit, commit-msg]
default_stages: [pre-commit]
# NB: The hooks in this file are listed in a particular order to reduce the number of times
# pre-commit has to run before getting an all-clear.
repos:
# ------------------------------------------------------------------------------------
# Automation hooks: Hooks that can alter the semantics of files
# ------------------------------------------------------------------------------------
- repo: https://github.com/asottile/pyupgrade
rev: v3.17.0
hooks:
# Automatically elide older Python syntax and replace with newer ones
- id: pyupgrade
args: [--py38-plus]
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: 'v0.6.8'
hooks:
# Run a number of Python linters in Rust. Not completely feature-parity with Python-based linters,
# but can autofix a number of issues before they run. Also wicked fast.
- id: ruff
args: [--target-version=py38, --fix]
# ------------------------------------------------------------------------------------
# Formatting hooks: Hooks that alter the syntax but not semantics of files
# ------------------------------------------------------------------------------------
- repo: https://github.com/psf/black
rev: '24.8.0'
hooks:
# Blacken all Python code
- id: black
args: ['--target-version=py38']
exclude: &newpy_files '^ci/perf_report\.py$'
- id: black
files: *newpy_files
- repo: https://github.com/PyCQA/isort
rev: 5.13.2
hooks:
# Sort imports in all the Python code
- id: isort
args: [--profile, black]
- repo: local
hooks:
# Format all Meson code with a consistent style
- id: meson-format
name: meson format
entry: meson format
args: [--inplace, --configuration=./meson.format]
language: python
types: [text] # TODO: This should be just [meson] but that doesn't cover new Meson filenames
files: (^|/)(meson\.(build|options|format)|meson_options\.txt)$
additional_dependencies:
- meson ==1.5.2
- repo: https://github.com/executablebooks/mdformat
rev: 0.7.22
hooks:
# Format CommonMark (Markdown) files to have a consistent style.
- id: mdformat
exclude: ^(doc/src/|doc/FORMATS\.md$|LICENSE\.md$|\.gitlab/)
additional_dependencies:
- mdformat-tables ==1.0.0
# FORMATS.md is carefully crafted for viewing in a terminal (i.e. unrendered)
- id: mdformat
files: ^doc/FORMATS\.md$
args: [--wrap=80, --number]
additional_dependencies:
- mdformat-tables ==1.0.0
# Format MyST (CommonMark for Sphinx) files to have a consistent style.
- id: mdformat
files: ^doc/src/
additional_dependencies:
- mdformat-myst ==0.2.1
- mdformat-deflist ==0.1.3
# Format GFM (CommmonMark for GitHub/GitLab) files to have a consistent style.
- id: mdformat
files: ^\.gitlab/
additional_dependencies:
- mdformat-gfm ==0.4.1
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
# Format JSON files to have a consistent style.
- id: pretty-format-json
args: ['--autofix', '--no-ensure-ascii', '--top-keys=name,id']
# Remove trailing whitespace
- id: trailing-whitespace
exclude: &vendored |
(?x)^(
.*/[^/]+\.patch | # Patches
subprojects/valgrind-headers/.*/[^/]+\.h | # External Valgrind headers
tests/data/dbase/[^/]+\.d/.* | # Generated test data
tests/data/meas/[^/]+\.m/.* | # Generated test data
tests/data/struct/[^/]+\.hpcstruct | # Generated test data
)$
# All files must end in a single newline (or be perfectly empty)
- id: end-of-file-fixer
exclude: *vendored
# Remove the UTF8 BOM from the start of any files
- id: fix-byte-order-marker
# Ensure files have consistent endings. (This operates in the worktree, Git also normalizes the index)
- id: mixed-line-ending
# ------------------------------------------------------------------------------------
# Linting hooks: Hooks that do not alter files but checks that they satisfy various conditions
# ------------------------------------------------------------------------------------
- repo: meta
hooks:
# Check that hooks listed actually do something
- id: check-hooks-apply
# Check that any excludes do indeed exclude something
- id: check-useless-excludes
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
# Ensure all executable scripts have a shebang
- id: check-executables-have-shebangs
# Ensure symlinks always point to something
# - id: check-symlinks
# Warn if symlinks are ever accidentally destroyed
- id: destroyed-symlinks
# Ensure conflict markers are never committed anywhere
- id: check-merge-conflict
# Ensure files do not differ only in case (problematic on some filesystems)
- id: check-case-conflict
# Reminder to always work in a branch separate from the main two
- id: no-commit-to-branch
args: [--branch, master, --branch, develop]
- repo: https://github.com/editorconfig-checker/editorconfig-checker.python
rev: '3.0.3'
hooks:
# Run a separate checker to ensure the .editorconfig rules are being followed
- id: editorconfig-checker
alias: ec
args: [-disable-indent-size, -disable-max-line-length]
exclude: *vendored
- repo: https://github.com/python-poetry/poetry
rev: '1.8.0'
hooks:
# Ensure the pyproject.toml files are valid for Poetry
- id: poetry-check
args: [-C, src/hpctesttool/, --lock]
- repo: https://github.com/netromdk/vermin
rev: v1.6.0
hooks:
# Check that the Python code doesn't require a newer version than expected
- id: vermin
args:
- --target=3.8-
- --eval-annotations
- --parse-comments
- --violations
- -vvv
exclude: *newpy_files
- repo: https://github.com/jendrikseipp/vulture
rev: v2.12
hooks:
# Check that there isn't any dead Python code lying around
- id: vulture
args: ['src/hpctesttool']
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.11.2
hooks:
# Run static checks on the Python code
- id: mypy
args:
- --config-file=src/hpctesttool/pyproject.toml
# - --scripts-are-modules
# NB: The MyPy cache needs to be disabled (--no-incremental) to dodge
# https://github.com/python/mypy/issues/12664 which affects ruamel.yaml
- --no-incremental
- --show-column-numbers
- --pretty
files: '^src/hpctesttool'
additional_dependencies:
- pytest >=7.3.2, <8
- ruamel.yaml >=0.17.16, <0.18
- click >=8.1.5, <9
- pyparsing >=3.0.9, <4
- Jinja2 >=3.1, <4
- id: mypy
exclude: '^src/hpctesttool/'
args: [--scripts-are-modules, --pretty]
- repo: https://github.com/pylint-dev/pylint
rev: v3.3.1
hooks:
# Run the aggressive static Python linter
- id: pylint
args: ['--rcfile=src/hpctesttool/pyproject.toml']
files: '^src/hpctesttool/'
additional_dependencies:
- ruamel.yaml >=0.17.32, <0.18
- pylint-pytest
- id: pylint
exclude: '^src/hpctesttool/'
args: [--disable=line-too-long]
- repo: https://github.com/shellcheck-py/shellcheck-py
rev: v0.10.0.1
hooks:
# Find common errors in shell scripts using shellcheck
- id: shellcheck
args: ['--exclude=SC2154']
- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
hooks:
# Identify common spelling mistakes in code and comments
- id: codespell
stages: [pre-commit, commit-msg]
args:
# HSA is part of the ROCm software stack. codespell mistakes it for "has".
# InsId is a type name from GTPin. codespell mistakes it for "inside".
# "copyin" is a shorthand used in the GPU bits. codespell considers it a typo.
- --ignore-words-list=hsa,insid,copyin,valu
# Wil Phan is one of our staff members. codespell mistakes it for "will/well".
- --ignore-regex=\b(Wil\s+Phan)\b
exclude: |
(?x)^(
doc/dtd/mathml/.*\.ent | # MathML follows LaTeX's habit of funny names for math symbols
subprojects/valgrind-headers/.*/[^/]+\.h | # External Valgrind headers
.*\.svg | # Images
subprojects/packagefiles/elfutils/libcpu/.*\.mnemonics | # Lists of weird ISA symbols
)$
- repo: https://github.com/Yelp/detect-secrets
rev: v1.5.0
hooks:
# Scan for secrets that should never appear in the repo itself
- id: detect-secrets
exclude: |
(?x)^(
.*\.hpcstruct | # Structfiles have lots of high-entropy strings
subprojects/[^/]+\.wrap | # Wraps almost always contain SHA256 hashes
subprojects/md5-g72cf2cd/tests\.c | # Contains a number of precomputed MD5 hashes
)$