diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..27fc001d --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,56 @@ +--- +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://opendev.org/openstack/hacking + rev: 6.1.0 + hooks: + - id: hacking + additional_dependencies: [] + exclude: '^(doc|releasenotes|tools)/.*$' + - repo: https://github.com/codespell-project/codespell + rev: v2.2.6 + hooks: + - id: codespell + args: [--write-changes] + - 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://opendev.org/openstack/bashate + rev: 2.1.0 + hooks: + - id: bashate + args: ["-iE006,E044", "-eE005,E042"] + name: bashate + description: This hook runs bashate for linting shell scripts + entry: bashate + language: python + types: [shell] + - repo: https://github.com/PyCQA/doc8 + rev: v1.1.2 + hooks: + - id: doc8 diff --git a/pyproject.toml b/pyproject.toml index 5eeed3e1..a9362f71 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,3 +2,5 @@ requires = ["pbr>=6.0.0", "setuptools>=64.0.0"] build-backend = "pbr.build" +[tool.doc8] +ignore = ["D001"] diff --git a/tox.ini b/tox.ini index 96370023..30ce793d 100644 --- a/tox.ini +++ b/tox.ini @@ -1,28 +1,31 @@ [tox] minversion = 4.4.0 envlist = py3,pep8 -ignore_basepython_conflict=true [testenv] -basepython = python3 constrain_package_deps = true usedevelop = True setenv = VIRTUAL_ENV={envdir} + PYTHONDONTWRITEBYTECODE=1 + PYTHONUNBUFFERED=1 PYTHONWARNINGS=default::DeprecationWarning deps = -c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master} - -r{toxinidir}/test-requirements.txt -r{toxinidir}/requirements.txt + -r{toxinidir}/test-requirements.txt commands = stestr run --slowest {posargs} [testenv:pep8] -deps= - hacking~=6.0.0 # Apache-2.0 - flake8-import-order>=0.17.1 # LGPLv3 - pycodestyle>=2.0.0,<3.0.0 # MIT - -c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master} -commands = flake8 {posargs} +deps = pre-commit +allowlist_externals = pre-commit +commands = pre-commit run --all-files --show-diff-on-failure {posargs} + +[testenv:codespell] +description = + Run codespell to check spelling +deps = pre-commit +commands = pre-commit run --all-files --show-diff-on-failure codespell [testenv:venv] setenv = PYTHONHASHSEED=0 @@ -90,11 +93,3 @@ import-order-style = pep8 application-import-names = sushy filename = *.py -[testenv:codespell] -description = - Run codespell to check spelling -deps = codespell -# note(JayF): {posargs} lets us run `tox -ecodespell -- -w` to get codespell -# to correct spelling issues in our code it's aware of. -commands = - codespell {posargs} \ No newline at end of file diff --git a/zuul.d/project.yaml b/zuul.d/project.yaml index 8195bf2d..31c6bb84 100644 --- a/zuul.d/project.yaml +++ b/zuul.d/project.yaml @@ -10,10 +10,8 @@ - ironic-cross-sushy - sushy-tempest-bios-redfish-pxe - sushy-tempest-uefi-redfish-vmedia - - sushy-tox-codespell gate: jobs: - ironic-cross-sushy - sushy-tempest-bios-redfish-pxe - sushy-tempest-uefi-redfish-vmedia - - sushy-tox-codespell diff --git a/zuul.d/sushy-jobs.yaml b/zuul.d/sushy-jobs.yaml index a8822801..8840544e 100644 --- a/zuul.d/sushy-jobs.yaml +++ b/zuul.d/sushy-jobs.yaml @@ -3,6 +3,7 @@ parent: ironic-tempest-bios-redfish-pxe irrelevant-files: - ^.*\.rst$ + - ^\.pre-commit-config\.yaml$ - ^doc/.*$ - ^test-requirements.txt$ - ^sushy/tests/.*$ @@ -14,15 +15,9 @@ parent: ironic-tempest-uefi-redfish-vmedia irrelevant-files: - ^.*\.rst$ + - ^\.pre-commit-config\.yaml$ - ^doc/.*$ - ^test-requirements.txt$ - ^sushy/tests/.*$ required-projects: - openstack/sushy - -- job: - name: sushy-tox-codespell - parent: openstack-tox - timeout: 7200 - vars: - tox_envlist: codespell \ No newline at end of file