From 1f2ed13133be2639a09eccc439a9b68b98521da0 Mon Sep 17 00:00:00 2001 From: Emmanuel Cazenave Date: Thu, 9 Aug 2018 17:24:50 +0200 Subject: [PATCH 2/2] create a Jenkinsfile (#24646) --- Jenkinsfile | 36 ++++++++++++++++++++++++++++++++++++ pylint.sh | 3 --- tox.ini | 14 +++++++------- 3 files changed, 43 insertions(+), 10 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/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