From d659a454a403fdff3265a35ed80c41d344e53db3 Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Wed, 3 Jun 2020 09:37:55 +0200 Subject: [PATCH 3/4] jenkins: adopt authentic way of doing tox.ini and Jenkinsfile --- Jenkinsfile | 16 +++++++++++++--- pylint.sh | 5 +++++ tox.ini | 55 ++++++++++++++++++++++++++++++++++++----------------- 3 files changed, 56 insertions(+), 20 deletions(-) create mode 100755 pylint.sh diff --git a/Jenkinsfile b/Jenkinsfile index 052f976..fc7f6a9 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -2,19 +2,28 @@ pipeline { agent any + options { disableConcurrentBuilds() } + environment { + TMPDIR = "/tmp/$BUILD_TAG" + } stages { stage('Unit Tests') { steps { - sh 'tox -rv' + sh "mkdir ${env.TMPDIR}" + sh """ +virtualenv -p python3 ${env.TMPDIR}/venv/ +${env.TMPDIR}/venv/bin/pip install tox "virtualenv<=20.0.5" "importlib-resources<=1.0.2" +PGPORT=`python -c 'import struct; import socket; s=socket.socket(); s.setsockopt(socket.SOL_SOCKET, socket.SO_LINGER, struct.pack("ii", 1, 0)); s.bind(("", 0)); print(s.getsockname()[1]); s.close()'` pg_virtualenv -o fsync=off ${env.TMPDIR}/venv/bin/tox -r""" } post { always { script { utils = new Utils() utils.publish_coverage('coverage.xml') - utils.publish_coverage_native() + utils.publish_coverage_native('index.html') + utils.publish_pylint('pylint.out') } - junit 'junit.xml' + mergeJunitResults() } } } @@ -36,6 +45,7 @@ pipeline { } } success { + sh "rm -rf ${env.TMPDIR}" cleanWs() } } diff --git a/pylint.sh b/pylint.sh new file mode 100755 index 0000000..452fac4 --- /dev/null +++ b/pylint.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +set -e + +pylint -f parseable "$@" > pylint.out || /bin/true diff --git a/tox.ini b/tox.ini index ca0f44a..cf43109 100644 --- a/tox.ini +++ b/tox.ini @@ -5,29 +5,50 @@ [tox] toxworkdir = {env:TMPDIR:/tmp}/tox-{env:USER}/wcs-olap/{env:BRANCH_NAME:} -envlist = py3-coverage +envlist = py3 + +[tox:jenkins] +envlist = + pylint + py3 [testenv] usedevelop = true setenv = - coverage: COVERAGE=--junit-xml=junit.xml --cov=wcs_olap --cov-report xml --cov-report html - WCS_MANAGE=wcs/manage.py + COVERAGE={tty::--cov=src --cov-branch --cov-append --cov-report xml --cov-report html} + JUNIT={tty::-o junit_suite_name={envname} --junit-xml=junit-{envname}.xml} + WCS_MANAGE=wcs/manage.py +deps = + pytest + pytest-cov + pytest-random + httmock + +# w.c.s. dependencies, as it cannot b installed through pip + quixote>=3 + psycopg2-binary + vobject + pyproj + django-ratelimit<3 + gadjo + django>=1.11,<1.12 +passenv= + BRANCH_NAME + # support for pg_virtualenv + PGPORT + PGHOST + PGUSER + PGPASSWORD +commands = + ./get_wcs.sh + py.test --sw {env:JUNIT:} {env:COVERAGE:} {posargs:--random-group tests} + +[testenv:pylint] +basepython = python3 deps = - coverage - pytest - pytest-cov - pytest-random - quixote>=3 - psycopg2-binary - vobject - pyproj - django-ratelimit<3 - gadjo - httmock - django>=1.11,<1.12 + pylint commands = - ./get_wcs.sh - py.test {env:COVERAGE:} {posargs:--random-group tests} + /bin/bash -c "./pylint.sh wcs_olap" [pytest] junit_family=xunit2 -- 2.26.2