forked from xapi-project/xen-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.pre-commit-config.yaml
155 lines (146 loc) · 5.17 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
#
# Configuration of pre-commit, a Python framework for git hooks.
# pre-commit is run for each git push by GitHub CI. It can run
# locally as well for early feedback and automatic formatting
# like trailing whitespace removal (to be configured later):
#
## For only installing the package itself, run:
# pip3 install pre-commit
#
## For activating it as a pre-commit and pre-push hook (recommended):
# pre-commit install --hook-type pre-push --hook-type pre-commit
#
## For manually executing the pre-push hook:
# pre-commit run -av --hook-stage pre-push
#
default_stages: [commit, push]
default_language_version:
python: python3.11
repos:
# Recommendation for a minimal git pre-commit hook:
# https://github.com/pre-commit/pre-commit-hooks/blob/main/README.md:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: no-commit-to-branch
name: "The master branch should be pulled only, don't commit to it"
args: [--branch, master]
always_run: true
- id: check-merge-conflict
- id: check-yaml
- id: check-executables-have-shebangs
exclude: ocaml
# Improve Python formatting incrementally:
# https://dev.to/akaihola/improving-python-code-incrementally-3f7a
#
# darker checks if staged python changes are formatted according using
# the PEP8-aligned black formatter. It also checks if the imports are sorted.
#
# It is a good idea to run this before committing, and it is also run in the
# GitHub Workflow.
#
# Note: darker only checks the changes in files ending in .py!
# Python scripts that don't end in .py should be renamed to have the .py extension
# when moving them to python3/bin.
# (remove the .py extension in the Makefile when installing the file)
#
- repo: https://github.com/akaihola/darker
rev: 1.7.3
hooks:
- id: darker
files: python3/
name: check changes in Python3 tree using darker and isort
args: [--diff, --skip-string-normalization, --isort, -tpy36]
additional_dependencies: [isort]
#
# Run pytest and diff-cover to check that the new /python3 test suite in passes.
# This hook uses a local venv containing the required dependencies. When adding
# new dependencies, they should be added to the additional_dependencies below.
#
- repo: local
hooks:
- id: pytest
files: python3/
name: check that the Python3 test suite in passes
entry: env PYTHONDEVMODE=yes sh -c 'coverage run && coverage xml &&
coverage html && coverage report &&
diff-cover --ignore-whitespace --compare-branch=origin/feature/py3
--show-uncovered --html-report .git/coverage-diff.html
--fail-under 50 .git/coverage3.11.xml'
require_serial: true
pass_filenames: false
language: python
types: [python]
additional_dependencies:
- coverage
- diff-cover
- future
- opentelemetry-api
- opentelemetry-exporter-zipkin-json
- opentelemetry-sdk
- pytest-mock
- mock
- wrapt
- XenAPI
- repo: https://github.com/RobertCraigie/pyright-python
rev: v1.1.372
hooks:
- id: pyright
name: check that python3 tree passes pyright/VSCode check
files: python3/
additional_dependencies:
- mock
- opentelemetry-api
- opentelemetry-exporter-zipkin-json
- opentelemetry-sdk
- pytest
- pyudev
- XenAPI
# Check that pylint passes for the changes in new /python3 code.
- repo: local
hooks:
- id: pylint
files: python3/
stages: [push]
name: check that changes to python3 tree pass pylint
entry: diff-quality --violations=pylint
--ignore-whitespace --compare-branch=origin/feature/py3
pass_filenames: false
language: python
types: [python]
additional_dependencies: [diff-cover, pylint, pytest]
# pre-push hook (it only runs if you install pre-commit as a pre-push hook):
# It can be manually tested using: `pre-commit run -av --hook-stage push`
# Recommendation for a minimal git pre-push hook:
# While using pre-commit yields great results, it
# is "not fast". Therefore only run it pre-push,
# (but always in GitHub CI of course):
#
# Calls ./pytype_reporter.py in a dedicated venv:
# pre-commit run -av --hook-stage push
- repo: local
hooks:
- id: pytype
name: pytype
entry: python3 pytype_reporter.py
pass_filenames: false
types: [python]
stages: [push]
verbose: true
# This hook runs locally only when Python files change:
language: python
# Pytype supports running on Python 3.8 to Python3.11 currently:
# https://google.github.io/pytype/support.html
# If a dev's default python3 interpreter is outside that range, but
# developers have such version installed, it can be configured here:
# language_version: python3.11
require_serial: true
additional_dependencies:
- future
- opentelemetry-api
- opentelemetry-exporter-zipkin-json
- opentelemetry-sdk
- pandas
- pytest
- pytype
files: python3/