Refactored tox.ini to ease usage for developer and CI

* Fixes ocassionally pre-commit linting was broken after a merge (-a)
  By always running on all files we avoid this rare case from happening.
  As seen on https://review.openstack.org/#/c/636160/55

* Fix minor bashare identation error that slipped in due to previous
  issue fix.

* Adds .eggs/ to ignore

* Moves whitelist_externals at top level to simplify tox.ini file

* Adds missing file patterns for tox py27/py35 job

* Avoids repetition of file patterns between py27/py37 jobs.

* removed pyflakes as this is included in flake8

* Running just "tox" now works even if developer has alternative python
  versions like py36/py37 instead of py35. No impact on CI where job
  is forcing use of specific interpreter.

* Remove bindep tox env and include bindep run as part of unittest
  environments. This will assure it runs on CI, as it previously din't.

Change-Id: Ia8f98fc0fda18203be3c17d4fdb93d33ca244dc4
This commit is contained in:
Sorin Sbarnea 2019-03-01 17:45:21 +00:00
parent 6376463e81
commit be9d4d6d2b
4 changed files with 19 additions and 36 deletions

1
.gitignore vendored
View File

@ -11,6 +11,7 @@ scripts/website/tripleosphinx/
scripts/website/planet-2.0/ scripts/website/planet-2.0/
scripts/website/planet.html.tmplc scripts/website/planet.html.tmplc
.eggs/
.tox/ .tox/
.coverage .coverage
.pytest_cache/ .pytest_cache/

View File

@ -4,5 +4,5 @@ pytest-cov
mock mock
requests requests
pprint pprint
pre-commit>=1.10 # MIT License pre-commit>=1.10 # MIT License
PyYAML PyYAML

42
tox.ini
View File

@ -1,5 +1,6 @@
[tox] [tox]
envlist = linters, py27, py35, py36, py37 envlist = linters, py27, py35, py36, py37
minversion = 3.4.0
ignore_basepython_conflict = True ignore_basepython_conflict = True
skip_missing_interpreters = True skip_missing_interpreters = True
@ -8,27 +9,27 @@ usedevelop = True
setenv = VIRTUAL_ENV={envdir} setenv = VIRTUAL_ENV={envdir}
deps = -r{toxinidir}/test-requirements.txt deps = -r{toxinidir}/test-requirements.txt
-r{toxinidir}/requirements.txt -r{toxinidir}/requirements.txt
whitelist_externals =
bash
commands_pre =
pip install -q bindep
bindep test
commands = pytest {posargs:--cov=emit_releases_file} scripts/emit_releases_file
[testenv:venv] [testenv:venv]
basepython = python3 basepython = python3
commands = {posargs} commands = {posargs}
[testenv:pyflakes]
basepython = python3
deps = pyflakes
commands = pyflakes setup.py scripts
[testenv:linters] [testenv:linters]
basepython = python3 basepython = python3
whitelist_externals = bash commands =
commands = python -m pre_commit run --source HEAD^ --origin HEAD python -m pre_commit run -a
# deprecated: use linters instead. kept only as a convenience alias # deprecated: use linters instead. kept only as a convenience alias
[testenv:pep8] [testenv:pep8]
basepython = python3 basepython = python3
envdir = {toxworkdir}/linters envdir = {toxworkdir}/linters
whitelist_externals = {[testenv:linters]whitelist_externals} whitelist_externals = {[testenv]whitelist_externals}
commands = {[testenv:linters]commands} commands = {[testenv:linters]commands}
[testenv:cireport] [testenv:cireport]
@ -36,26 +37,3 @@ basepython = python3
passenv = passenv =
SSH_AUTH_SOCK SSH_AUTH_SOCK
commands = python scripts/tripleo-jobs-gerrit.py {posargs} commands = python scripts/tripleo-jobs-gerrit.py {posargs}
# This environment can be used to quickly validate that all needed system
# packages required to successfully execute test targets are installed
[testenv:bindep]
basepython = python3
# 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
# dependencies are missing! This also means that bindep must be installed
# separately, outside of the requirements files.
deps = bindep
commands = bindep test
# This environment is used to run unit tests
[testenv:py27]
deps = {[testenv]deps}
changedir = scripts/emit_releases_file
commands = pytest {posargs:--cov=emit_releases_file}
[testenv:py35]
basepython = python3.5
deps={[testenv]deps}
changedir = {[testenv:py27]changedir}
commands = {[testenv:py27]commands}

View File

@ -16,12 +16,16 @@
check: check:
jobs: jobs:
- openstack-tox-linters - openstack-tox-linters
- openstack-tox-py27: - openstack-tox-py27: &files
files: files:
- ^bindep.txt$
- ^requirements.txt$
- ^scripts/emit_releases_file/.*$ - ^scripts/emit_releases_file/.*$
- ^setup.cfg$
- ^setup.py$
- ^tox.ini$
- openstack-tox-py35: - openstack-tox-py35:
files: <<: *files
- ^scripts/emit_releases_file/.*$
- tripleo-buildimage-overcloud-full-centos-7: - tripleo-buildimage-overcloud-full-centos-7:
files: files:
- ^playbooks/tripleo-buildimage/.*$ - ^playbooks/tripleo-buildimage/.*$