From d4600b2816225ef5fe608f5052fb0ac20bd193d4 Mon Sep 17 00:00:00 2001 From: Emmanuel Cazenave Date: Thu, 26 Sep 2019 15:25:12 +0200 Subject: [PATCH] use tox to run tests (#15562) --- .coveragerc | 5 +++++ Jenkinsfile | 2 +- pylint.sh | 15 +++++++++++++++ tox.ini | 39 ++++++++++++++++++--------------------- 4 files changed, 39 insertions(+), 22 deletions(-) create mode 100644 .coveragerc create mode 100755 pylint.sh diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 000000000..26a251fa1 --- /dev/null +++ b/.coveragerc @@ -0,0 +1,5 @@ +[run] +omit = wcs/ctl/Bouncers/*.py wcs/qommon/vendor/*.py + +[report] +omit = wcs/ctl/Bouncers/*.py wcs/qommon/vendor/*.py diff --git a/Jenkinsfile b/Jenkinsfile index dfed0a3a2..b0eba093f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -6,7 +6,7 @@ pipeline { stages { stage('Unit Tests') { steps { - sh './jenkins.sh' + sh 'tox -r' } post { always { diff --git a/pylint.sh b/pylint.sh new file mode 100755 index 000000000..8e27e2ce2 --- /dev/null +++ b/pylint.sh @@ -0,0 +1,15 @@ +#!/bin/sh +set -e -x +env +if [ -f /var/lib/jenkins/pylint.wcs.rc ]; then + PYLINT_RC=/var/lib/jenkins/pylint.wcs.rc +elif [ -f pylint.wcs.rc ]; then + PYLINT_RC=pylint.wcs.rc +else + echo No pylint RC found + exit 0 +fi + +test -f pylint.out && cp pylint.out pylint.out.prev +pylint -f parseable --rcfile ${PYLINT_RC} "$@" | tee pylint.out || /bin/true +test -f pylint.out.prev && (diff pylint.out.prev pylint.out | grep '^[><]' | grep .py) || /bin/true diff --git a/tox.ini b/tox.ini index 306deb34d..e7d45a8c4 100644 --- a/tox.ini +++ b/tox.ini @@ -1,37 +1,34 @@ [tox] -envlist = coverage-{django18,django111}-pylint-pg -skipsdist = True -toxworkdir = {env:TMPDIR:/tmp}/tox-{env:USER}/wcs/ +toxworkdir = {env:TMPDIR:/tmp}/tox-{env:USER}/wcs/{env:BRANCH_NAME:} +envlist = py2-pylint-coverage [testenv] +sitepackages = true setenv = - PYTHONPATH=. + PYTHONPATH={toxinidir}{:}{env:PYTHONPATH:} + PYTHONHASHSEED=0 DJANGO_SETTINGS_MODULE=wcs.settings WCS_SETTINGS_FILE=tests/settings.py - coverage: COVERAGE=--junit-xml=test_results.xml --cov=wcs --cov-report xml --cov-config .coveragerc + LC_ALL=C + LC_TIME=C + LANG=C + coverage: COVERAGE=--junitxml=test_results.xml --cov-report xml --cov-report html --cov=wcs/ --cov-config .coveragerc -v passenv = USER deps = - django18: django>=1.8,<1.9 - django111: django>=1.11,<1.12 - pytest>=3.3.0,<4.1 + pytest pytest-mock pytest-cov + pytest-django WebTest - psycopg2 mechanize - gadjo>=0.53 - requests - scgi - vobject + gadjo pyquery - http://quixote.python.ca/releases/Quixote-2.7b2.tar.gz - qrcode - python-dateutil - pillow - feedparser + git+https://git.entrouvert.org/debian/django-ckeditor.git + django >=1.11, <1.12 + django-ratelimit<3 pyproj + pylint<1.8 commands = - ./getlasso.sh - pickle: py.test --without-postgresql-tests {env:COVERAGE:} {posargs:tests} - pg: py.test {env:COVERAGE:} {posargs:tests} + py.test {env:COVERAGE:} {posargs:tests/} + pylint: ./pylint.sh wcs/