forked from aristanetworks/avd
-
Notifications
You must be signed in to change notification settings - Fork 1
/
.pre-commit-config.yaml
235 lines (214 loc) · 9.94 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
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
ci:
autoupdate_commit_msg: "Bump: pre-commit autoupdate"
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: trailing-whitespace
name: Trims trailing whitespace.
exclude: ansible_collections/arista/avd/molecule
- id: end-of-file-fixer
name: Ensures that a file is either empty, or ends with one newline.
exclude_types: [svg, json]
exclude: ansible_collections/arista/avd/molecule
- id: check-added-large-files
name: Prevents giant files from being committed.
exclude: (ansible_collections/arista/avd/molecule|pickle$)
- id: check-merge-conflict
name: Checks for files that contain merge conflict strings.
exclude: ansible_collections/arista/avd/molecule
- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.5.5
hooks:
- id: insert-license
name: Check and insert license on Python files.
exclude: ansible_collections/arista/avd/(plugins/module_utils|tests/unit(/module_utils|/modules|))/__init__.py
files: .*\.py$
args:
- --license-filepath
- development/license-short.txt
- --use-current-year
- --allow-past-years
- --fuzzy-match-generates-todo
- --no-extra-eol
- id: insert-license
name: Check and insert license on select YAML files.
files: ansible_collections/arista/avd/roles/.*/(handlers|schemas|tasks)/.*\.yml$
args:
- --license-filepath
- development/license-short.txt
- --use-current-year
- --allow-past-years
- --fuzzy-match-generates-todo
- --no-extra-eol
- id: insert-license
name: Check and insert license on Jinja2 files.
files: .*\.j2$
exclude: ansible_collections/arista/avd/molecule.*
args:
- --license-filepath
- development/license-short.txt
- --use-current-year
- --allow-past-years
- --fuzzy-match-generates-todo
- --comment-style
- '{#||#}'
- --no-extra-eol
- id: insert-license
name: Check and insert license on Markdown files.
files: .*\.md$
exclude: (ansible_collections/arista/avd/molecule|.github|ansible_collections/arista/avd/examples/.+/documentation/).*
args:
- --license-filepath
- development/license-short.txt
- --use-current-year
- --allow-past-years
- --fuzzy-match-generates-todo
- --comment-style
- '<!--| ~| -->'
# - repo: https://github.com/pre-commit/mirrors-autopep8
# rev: 'v1.5.6' # Use the sha / tag you want to point at
# hooks:
# - id: autopep8
- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort
name: Check for changes when running isort on all python files.
- repo: https://github.com/psf/black
rev: 24.4.2
hooks:
- id: black
name: Check for changes when running Black on all python files.
- repo: https://github.com/pycqa/flake8
rev: 7.0.0
hooks:
- id: flake8
name: Check for Flake8 errors on Python files.
# ignoring errors and selecting line length as per
# https://github.com/ansible/ansible/blob/devel/test/lib/ansible_test/_util/controller/sanity/pep8/current-ignore.txt
types: [python]
# The cv client api is generated from proto files, so it should not be linted.
exclude: ^python-avd/pyavd/_cv/api
- repo: https://github.com/pycqa/pylint
rev: "v3.1.1"
hooks:
- id: pylint # Use pylintrc file in repository
name: Check for Linting errors on Python files outside the Ansible collection.
description: This hook runs pylint.
types: [python]
args:
# Suppress duplicate code for modules header
- -d duplicate-code
- id: pylint # Use pylintrc file in Ansible collection
name: Check for Linting errors on Python files in the Ansible collection.
description: This hook runs pylint.
types: [python]
files: ansible_collections/arista/avd/
args:
- --rcfile=ansible_collections/arista/avd/pylintrc
# Suppress duplicate code for modules header
- -d duplicate-code
- repo: https://github.com/adrienverge/yamllint.git
rev: "v1.35.1"
hooks:
- id: yamllint
name: Check for Linting errors on YAML files with settings defined in `.github/yamllintrc`.
description: This hook runs yamllint.
entry: yamllint
language: python
types: [file, yaml]
args: [--strict, -c=.github/yamllintrc]
- repo: https://github.com/aristanetworks/j2lint.git
rev: "v1.1.0"
hooks:
- id: j2lint
name: Check for Linting errors on Jinja2 files
- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
hooks:
- id: codespell
name: Check for common misspellings in text files.
entry: codespell
language: python
types: [text]
args:
- '--ignore-words=.github/ignore-codespell-words' # Ignore words listed in this file
exclude: > # List of regex patterns for files/directories to exclude
(?x)^(
.*\.cfg| # Exclude all .cfg files
.*\.svg| # Exclude all .svg files
.*\.excalidraw| # Exclude all .excalidraw files
.*\.rst| # Exclude all .rst files
python-avd/pyavd/vendor/.*| # Exclude all files in this directory
ansible_collections/arista/avd/CHANGELOG.rst| # Exclude auto generated CHANGELOG.rst file
ansible_collections/arista/avd/changelogs/.*| # Exclude all files in this directory
ansible_collections/arista/avd/roles/.*/docs/tables/.*\.md| # Exclude all .md files in tables
python-avd/pyavd/.*/schema/.*schema\.yml| # Exclude YAML schemas file
python-avd/pyavd/.*/schema/.*jsonschema\.json| # Exclude JSON schemas file
python-avd/pyavd/_cv/api/.*| # Exclude auto generated files for CV API
python-avd/pyavd/_cv/extra_cv_protos/.*| # Exclude extra CV proto files
ansible-avd/ansible_collections/arista/avd/docs/plugins/.* | # Excluded auto generated doc for Ansible plugins
)$
- repo: local
hooks:
- id: docs-plugin-modules
name: Build documentation for collection modules and action plugins.
entry: ansible-doc-extractor --template ansible_collections/arista/avd/docs/templates/plugin-docs.j2 --markdown "ansible_collections/arista/avd/docs/plugins/Modules_and_action_plugins/"
language: python
types: [python]
additional_dependencies: ['ansible-doc-extractor>=0.1.10', 'ansible-core>=2.15.0,<2.18.0']
files: ansible_collections/arista/avd/plugins/modules/
- id: docs-plugin-filter
name: Build documentation for collection filter plugins.
entry: ansible-doc-extractor --template ansible_collections/arista/avd/docs/templates/plugin-docs.j2 --markdown "ansible_collections/arista/avd/docs/plugins/Filter_plugins/"
language: python
types: [python]
additional_dependencies: ['ansible-doc-extractor>=0.1.10', 'ansible-core>=2.15.0,<2.18.0']
files: ansible_collections/arista/avd/plugins/filter/
- id: docs-plugin-lookup
name: Build documentation for collection lookup plugins.
entry: ansible-doc-extractor --template ansible_collections/arista/avd/docs/templates/plugin-docs.j2 --markdown "ansible_collections/arista/avd/docs/plugins/Lookup_plugins/"
language: python
types: [python]
additional_dependencies: ['ansible-doc-extractor>=0.1.10', 'ansible-core>=2.15.0,<2.18.0']
files: ansible_collections/arista/avd/plugins/lookup/
- id: docs-plugin-test
name: Build documentation for collection test plugins.
entry: ansible-doc-extractor --template ansible_collections/arista/avd/docs/templates/plugin-docs.j2 --markdown "ansible_collections/arista/avd/docs/plugins/Test_plugins/"
language: python
types: [python]
additional_dependencies: ['ansible-doc-extractor>=0.1.10', 'ansible-core>=2.15.0,<2.18.0']
files: ansible_collections/arista/avd/plugins/test/
- id: docs-plugin-vars
name: Build documentation for collection var plugins.
entry: ansible-doc-extractor --template ansible_collections/arista/avd/docs/templates/plugin-docs.j2 --markdown "ansible_collections/arista/avd/docs/plugins/Vars_plugins/"
language: python
types: [python]
additional_dependencies: ['ansible-doc-extractor>=0.1.10', 'ansible-core>=2.15.0,<2.18.0']
files: ansible_collections/arista/avd/plugins/vars/
- id: schemas
name: Build AVD schemas and documentation.
entry: sh -c 'exec python-avd/scripts/build-schemas.py'
language: python
files: python-avd/pyavd/[a-z_]+/schema
pass_filenames: false
additional_dependencies: ['deepmerge>=1.1.0', 'PyYAML>=6.0.0', 'pydantic>=2.3.0', 'jsonschema>=4.10.3', 'referencing>=0.35.0']
- id: templates
name: Precompile eos_cli_config_gen Jinja2
entry: sh -c 'python-avd/scripts/compile_templates.py'
language: python
files: python-avd/pyavd/_eos_cli_config_gen/j2templates/
pass_filenames: false
additional_dependencies: ['Jinja2>=3.0.0', 'cryptography>=38.0.4', 'deepmerge>=1.1.0', 'PyYAML>=6.0.0', 'pydantic>=2.3.0', 'jsonschema>=4.10.3', 'referencing>=0.35.0']
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.41.0
hooks:
- id: markdownlint
name: Check for Linting errors on Markdown files with settings defined in `.github/.markdownlint.yaml`.
args:
- --config=.github/.markdownlint.yaml
- --ignore-path=.github/.markdownlintignore
- --fix