From 78426195feafbf7677416f50f454b474f42a61d6 Mon Sep 17 00:00:00 2001 From: Emmanuel Cazenave Date: Tue, 26 Jun 2018 17:10:16 +0200 Subject: [PATCH] create a Jenkinsfile (#24646) --- Jenkinsfile | 36 ++++++++++++++++++++++++++++++++++++ pylint.sh | 3 --- setup.py | 9 +++++---- tox.ini | 14 +++++++------- 4 files changed, 48 insertions(+), 14 deletions(-) create mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..73c3dd3 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,36 @@ +@Library('eo-jenkins-lib@master') import eo.Utils + +pipeline { + agent any + stages { + stage('Unit Tests') { + steps { + sh 'tox -rv' + } + } + stage('Packaging') { + steps { + script { + if (env.JOB_NAME == 'passerelle' && env.GIT_BRANCH == 'origin/master') { + sh 'sudo -H -u eobuilder /usr/local/bin/eobuilder -d jessie,stretch passerelle' + } + } + } + } + } + post { + always { + script { + utils = new Utils() + utils.mail_notify(currentBuild, env, 'admin+jenkins-passerelle@entrouvert.com') + utils.publish_coverage('coverage.xml') + utils.publish_coverage_native('index.html') + utils.publish_pylint('pylint.out') + } + junit '*_results.xml' + } + success { + cleanWs() + } + } +} diff --git a/pylint.sh b/pylint.sh index babdf18..d7295cc 100755 --- a/pylint.sh +++ b/pylint.sh @@ -10,7 +10,4 @@ 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/setup.py b/setup.py index 41756b1..1039d16 100755 --- a/setup.py +++ b/setup.py @@ -17,11 +17,12 @@ def get_version(): version_file.close() return version if os.path.exists('.git'): - p = subprocess.Popen(['git','describe','--match=v*'], stdout=subprocess.PIPE) + p = subprocess.Popen(['git', 'describe', '--dirty', '--match=v*'], stdout=subprocess.PIPE) result = p.communicate()[0] - version = result.split()[0][1:] - version = version.replace('-', '.') - return version + if p.returncode == 0: + version = str(result.split()[0][1:]) + version = version.replace('-', '.') + return version return '0' class eo_sdist(sdist): diff --git a/tox.ini b/tox.ini index 9672bb2..2f06b7e 100644 --- a/tox.ini +++ b/tox.ini @@ -1,15 +1,14 @@ [tox] -envlist = coverage-{django18,django111}-pylint -toxworkdir = {env:TMPDIR:/tmp}/tox-{env:USER}/passerelle/ +toxworkdir = {env:TMPDIR:/tmp}/tox-{env:USER}/passerelle/{env:BRANCH_NAME:} +envlist = django{18,111} [testenv] -usedevelop = - coverage: True +usedevelop = True +basepython = python2 setenv = DJANGO_SETTINGS_MODULE=passerelle.settings PASSERELLE_SETTINGS_FILE=tests/settings.py fast: FAST=--nomigrations - coverage: COVERAGE=--junitxml=test_results.xml --cov-report xml --cov=passerelle/ --cov-config .coveragerc deps = django18: django>=1.8,<1.9 django111: django>=1.11,<1.12 @@ -26,5 +25,6 @@ deps = lxml mohawk commands = - py.test {env:FAST:} {env:COVERAGE:} {posargs:tests/} - pylint: ./pylint.sh passerelle/ + django18: py.test {posargs: {env:FAST:} --junitxml=test_{envname}_results.xml --cov-report xml --cov-report html --cov=passerelle/ --cov-config .coveragerc tests/} + django18: ./pylint.sh passerelle/ + django111: py.test {posargs: --junitxml=test_{envname}_results.xml tests/} -- 2.18.0