From 094867041d67098b69ab66ae604ea4059ae19e56 Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Tue, 14 May 2024 14:29:44 +0100 Subject: [PATCH] Integrate pre-commit Just as we've done for Nova and many other projects. Change-Id: I40410f637fcb1b05724a4ed7106e557c07006164 Signed-off-by: Stephen Finucane --- .pre-commit-config.yaml | 41 +++++++++++++++++++ .../allocation-candidates-member-of.yaml | 1 - .../functional/gabbits/microversion.yaml | 4 -- tox.ini | 5 ++- 4 files changed, 45 insertions(+), 6 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 000000000..d5435f5f6 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,41 @@ +--- +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.6.0 + hooks: + - id: trailing-whitespace + - id: mixed-line-ending + args: ['--fix', 'lf'] + exclude: '.*\.(svg)$' + - id: check-byte-order-marker + - id: check-executables-have-shebangs + - id: check-merge-conflict + - id: debug-statements + - id: check-json + files: .*\.json$ + - id: check-yaml + files: .*\.(yaml|yml)$ + - repo: https://github.com/Lucas-C/pre-commit-hooks + rev: v1.5.5 + 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)/.*$' + # TODO(stephenfin): Uncomment this + # - repo: https://github.com/hhatto/autopep8 + # rev: v2.3.1 + # hooks: + # - id: autopep8 + # files: '^.*\.py$' + # - repo: https://github.com/sphinx-contrib/sphinx-lint + # rev: v0.9.1 + # hooks: + # - id: sphinx-lint + # args: [--enable=default-role] + # files: ^doc/|releasenotes|api-guide + # types: [rst] diff --git a/placement/tests/functional/gabbits/allocation-candidates-member-of.yaml b/placement/tests/functional/gabbits/allocation-candidates-member-of.yaml index a5a58a02d..217d7d269 100644 --- a/placement/tests/functional/gabbits/allocation-candidates-member-of.yaml +++ b/placement/tests/functional/gabbits/allocation-candidates-member-of.yaml @@ -107,7 +107,6 @@ tests: status: 200 response_json_paths: $.allocation_requests.`len`: 2 - status: 200 - name: verify microversion fail for multiple member_of params GET: /allocation_candidates?resources=VCPU:1,MEMORY_MB:1024,DISK_GB:100&member_of=$ENVIRON['AGGA_UUID']&member_of=$ENVIRON['AGGB_UUID'] diff --git a/placement/tests/functional/gabbits/microversion.yaml b/placement/tests/functional/gabbits/microversion.yaml index 214ec8cd1..de1fe512b 100644 --- a/placement/tests/functional/gabbits/microversion.yaml +++ b/placement/tests/functional/gabbits/microversion.yaml @@ -32,10 +32,6 @@ tests: status: 406 response_headers: content-type: /application/json/ - response_json_paths: - $.errors.[0].title: Not Acceptable - $.errors.[0].max_version: /^\d+\.\d+$/ - $.errors.[0].min_version: /^\d+\.\d+$/ response_strings: - "Unacceptable version header: 0.5" response_json_paths: diff --git a/tox.ini b/tox.ini index f151c7938..ad941f6c3 100644 --- a/tox.ini +++ b/tox.ini @@ -36,8 +36,11 @@ commands = [testenv:pep8] description = Run style checks. +skip_install = true +deps = + pre-commit commands = - bash tools/flake8wrap.sh {posargs} + pre-commit run --all-files --show-diff-on-failure [testenv:fast8] description =