Example prepararation of tox & zuul for Debian & CentOS co-existence

The plan is for both Debian and Centos to be built from
the master branch.
At runtime they have different Python environments. Different versions
of packages are required for testing.

This commit is an example of what to modify for other repos for both
zuul and tox in order to obtain test environments for both Python 2 and
Python 3.
The targeted repo for this example was stx/config/sysinv/sysinv/sysinv.
The targeted tox test environments were flake8 and pylint.

Note:
Pep8 testenv is preserved for aligning with opendev openstack zuul jobs
(e.g openstack-tox-pep8).

Story: 2008454
Task: 42842
Signed-off-by: Dan Voiculeasa <dan.voiculeasa@windriver.com>
Change-Id: I70e4521eb4438a340199964fd2dbffa29ae9932b
This commit is contained in:
Dan Voiculeasa 2021-07-14 16:20:53 +03:00
parent 8d2503bd2a
commit 4118c144ca
3 changed files with 94 additions and 16 deletions

View File

@ -9,8 +9,10 @@
- openstack-tox-linters
- sysinv-tox-py27
- sysinv-tox-py36
- sysinv-tox-flake8
- sysinv-tox-pylint
- sysinv-tox-flake8-py27
- sysinv-tox-flake8-py36
- sysinv-tox-pylint-py27
- sysinv-tox-pylint-py36
- sysinv-tox-bandit
- controllerconfig-tox-py27
- controllerconfig-tox-py36
@ -25,8 +27,10 @@
- openstack-tox-linters
- sysinv-tox-py27
- sysinv-tox-py36
- sysinv-tox-flake8
- sysinv-tox-pylint
- sysinv-tox-flake8-py27
- sysinv-tox-flake8-py36
- sysinv-tox-pylint-py27
- sysinv-tox-pylint-py36
- sysinv-tox-bandit
- controllerconfig-tox-py27
- controllerconfig-tox-py36
@ -60,7 +64,7 @@
name: sysinv-tox-py36
parent: tox
description: |
Run py36 test for sysinv
Run py36 test for sysinv in Python 3.6 env
nodeset: ubuntu-bionic
required-projects:
- starlingx/fault
@ -73,22 +77,34 @@
tox_extra_args: -c sysinv/sysinv/sysinv/tox.ini
- job:
name: sysinv-tox-flake8
name: sysinv-tox-flake8-py27
parent: tox
description: |
Run flake8 test for sysinv
Run flake8 test for sysinv in Python 2.7 env
nodeset: ubuntu-bionic
files:
- sysinv/sysinv/*
vars:
tox_envlist: flake8
tox_envlist: flake8-py27
tox_extra_args: -c sysinv/sysinv/sysinv/tox.ini
- job:
name: sysinv-tox-pylint
name: sysinv-tox-flake8-py36
parent: tox
description: |
Run pylint test for sysinv
Run flake8 test for sysinv in Python 3.6 env
nodeset: ubuntu-bionic
files:
- sysinv/sysinv/*
vars:
tox_envlist: flake8-py36
tox_extra_args: -c sysinv/sysinv/sysinv/tox.ini
- job:
name: sysinv-tox-pylint-py27
parent: tox
description: |
Run pylint test for sysinv in Pyhton 2.7 env
nodeset: ubuntu-bionic
required-projects:
- starlingx/fault
@ -97,7 +113,23 @@
files:
- sysinv/sysinv/*
vars:
tox_envlist: pylint
tox_envlist: pylint-py27
tox_extra_args: -c sysinv/sysinv/sysinv/tox.ini
- job:
name: sysinv-tox-pylint-py36
parent: tox
description: |
Run pylint test for sysinv in Python 3.6 env
nodeset: ubuntu-bionic
required-projects:
- starlingx/fault
- starlingx/update
- starlingx/utilities
files:
- sysinv/sysinv/*
vars:
tox_envlist: pylint-py36
tox_extra_args: -c sysinv/sysinv/sysinv/tox.ini
- job:

View File

@ -1,5 +1,5 @@
[tox]
envlist = flake8,py27,py36,pylint
envlist = flake8-py{27,36},py{27,36},pylint-py{27,36}
minversion = 1.6
skipsdist = True
@ -95,7 +95,7 @@ ignore = H101,H102,H104,H105,H306,H401,H403,H404,H405,H701,H702,H703,
exclude = build,dist,tools,.eggs
max-line-length=120
[testenv:flake8]
[testenv:flake8-py36]
basepython = python3
deps = -r{toxinidir}/test-requirements.txt
commands =
@ -103,6 +103,14 @@ commands =
scripts/manage-partitions \
scripts/query_pci_id
[testenv:flake8-py27]
basepython = python2.7
deps = -r{toxinidir}/test-requirements.txt
commands =
flake8 {posargs} . \
scripts/manage-partitions \
scripts/query_pci_id
[testenv:py27]
basepython = python2.7
commands =
@ -117,11 +125,28 @@ commands =
stestr run {posargs}
stestr slowest
[testenv:pep8]
[testenv:pep8-py27]
# testenv:flake8 clone
basepython = python2.7
deps = -r{toxinidir}/test-requirements.txt
commands = {[testenv:flake8-py27]commands}
[testenv:pep8-py36]
# testenv:flake8 clone
basepython = python3
deps = -r{toxinidir}/test-requirements.txt
commands = {[testenv:flake8]commands}
commands = {[testenv:flake8-py36]commands}
[testenv:pep8]
# default pep8 to py36 environment
# Needed for when when zuul template will call pep8.
# https://opendev.org/starlingx/zuul-jobs/src/branch/master/zuul.d/project-templates.yaml
#
# For example this is the openstack template:
# https://opendev.org/openstack/openstack-zuul-jobs/src/branch/master/zuul.d/jobs.yaml#L329
basepython = python3
deps = -r{toxinidir}/test-requirements.txt
commands = {[testenv:pep8-py36]commands}
[testenv:venv]
commands = {posargs}
@ -163,7 +188,12 @@ basepython = python3
deps = -r{toxinidir}/test-requirements.txt
commands = bandit --ini tox.ini -n 5 -r sysinv
[testenv:pylint]
[testenv:pylint-py27]
basepython = python2.7
commands =
pylint {posargs} sysinv --rcfile=./pylint.rc
[testenv:pylint-py36]
basepython = python3.6
commands =
pylint {posargs} sysinv --rcfile=./pylint.rc

16
tox.ini
View File

@ -49,10 +49,26 @@ commands = {posargs}
basepython = python3
description = Dummy environment to allow flake8 to be run in subdir tox
[testenv:flake8-py27]
basepython = python2.7
description = Dummy environment to allow flake8 to be run in subdir tox
[testenv:flake8-py36]
basepython = python3.6
description = Dummy environment to allow flake8 to be run in subdir tox
[testenv:pylint]
basepython = python3
description = Dummy environment to allow pylint to be run in subdir tox
[testenv:pylint-py27]
basepython = python2.7
description = Dummy environment to allow pylint to be run in subdir tox
[testenv:pylint-py36]
basepython = python3.6
description = Dummy environment to allow pylint to be run in subdir tox
[testenv:bandit]
basepython = python3
description = Dummy environment to allow bandit to be run in subdir tox