Add flake8-import-order and use python3.9 on tox

Improving the code quality of upstream by adding the flake8 check on
zuul and adding the flake8-import-order plugin to standardize imports.
Also, defaults testenv to python3.9 configuration that should be used
for now on with the debian migration.

Story: 2010100
Task: 45669
Signed-off-by: Thiago Brito <thiago.brito@windriver.com>
Change-Id: I55aa952c4f22a7af53e1f1c11a4a51997afa4bcf
This commit is contained in:
Thiago Brito 2022-06-22 12:27:57 -03:00 committed by Thiago Paiva Brito
parent 1b989b481a
commit 4d34b1ac65
5 changed files with 40 additions and 24 deletions

View File

@ -5,16 +5,26 @@
- stx-release-notes-jobs
check:
jobs:
- openstack-tox-pep8
- openstack-tox-linters
- stx-upstream-tox-pep8
- stx-upstream-tox-linters
gate:
jobs:
- openstack-tox-pep8
- openstack-tox-linters
- stx-upstream-tox-pep8
- stx-upstream-tox-linters
post:
jobs:
- stx-upstream-upload-git-mirror
- job:
name: stx-upstream-tox-pep8
parent: openstack-tox-pep8
nodeset: debian-bullseye
- job:
name: stx-upstream-tox-linters
parent: openstack-tox-linters
nodeset: debian-bullseye
- job:
name: stx-upstream-upload-git-mirror
parent: upload-git-mirror

View File

@ -3,6 +3,7 @@ import fnmatch
import os
import resource
import subprocess
from django.conf import settings

View File

@ -12,10 +12,11 @@
# License for the specific language governing permissions and limitations
# under the License.
import sys
from keystone.server import wsgi as wsgi_server
import sys
sys.argv = sys.argv[:1]
application = wsgi_server.initialize_public_application()

View File

@ -1,4 +1,5 @@
bashate >= 0.2
PyYAML >= 3.1.0
yamllint >= 0.5.2
flake8 >= 2.5.4 # MIT
bashate
PyYAML
yamllint
flake8
flake8-import-order

33
tox.ini
View File

@ -4,7 +4,12 @@ minversion = 2.3
skipsdist = True
[testenv]
install_command = pip install -U {opts} {packages}
basepython = python3.9
install_command = pip install \
-v -v -v \
-U \
-c{env:UPPER_CONSTRAINTS_FILE:https://opendev.org/starlingx/root/raw/branch/master/build-tools/requirements/debian/upper-constraints.txt} \
{opts} {packages}
setenv = VIRTUAL_ENV={envdir}
OS_STDOUT_CAPTURE=1
OS_STDERR_CAPTURE=1
@ -12,7 +17,6 @@ setenv = VIRTUAL_ENV={envdir}
deps = -r{toxinidir}/test-requirements.txt
[testenv:linters]
basepython = python3
whitelist_externals = bash
commands =
bash -c "find {toxinidir} \
@ -27,17 +31,6 @@ commands =
-o -name '*.yaml' \
-print0 | xargs -0 yamllint"
[testenv:pep8]
basepython = python3
usedevelop = False
description =
Run style checks.
commands =
flake8
[flake8]
# E123, E125 skipped as they are invalid PEP-8.
# E501 skipped because some of the code files include templates
@ -46,10 +39,20 @@ commands =
show-source = True
ignore = E123,E125,E501,H405
exclude = .venv,.git,.tox,dist,doc,*lib/python*,*egg,build,release-tag-*
import-order-style = google
[testenv:pep8]
usedevelop = False
description =
Run style checks.
commands =
flake8
[testenv:venv]
basepython = python3
commands = {posargs}
[testenv:docs]
@ -71,8 +74,8 @@ whitelist_externals =
reno
[testenv:newnote]
basepython = python3
# Re-use the releasenotes venv
basepython = python3
envdir = {toxworkdir}/releasenotes
deps = -r{toxinidir}/doc/requirements.txt
commands = reno new {posargs}