switch lints to using pre-commit

Switch to using pre-commit for linters. This consolidates the doc8 run
into pre-commit. To ensure that CI matches what users get and to not
require users to do anything different, call pre-commit from tox. Added
the same pre-commit hooks from the ironic repo where they pass cleanly.

Change-Id: Ic49b06d8ef1621646bf5455b705af1e0db830ab1
Signed-off-by: Doug Goldstein <cardoe@cardoe.com>
This commit is contained in:
Doug Goldstein 2024-11-09 12:14:09 -05:00
parent 77353cd15e
commit 3592d4c370
No known key found for this signature in database
3 changed files with 39 additions and 2 deletions

36
.pre-commit-config.yaml Normal file
View File

@ -0,0 +1,36 @@
---
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: trailing-whitespace
- id: mixed-line-ending
args: ['--fix', 'lf']
exclude: |
(?x)(
.*.svg$|
)
- id: fix-byte-order-marker
- id: check-merge-conflict
- id: debug-statements
- id: check-json
files: .*\.json$
- id: check-yaml
files: .*\.(yaml|yml)$
exclude: releasenotes/.*$
- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.5.4
hooks:
- id: remove-tabs
exclude: '.*\.(svg)$'
- repo: https://github.com/sphinx-contrib/sphinx-lint
rev: v1.0.0
hooks:
- id: sphinx-lint
args: [--enable=default-role]
files: ^doc/|releasenotes|api-ref
- repo: https://github.com/PyCQA/doc8
rev: v1.1.2
hooks:
- id: doc8

View File

@ -2,7 +2,6 @@
# of appearance. Changing the order has an impact on the overall integration
# process, which may cause wedges in the gate later.
doc8 # Apache-2.0
stestr!=2.3.1 # Apache-2.0
testtools>=0.9.34

View File

@ -5,15 +5,17 @@ skipsdist = true
[testenv]
usedevelop = True
allowlist_externals = pre-commit
setenv =
VIRTUAL_ENV={envdir}
deps =
-c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master}
-r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt
pre-commit
commands =
stestr run {posargs}
doc8 priorities/ specs/ doc/source README.rst
pre-commit run --all-files --show-diff-on-failure {posargs}
[testenv:venv]
commands = {posargs:}