From 3592d4c3706db70e2f656d44eef73f77b8eef298 Mon Sep 17 00:00:00 2001 From: Doug Goldstein Date: Sat, 9 Nov 2024 12:14:09 -0500 Subject: [PATCH] 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 --- .pre-commit-config.yaml | 36 ++++++++++++++++++++++++++++++++++++ test-requirements.txt | 1 - tox.ini | 4 +++- 3 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..e5a746a7 --- /dev/null +++ b/.pre-commit-config.yaml @@ -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 + diff --git a/test-requirements.txt b/test-requirements.txt index 66afba2c..9dcb184d 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -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 diff --git a/tox.ini b/tox.ini index 6ccdbf34..4692ecd1 100644 --- a/tox.ini +++ b/tox.ini @@ -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:}