Merge "Use pre-commit for lint jobs"
This commit is contained in:
@@ -1,10 +1,7 @@
|
|||||||
---
|
---
|
||||||
default_language_version:
|
|
||||||
# force all unspecified python hooks to run python3
|
|
||||||
python: python3
|
|
||||||
repos:
|
repos:
|
||||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||||
rev: v4.1.0
|
rev: v5.0.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: trailing-whitespace
|
- id: trailing-whitespace
|
||||||
- id: mixed-line-ending
|
- id: mixed-line-ending
|
||||||
@@ -16,17 +13,18 @@ repos:
|
|||||||
- id: check-yaml
|
- id: check-yaml
|
||||||
files: .*\.(yaml|yml)$
|
files: .*\.(yaml|yml)$
|
||||||
- repo: https://github.com/Lucas-C/pre-commit-hooks
|
- repo: https://github.com/Lucas-C/pre-commit-hooks
|
||||||
rev: v1.1.13
|
rev: v1.5.5
|
||||||
hooks:
|
hooks:
|
||||||
- id: remove-tabs
|
- id: remove-tabs
|
||||||
exclude: '.*\.(svg)$'
|
exclude: '.*\.(svg)$'
|
||||||
- repo: local
|
- repo: https://github.com/PyCQA/bandit
|
||||||
|
rev: 1.8.5
|
||||||
hooks:
|
hooks:
|
||||||
- id: flake8
|
- id: bandit
|
||||||
name: flake8
|
exclude: '^novaclient/tests/.*$'
|
||||||
additional_dependencies:
|
- repo: https://opendev.org/openstack/hacking
|
||||||
- hacking>=6.1.0,<6.2.0
|
rev: 7.0.0
|
||||||
language: python
|
hooks:
|
||||||
entry: flake8
|
- id: hacking
|
||||||
files: '^.*\.py$'
|
additional_dependencies: []
|
||||||
exclude: '^(doc|releasenotes|tools)/.*$'
|
exclude: '^(doc|releasenotes|tools)/.*$'
|
||||||
|
@@ -14,7 +14,7 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import base64
|
import base64
|
||||||
import subprocess
|
import subprocess # nosec: B404
|
||||||
|
|
||||||
|
|
||||||
class DecryptionFailure(Exception):
|
class DecryptionFailure(Exception):
|
||||||
@@ -30,7 +30,7 @@ def decrypt_password(private_key, password):
|
|||||||
cmd = ['openssl', 'rsautl', '-decrypt', '-inkey', private_key]
|
cmd = ['openssl', 'rsautl', '-decrypt', '-inkey', private_key]
|
||||||
proc = subprocess.Popen(cmd, stdin=subprocess.PIPE,
|
proc = subprocess.Popen(cmd, stdin=subprocess.PIPE,
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.PIPE)
|
stderr=subprocess.PIPE) # nosec: B603
|
||||||
out, err = proc.communicate(unencoded)
|
out, err = proc.communicate(unencoded)
|
||||||
proc.stdin.close()
|
proc.stdin.close()
|
||||||
if proc.returncode:
|
if proc.returncode:
|
||||||
|
@@ -4208,7 +4208,7 @@ def do_ssh(cs, args):
|
|||||||
cmd = "ssh -%d -p%d %s %s@%s %s" % (version, args.port, identity,
|
cmd = "ssh -%d -p%d %s %s@%s %s" % (version, args.port, identity,
|
||||||
args.login, ip_address, args.extra)
|
args.login, ip_address, args.extra)
|
||||||
logger.debug("Executing cmd '%s'", cmd)
|
logger.debug("Executing cmd '%s'", cmd)
|
||||||
os.system(cmd)
|
os.system(cmd) # nosec: B605
|
||||||
|
|
||||||
|
|
||||||
# NOTE(mriedem): In the 2.50 microversion, the os-quota-class-sets API
|
# NOTE(mriedem): In the 2.50 microversion, the os-quota-class-sets API
|
||||||
|
@@ -2,4 +2,3 @@
|
|||||||
upgrade:
|
upgrade:
|
||||||
- remove version 1.1 API support as we only support v2 and v2.1
|
- remove version 1.1 API support as we only support v2 and v2.1
|
||||||
API in nova side now.
|
API in nova side now.
|
||||||
|
|
||||||
|
@@ -1,5 +1,3 @@
|
|||||||
hacking>=6.1.0,<6.2.0 # Apache-2.0
|
|
||||||
bandit>=1.1.0 # Apache-2.0
|
|
||||||
coverage>=4.4.1 # Apache-2.0
|
coverage>=4.4.1 # Apache-2.0
|
||||||
ddt>=1.0.1 # MIT
|
ddt>=1.0.1 # MIT
|
||||||
fixtures>=3.0.0 # Apache-2.0/BSD
|
fixtures>=3.0.0 # Apache-2.0/BSD
|
||||||
|
@@ -3,25 +3,25 @@ _nova_flags="" # lazy init
|
|||||||
_nova_opts_exp="" # lazy init
|
_nova_opts_exp="" # lazy init
|
||||||
_nova()
|
_nova()
|
||||||
{
|
{
|
||||||
local cur prev nbc cflags
|
local cur prev nbc cflags
|
||||||
COMPREPLY=()
|
COMPREPLY=()
|
||||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||||
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||||
|
|
||||||
if [ "x$_nova_opts" == "x" ] ; then
|
if [ "x$_nova_opts" == "x" ] ; then
|
||||||
nbc="`nova bash-completion | sed -e "s/ *-h */ /" -e "s/ *-i */ /"`"
|
nbc="`nova bash-completion | sed -e "s/ *-h */ /" -e "s/ *-i */ /"`"
|
||||||
_nova_opts="`echo "$nbc" | sed -e "s/--[a-z0-9_-]*//g" -e "s/ */ /g"`"
|
_nova_opts="`echo "$nbc" | sed -e "s/--[a-z0-9_-]*//g" -e "s/ */ /g"`"
|
||||||
_nova_flags="`echo " $nbc" | sed -e "s/ [^-][^-][a-z0-9_-]*//g" -e "s/ */ /g"`"
|
_nova_flags="`echo " $nbc" | sed -e "s/ [^-][^-][a-z0-9_-]*//g" -e "s/ */ /g"`"
|
||||||
_nova_opts_exp="`echo "$_nova_opts" | tr ' ' '|'`"
|
_nova_opts_exp="`echo "$_nova_opts" | tr ' ' '|'`"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ " ${COMP_WORDS[@]} " =~ " "($_nova_opts_exp)" " && "$prev" != "help" ]] ; then
|
if [[ " ${COMP_WORDS[@]} " =~ " "($_nova_opts_exp)" " && "$prev" != "help" ]] ; then
|
||||||
COMPLETION_CACHE=~/.novaclient/*/*-cache
|
COMPLETION_CACHE=~/.novaclient/*/*-cache
|
||||||
cflags="$_nova_flags "$(cat $COMPLETION_CACHE 2> /dev/null | tr '\n' ' ')
|
cflags="$_nova_flags "$(cat $COMPLETION_CACHE 2> /dev/null | tr '\n' ' ')
|
||||||
COMPREPLY=($(compgen -W "${cflags}" -- ${cur}))
|
COMPREPLY=($(compgen -W "${cflags}" -- ${cur}))
|
||||||
else
|
else
|
||||||
COMPREPLY=($(compgen -W "${_nova_opts}" -- ${cur}))
|
COMPREPLY=($(compgen -W "${_nova_opts}" -- ${cur}))
|
||||||
fi
|
fi
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
complete -F _nova nova
|
complete -F _nova nova
|
||||||
|
39
tox.ini
39
tox.ini
@@ -1,12 +1,11 @@
|
|||||||
[tox]
|
[tox]
|
||||||
envlist = py3,pep8,docs
|
envlist = py3,pep8,docs
|
||||||
minversion = 3.18.0
|
minversion = 4.6.0
|
||||||
ignore_basepython_conflict = true
|
|
||||||
|
|
||||||
[testenv]
|
[testenv]
|
||||||
basepython = python3
|
description =
|
||||||
|
Run unit tests.
|
||||||
usedevelop = true
|
usedevelop = true
|
||||||
# tox is silly... these need to be separated by a newline....
|
|
||||||
allowlist_externals =
|
allowlist_externals =
|
||||||
find
|
find
|
||||||
rm
|
rm
|
||||||
@@ -23,10 +22,20 @@ commands =
|
|||||||
stestr run {posargs}
|
stestr run {posargs}
|
||||||
|
|
||||||
[testenv:pep8]
|
[testenv:pep8]
|
||||||
commands = flake8 {posargs}
|
description =
|
||||||
|
Run style checks.
|
||||||
|
deps =
|
||||||
|
pre-commit
|
||||||
|
commands =
|
||||||
|
pre-commit run --all-files --show-diff-on-failure
|
||||||
|
|
||||||
[testenv:bandit]
|
[testenv:bandit]
|
||||||
commands = bandit -r novaclient -n5 -x tests
|
description =
|
||||||
|
Run security checks.
|
||||||
|
deps =
|
||||||
|
pre-commit
|
||||||
|
commands =
|
||||||
|
pre-commit run --all-files --show-diff-on-failure bandit
|
||||||
|
|
||||||
[testenv:venv]
|
[testenv:venv]
|
||||||
deps =
|
deps =
|
||||||
@@ -37,6 +46,8 @@ deps =
|
|||||||
commands = {posargs}
|
commands = {posargs}
|
||||||
|
|
||||||
[testenv:docs]
|
[testenv:docs]
|
||||||
|
description =
|
||||||
|
Build documentation in HTML format.
|
||||||
deps =
|
deps =
|
||||||
-c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master}
|
-c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master}
|
||||||
-r{toxinidir}/doc/requirements.txt
|
-r{toxinidir}/doc/requirements.txt
|
||||||
@@ -47,6 +58,8 @@ commands =
|
|||||||
whereto doc/build/html/.htaccess doc/test/redirect-tests.txt
|
whereto doc/build/html/.htaccess doc/test/redirect-tests.txt
|
||||||
|
|
||||||
[testenv:pdf-docs]
|
[testenv:pdf-docs]
|
||||||
|
description =
|
||||||
|
Build documentation in PDF format.
|
||||||
deps = {[testenv:docs]deps}
|
deps = {[testenv:docs]deps}
|
||||||
commands =
|
commands =
|
||||||
rm -rf doc/build/pdf
|
rm -rf doc/build/pdf
|
||||||
@@ -54,6 +67,8 @@ commands =
|
|||||||
make -C doc/build/pdf
|
make -C doc/build/pdf
|
||||||
|
|
||||||
[testenv:releasenotes]
|
[testenv:releasenotes]
|
||||||
|
description =
|
||||||
|
Build release notes.
|
||||||
deps =
|
deps =
|
||||||
-c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master}
|
-c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master}
|
||||||
-r{toxinidir}/doc/requirements.txt
|
-r{toxinidir}/doc/requirements.txt
|
||||||
@@ -61,12 +76,17 @@ commands =
|
|||||||
sphinx-build -a -E -W -d releasenotes/build/doctrees -b html releasenotes/source releasenotes/build/html
|
sphinx-build -a -E -W -d releasenotes/build/doctrees -b html releasenotes/source releasenotes/build/html
|
||||||
|
|
||||||
[testenv:functional{,-py39,-py310,-py311,-py312}]
|
[testenv:functional{,-py39,-py310,-py311,-py312}]
|
||||||
passenv = OS_*
|
description =
|
||||||
|
Run functional tests.
|
||||||
|
passenv =
|
||||||
|
OS_*
|
||||||
commands =
|
commands =
|
||||||
stestr --test-path=./novaclient/tests/functional run --concurrency=1 {posargs}
|
stestr --test-path=./novaclient/tests/functional run --concurrency=1 {posargs}
|
||||||
python novaclient/tests/functional/hooks/check_resources.py
|
python novaclient/tests/functional/hooks/check_resources.py
|
||||||
|
|
||||||
[testenv:cover]
|
[testenv:cover]
|
||||||
|
description =
|
||||||
|
Run unit tests and print coverage information.
|
||||||
setenv =
|
setenv =
|
||||||
PYTHON=coverage run --source novaclient --parallel-mode
|
PYTHON=coverage run --source novaclient --parallel-mode
|
||||||
commands =
|
commands =
|
||||||
@@ -93,11 +113,12 @@ exclude=.venv,.git,.tox,dist,*lib/python*,*egg,build,doc/source/conf.py,releasen
|
|||||||
import_exceptions = novaclient.i18n
|
import_exceptions = novaclient.i18n
|
||||||
|
|
||||||
[testenv:bindep]
|
[testenv:bindep]
|
||||||
|
description =
|
||||||
|
Check for installed binary dependencies.
|
||||||
# Do not install any requirements. We want this to be fast and work even if
|
# Do not install any requirements. We want this to be fast and work even if
|
||||||
# system dependencies are missing, since it's used to tell you what system
|
# system dependencies are missing, since it's used to tell you what system
|
||||||
# dependencies are missing! This also means that bindep must be installed
|
# dependencies are missing! This also means that bindep must be installed
|
||||||
# separately, outside of the requirements files.
|
# separately, outside of the requirements files.
|
||||||
deps = bindep
|
deps = bindep
|
||||||
skipsdist=True
|
skip_install = true
|
||||||
usedevelop=False
|
|
||||||
commands = bindep test
|
commands = bindep test
|
||||||
|
Reference in New Issue
Block a user