Fix and improve flake8 test.
Previously the 'flake8' command was running but didn't seem to check out something in all cases. - This patch decouples the 'ansible-lint' and the 'flake8' parts into separated 'testenv'. - And this patch fixes some 'flake8' issues. - Added noqa comment in ci-scripts/validate-yaml, because globals variables are treated as undefined! Change-Id: I442112d44790c576702cfaee6c1d55b708b4dca9 Signed-off-by: Gael Chamoulaud <gchamoul@redhat.com>
This commit is contained in:
parent
7ac5c55b83
commit
ff4a95009c
@ -12,9 +12,9 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import os
|
||||
import argparse
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
import yaml
|
||||
|
||||
@ -54,13 +54,13 @@ def validate_directory(path):
|
||||
|
||||
for dirpath, dirnames, filenames in os.walk(path):
|
||||
for filename in filenames:
|
||||
if not (filename.endswith('.yml')
|
||||
or filename.endswith('.yaml')):
|
||||
if not (filename.endswith('.yml') or
|
||||
filename.endswith('.yaml')):
|
||||
continue
|
||||
|
||||
filename = os.path.join(dirpath, filename)
|
||||
all_valid = validate_file(filename) and all_valid
|
||||
if not all_valid and args.fail_fast:
|
||||
if not all_valid and args.fail_fast: # noqa : F821
|
||||
break
|
||||
else:
|
||||
continue
|
||||
@ -90,5 +90,6 @@ def main():
|
||||
|
||||
return 0 if all_valid else 1
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main())
|
||||
|
@ -1,10 +1,23 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/python
|
||||
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
|
||||
import json
|
||||
import os
|
||||
|
||||
from novaclient import client
|
||||
from novaclient import __version__ as nc_version
|
||||
from novaclient import client
|
||||
|
||||
# We can remove this logic when newton (novaclient 6) is EOL
|
||||
if nc_version[0] <= "6":
|
||||
|
28
tox.ini
28
tox.ini
@ -8,6 +8,7 @@ usedevelop = True
|
||||
install_command = pip install -c{env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt} {opts} {packages}
|
||||
setenv = VIRTUAL_ENV={envdir}
|
||||
deps = -r{toxinidir}/test-requirements.txt
|
||||
whitelist_externals = bash
|
||||
|
||||
[testenv:bindep]
|
||||
# Do not install any requirements. We want this to be fast and work even if
|
||||
@ -23,13 +24,30 @@ commands = jenkins-jobs test {toxinidir}/jenkins/jobs
|
||||
[testenv:docs]
|
||||
commands = python setup.py build_sphinx
|
||||
|
||||
[testenv:linters]
|
||||
basepython=python2
|
||||
whitelist_externals = bash
|
||||
[testenv:pep8]
|
||||
commands =
|
||||
# Run hacking/flake8 check for all python files
|
||||
bash -c "grep --recursive --binary-files=without-match \
|
||||
--files-with-match '^.!.*python$' \
|
||||
--exclude-dir .tox \
|
||||
--exclude-dir .git \
|
||||
--exclude-dir .eggs \
|
||||
--exclude-dir *.egg-info \
|
||||
--exclude-dir dist \
|
||||
--exclude-dir *lib/python* \
|
||||
--exclude-dir doc \
|
||||
{toxinidir} | xargs flake8 --verbose"
|
||||
|
||||
[testenv:ansible-lint]
|
||||
basepython=python2
|
||||
commands =
|
||||
flake8
|
||||
bash ci-scripts/ansible-lint.sh
|
||||
|
||||
[testenv:linters]
|
||||
commands =
|
||||
{[testenv:pep8]commands}
|
||||
{[testenv:ansible-lint]commands}
|
||||
|
||||
[testenv:releasenotes]
|
||||
whitelist_externals = bash
|
||||
commands = bash -c ci-scripts/releasenotes_tox.sh
|
||||
@ -39,8 +57,6 @@ commands = {posargs}
|
||||
|
||||
[flake8]
|
||||
# E123, E125 skipped as they are invalid PEP-8.
|
||||
|
||||
show-source = True
|
||||
ignore = E123,E125
|
||||
builtins = _
|
||||
exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build
|
||||
|
Loading…
Reference in New Issue
Block a user