From 59bb0a3116f8a841466bdf46054da9fbaedada58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Sun, 31 Mar 2019 16:07:21 +0200 Subject: [PATCH] build: add jenkinsfile --- Jenkinsfile | 43 +++++++++++++++++++++++++++++++++++++++++++ pylint.sh | 16 ++++++++++++++++ tox.ini | 13 +++++++------ 3 files changed, 66 insertions(+), 6 deletions(-) create mode 100644 Jenkinsfile create mode 100755 pylint.sh diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..71c4a96 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,43 @@ +@Library('eo-jenkins-lib@master') import eo.Utils + +pipeline { + agent any + stages { + stage('Unit Tests') { + steps { + sh 'tox -rv' + } + post { + always { + script { + utils = new Utils() + utils.publish_coverage('coverage.xml') + utils.publish_coverage_native('index.html') + utils.publish_pylint('pylint.out') + } + junit '*_results.xml' + } + } + } + stage('Packaging') { + steps { + script { + if (env.JOB_NAME == 'fargo' && env.GIT_BRANCH == 'origin/master') { + sh 'sudo -H -u eobuilder /usr/local/bin/eobuilder fargo' + } + } + } + } + } + post { + always { + script { + utils = new Utils() + utils.mail_notify(currentBuild, env, 'admin+jenkins-fargo@entrouvert.com') + } + } + success { + cleanWs() + } + } +} diff --git a/pylint.sh b/pylint.sh new file mode 100755 index 0000000..babdf18 --- /dev/null +++ b/pylint.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +set -e -x +env +if [ -f /var/lib/jenkins/pylint.django.rc ]; then + PYLINT_RC=/var/lib/jenkins/pylint.django.rc +elif [ -f pylint.django.rc ]; then + PYLINT_RC=pylint.django.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 eb40b56..12ea960 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,6 @@ [tox] -toxworkdir = {env:TMPDIR:/tmp}/tox-{env:USER}/fargo/ -envlist = py2-coverage-dj18-sqlite,py2-coverage-dj111-sqlite,py2-coverage-dj18-pg,{py2,py3}-coverage-dj111-pg +toxworkdir = {env:TMPDIR:/tmp}/tox-{env:USER}/fargo/{env:BRANCH_NAME:} +envlist = py2-coverage-dj18-sqlite,py2-coverage-dj111-sqlite-pylint,py2-coverage-dj18-pg,{py2,py3}-coverage-dj111-pg [testenv] usedevelop = True @@ -11,7 +11,7 @@ setenv = pg: DB_ENGINE=postgresql_psycopg2 DJANGO_SETTINGS_MODULE=fargo.settings FARGO_SETTINGS_FILE=tests/settings.py - coverage: COVERAGE=--cov=fargo --cov-report xml + coverage: COVERAGE=--junitxml=test_results.xml --random --cov-report xml --cov-report html --cov=fargo/ deps = dj18: django>=1.8,<1.9 dj18: django-tables2<1.1 @@ -19,6 +19,8 @@ deps = dj111: django-tables2>=1.5,<2.0 pytest>=3.3.0,<4.1 pg: psycopg2 + pylint<1.8 + pylint-django<0.8.1 pytest-cov pytest-random pytest-mock @@ -29,6 +31,5 @@ deps = djangorestframework>=3.3,<3.4 mock commands = - py.test {env:COVERAGE:} {posargs:--random --junit-xml=junit-{envname}.xml tests} - coverage: mv coverage.xml coverage-{envname}.xml - + py.test {env:COVERAGE:} {posargs:tests/} + pylint: ./pylint.sh fargo/