From be949e0a0a2420205aaf80de514432a76596a854 Mon Sep 17 00:00:00 2001 From: Jason DeTiberus Date: Wed, 21 Dec 2016 17:15:42 -0500 Subject: More toxification - Move pylint tests to tox - Move yamllint tests to tox - Create separate tox config (and setup.py) for root - bump ansible requirement - unify pylint config - add docs - remove git directory containing old testing tools - install python-six if not present for openshift-facts - add python-six as a dependency for openshift-ansible-utils --- utils/.pylintrc | 1 + utils/Makefile | 30 ++++++++---------------------- utils/README.md | 41 +++++++++++++++++++++++++++++++++++++++++ utils/setup.cfg | 4 +++- utils/test-requirements.txt | 2 ++ utils/tox.ini | 5 ++--- 6 files changed, 57 insertions(+), 26 deletions(-) create mode 120000 utils/.pylintrc (limited to 'utils') diff --git a/utils/.pylintrc b/utils/.pylintrc new file mode 120000 index 000000000..30b33b524 --- /dev/null +++ b/utils/.pylintrc @@ -0,0 +1 @@ +../.pylintrc \ No newline at end of file diff --git a/utils/Makefile b/utils/Makefile index 2a37b922c..038c31fcf 100644 --- a/utils/Makefile +++ b/utils/Makefile @@ -46,7 +46,7 @@ clean: @find . -type f \( -name "*~" -or -name "#*" \) -delete @rm -fR build dist rpm-build MANIFEST htmlcov .coverage cover ooinstall.egg-info oo-install @rm -fR $(VENV) - + @rm -fR .tox # To force a rebuild of the docs run 'touch' on any *.in file under # docs/man/man1/ @@ -84,41 +84,27 @@ ci-unittests: $(VENV) @echo "#############################################" @echo "# Running Unit Tests in virtualenv" @echo "#############################################" - . $(VENV)/bin/activate && tox -e py27-unit - . $(VENV)/bin/activate && tox -e py35-unit + . $(VENV)/bin/activate && detox -e py27-unit,py35-unit @echo "VIEW CODE COVERAGE REPORT WITH 'xdg-open cover/index.html' or run 'make viewcover'" ci-pylint: $(VENV) @echo "#############################################" @echo "# Running PyLint Tests in virtualenv" @echo "#############################################" - . $(VENV)/bin/activate && python -m pylint --rcfile ../git/.pylintrc $(PYFILES) - -ci-yamllint: $(VENV) - @echo "#############################################" - @echo "# Running yamllint Tests in virtualenv" - @echo "#############################################" - @. $(VENV)/bin/activate && yamllint -c ../git/.yamllint $(YAMLFILES) - -ci-list-deps: $(VENV) - @echo "#############################################" - @echo "# Listing all pip deps" - @echo "#############################################" - . $(VENV)/bin/activate && pip freeze + . $(VENV)/bin/activate && detox -e py27-pylint,py35-pylint ci-flake8: $(VENV) @echo "#############################################" @echo "# Running Flake8 Compliance Tests in virtualenv" @echo "#############################################" - . $(VENV)/bin/activate && tox -e py27-flake8 - . $(VENV)/bin/activate && tox -e py35-flake8 + . $(VENV)/bin/activate && detox -e py27-flake8,py35-flake8 -ci-tox: - . $(VENV)/bin/activate && tox +ci-tox: $(VENV) + . $(VENV)/bin/activate && detox -ci: ci-list-deps ci-tox ci-pylint ci-yamllint +ci: ci-tox @echo @echo "##################################################################################" @echo "VIEW CODE COVERAGE REPORT WITH 'xdg-open cover/index.html' or run 'make viewcover'" @echo "To clean your test environment run 'make clean'" - @echo "Other targets you may run with 'make': 'ci-pylint', 'ci-tox', 'ci-unittests', 'ci-flake8', 'ci-yamllint'" + @echo "Other targets you may run with 'make': 'ci-pylint', 'ci-tox', 'ci-unittests', 'ci-flake8'" diff --git a/utils/README.md b/utils/README.md index 2abf2705e..c37ab41e6 100644 --- a/utils/README.md +++ b/utils/README.md @@ -6,6 +6,47 @@ Run the command: to run an array of unittests locally. +Underneath the covers, we use [tox](http://readthedocs.org/docs/tox/) to manage virtualenvs and run +tests. Alternatively, tests can be run using [detox](https://pypi.python.org/pypi/detox/) which allows +for running tests in parallel + + +``` +pip install tox detox +``` + +List the test environments available: +``` +tox -l +``` + +Run all of the tests with: +``` +tox +``` + +Run all of the tests in parallel with detox: +``` +detox +``` + +Running a particular test environment (python 2.7 flake8 tests in this case): +``` +tox -e py27-ansible22-flake8 +``` + +Running a particular test environment in a clean virtualenv (python 3.5 pylint +tests in this case): +``` +tox -r -e py35-ansible22-pylint +``` + +If you want to enter the virtualenv created by tox to do additional +testing/debugging (py27-flake8 env in this case): +``` +source .tox/py27-ansible22-flake8/bin/activate +``` + You will get errors if the log files already exist and can not be written to by the current user (`/tmp/ansible.log` and `/tmp/installer.txt`). *We're working on it.* diff --git a/utils/setup.cfg b/utils/setup.cfg index ea07eea9f..862dffd7b 100644 --- a/utils/setup.cfg +++ b/utils/setup.cfg @@ -5,7 +5,6 @@ universal=1 [nosetests] -tests=../,../roles/openshift_master_facts/test/,test/ verbosity=2 with-coverage=1 cover-html=1 @@ -19,3 +18,6 @@ cover-branches=1 max-line-length=120 exclude=test/*,setup.py,oo-installenv ignore=E501 + +[lint] +lint_disable=fixme,locally-disabled,file-ignored,duplicate-code diff --git a/utils/test-requirements.txt b/utils/test-requirements.txt index e5c5360c3..f6a7bde10 100644 --- a/utils/test-requirements.txt +++ b/utils/test-requirements.txt @@ -1,6 +1,7 @@ ansible configparser pylint +setuptools-lint nose coverage mock @@ -11,3 +12,4 @@ backports.functools_lru_cache pyOpenSSL yamllint tox +detox diff --git a/utils/tox.ini b/utils/tox.ini index 747d79dfe..1308f7505 100644 --- a/utils/tox.ini +++ b/utils/tox.ini @@ -1,7 +1,7 @@ [tox] minversion=2.3.1 envlist = - py{27,35}-{flake8,unit} + py{27,35}-{flake8,unit,pylint} skipsdist=True skip_missing_interpreters=True @@ -10,8 +10,7 @@ usedevelop=True deps = -rtest-requirements.txt py35-flake8: flake8-bugbear - commands = - flake8: flake8 --config=setup.cfg ../ --exclude="../utils,.tox,../inventory" flake8: python setup.py flake8 unit: python setup.py nosetests + pylint: python setup.py lint -- cgit v1.2.1