-
Notifications
You must be signed in to change notification settings - Fork 38
/
Copy path.pre-commit-config.yaml
220 lines (199 loc) · 6.8 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
exclude: ^misc/bench.py$
default_language_version:
rust: 1.68.0
node: 18.12.0
repos:
##############
# Common stuff
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0 # Use the ref you want to point at
hooks:
- id: mixed-line-ending
alias: eol
- id: trailing-whitespace
- id: end-of-file-fixer
alias: eof
- repo: local
hooks:
# - id: releaser
# name: releaser
# entry: python ./misc/releaser.py check
# language: python
# language_version: python3
# pass_filenames: false
# require_serial: true
- id: license_headers
name: license_headers
alias: headers
entry: python ./misc/license_headers.py add
language: python
language_version: python3
# see: https://github.com/pre-commit/identify/blob/master/identify/extensions.py
types_or: [ python, pyi, sql, rust, vue, ts, tsx, javascript, jsx ]
- repo: https://github.com/adrienverge/yamllint
rev: v1.29.0
hooks:
- id: yamllint
- repo: https://github.com/streetsidesoftware/cspell-cli
rev: v6.30.1
hooks:
- id: cspell
stages:
- manual
args:
- --config=./.cspell/cspell.config.yml
- --no-progress
- --dot
- --no-must-find-files
- --no-summary
- --gitignore
additional_dependencies:
- "@cspell/dict-en_us"
- "@cspell/dict-fr-fr"
- "@cspell/dict-fr-reforme"
- "@cspell/dict-bash"
- "@cspell/dict-shell"
- "@cspell/dict-win32"
########
# Python
# Long story short we cannot use pre-commit isolated venv system for mypy
# given mypy requires to have access to the project dependencies.
# We used to specify the list of dependencies actually needed by mypy as
# additional dependencies to install before running the pre-commit but it
# was incredibly error-prone and create random breakages.
# Instead we go the pragmatic way by calling mypy trough poetry:
# - `poetry run` will stick to the shell current virtual env
# - if the shell is not into a virtual env, poetry will create one and install Parsec&deps
# - lastly, mypy is started
# So this is similar to what the developer does when running mypy from it dev shell \o/
#
# Now that we use poetry to run mypy, why not also use it for ruff & black !
# This have the following benefits:
# - It prevents going out of sync in tools version between pre-commit-config
# and poetry.lock
# - It saves time on initial run because we don't have to create isolated
# virtualenv for those tools
# - Pre-commit hook are really simple, so it's no big deal to inline them.
# - Pre-commit hook need sometime tweaks (e.g. ruff hook not correctly
# handling .pyi), it's more readable then to have all the config here then.
- repo: local
hooks:
- id: ruff
name: ruff (using `poetry run ruff`)
entry: poetry run ruff
require_serial: true
language: system
types_or: [ python, pyi ]
args:
[
--extend-exclude=parsec/core/gui/_resources_rc.py,
--extend-exclude=parsec/core/gui/ui/*,
--extend-exclude=oxidation/*,
--fix,
]
- id: black
name: black (using `poetry run black`)
entry: poetry run black
require_serial: true
language: system
types_or: [ python, pyi ]
args:
[
--line-length=100,
--exclude=parsec/core/gui/_resources_rc.py,
--exclude=parsec/core/gui/ui/,
]
- id: mypy
name: Mypy (using `poetry run mypy`)
entry: poetry run mypy
require_serial: true
language: system
types_or: [ python, pyi ]
files: ^(parsec|tests|misc)/
######
# Rust
- repo: local
hooks:
- id: fmt
name: fmt
entry: cargo fmt
language: system
types: [ rust ]
args: [ -- ]
- id: clippy
name: clippy
entry: cargo clippy
language: system
types: [ rust ]
pass_filenames: false
args:
[
--workspace,
--tests,
--bins,
--lib,
--exclude=libparsec_bindings_android,
--exclude=libparsec_bindings_web,
--exclude=libparsec_bindings_electron,
--,
--deny=warnings,
--deny=clippy::undocumented_unsafe_blocks,
]
####
# Js
- repo: local
hooks:
- id: eslint
name: eslint
entry: eslint
language: node
files: ^oxidation/client/
# see: https://github.com/pre-commit/identify/blob/master/identify/extensions.py
types_or: [ vue, ts, tsx, javascript, jsx ]
args: [ --config=oxidation/client/.eslintrc.cjs ]
stages:
- manual
# Deps should be kept updated with `oxidation/client/package-lock.json` !
additional_dependencies:
- "@intlify/[email protected]"
- "@typescript-eslint/[email protected]"
- "@typescript-eslint/[email protected]"
- "@vue/[email protected]"
######
# JSON
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.22.0
hooks:
- id: check-jsonschema
name: Validate protocol files with jsonschema
alias: check-protocol-schema
types_or: [ json5 ]
files: ^oxidation/libparsec/crates/protocol/schema/
args: [ --schemafile, json_schema/protocol.schema.json ]
additional_dependencies: [ json5 ]
- id: check-jsonschema
name: Validate data files with jsonschema
alias: check-data-schema
types_or: [ json5 ]
files: ^oxidation/libparsec/crates/types/schema/
args: [ --schemafile, json_schema/data.schema.json ]
additional_dependencies: [ json5 ]
- id: check-metaschema
files: ^json_schema/
- id: check-jsonschema
name: Validate Read the doc configuration files
alias: check-readthedoc
files: .readthedocs.yml
args: [ --schemafile, https://raw.githubusercontent.com/readthedocs/readthedocs.org/main/readthedocs/rtd_tests/fixtures/spec/v2/schema.json ]
- id: check-jsonschema
name: Validate snapcraft config
alias: check-snapcraft
files: ^packaging/snap/snap/snapcraft.yaml
args: [ --schemafile, https://raw.githubusercontent.com/snapcore/snapcraft/main/schema/snapcraft.json ]