From be9d4d6d2bd5f4d3965a8f91a3fde85b0995d1cc Mon Sep 17 00:00:00 2001 From: Sorin Sbarnea Date: Fri, 1 Mar 2019 17:45:21 +0000 Subject: [PATCH] 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 --- .gitignore | 1 + test-requirements.txt | 2 +- tox.ini | 42 ++++++++++-------------------------------- zuul.d/layout.yaml | 10 +++++++--- 4 files changed, 19 insertions(+), 36 deletions(-) diff --git a/.gitignore b/.gitignore index b5f2b7f92..1c703cb84 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,7 @@ scripts/website/tripleosphinx/ scripts/website/planet-2.0/ scripts/website/planet.html.tmplc +.eggs/ .tox/ .coverage .pytest_cache/ diff --git a/test-requirements.txt b/test-requirements.txt index 8924a752c..14db02a44 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -4,5 +4,5 @@ pytest-cov mock requests pprint -pre-commit>=1.10 # MIT License +pre-commit>=1.10 # MIT License PyYAML \ No newline at end of file diff --git a/tox.ini b/tox.ini index d1c2c563f..5fdf10fa6 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,6 @@ [tox] envlist = linters, py27, py35, py36, py37 +minversion = 3.4.0 ignore_basepython_conflict = True skip_missing_interpreters = True @@ -8,27 +9,27 @@ usedevelop = True setenv = VIRTUAL_ENV={envdir} deps = -r{toxinidir}/test-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] basepython = python3 commands = {posargs} -[testenv:pyflakes] -basepython = python3 -deps = pyflakes -commands = pyflakes setup.py scripts - [testenv:linters] basepython = python3 -whitelist_externals = bash -commands = python -m pre_commit run --source HEAD^ --origin HEAD - +commands = + python -m pre_commit run -a # deprecated: use linters instead. kept only as a convenience alias [testenv:pep8] basepython = python3 envdir = {toxworkdir}/linters -whitelist_externals = {[testenv:linters]whitelist_externals} +whitelist_externals = {[testenv]whitelist_externals} commands = {[testenv:linters]commands} [testenv:cireport] @@ -36,26 +37,3 @@ basepython = python3 passenv = SSH_AUTH_SOCK 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} diff --git a/zuul.d/layout.yaml b/zuul.d/layout.yaml index 2129364b9..c1e6202e7 100644 --- a/zuul.d/layout.yaml +++ b/zuul.d/layout.yaml @@ -16,12 +16,16 @@ check: jobs: - openstack-tox-linters - - openstack-tox-py27: + - openstack-tox-py27: &files files: + - ^bindep.txt$ + - ^requirements.txt$ - ^scripts/emit_releases_file/.*$ + - ^setup.cfg$ + - ^setup.py$ + - ^tox.ini$ - openstack-tox-py35: - files: - - ^scripts/emit_releases_file/.*$ + <<: *files - tripleo-buildimage-overcloud-full-centos-7: files: - ^playbooks/tripleo-buildimage/.*$