diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..ae34198 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,44 @@ +@Library('eo-jenkins-lib@master') import eo.Utils + +pipeline { + agent any + options { disableConcurrentBuilds() } + 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 == 'welco' && env.GIT_BRANCH == 'origin/master') { + sh 'sudo -H -u eobuilder /usr/local/bin/eobuilder welco' + } + } + } + } + } + post { + always { + script { + utils = new Utils() + utils.mail_notify(currentBuild, env, 'admin+jenkins-welco@entrouvert.com') + } + } + success { + cleanWs() + } + } +} diff --git a/pylint.sh b/pylint.sh new file mode 100755 index 0000000..d7295cc --- /dev/null +++ b/pylint.sh @@ -0,0 +1,13 @@ +#!/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 +pylint -f parseable --rcfile ${PYLINT_RC} "$@" | tee pylint.out || /bin/true diff --git a/tests/settings.py b/tests/settings.py new file mode 100644 index 0000000..3c02312 --- /dev/null +++ b/tests/settings.py @@ -0,0 +1 @@ +LANGUAGE_CODE = 'en-en' diff --git a/tox.ini b/tox.ini index a0a48f7..1f0a84a 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = coverage-{django18,django111} +envlist = py27-{django18,django111} toxworkdir = {env:TMPDIR:/tmp}/tox-{env:USER}/welco/ [testenv] @@ -7,8 +7,8 @@ usedevelop = coverage: True setenv = DJANGO_SETTINGS_MODULE=welco.settings + WELCO_SETTINGS_FILE=tests/settings.py fast: FAST=--nomigrations - coverage: COVERAGE=--junitxml=test_results.xml --cov-report xml --cov=welco/ deps = django18: django>=1.8,<1.9 django18: django-taggit<0.23 @@ -22,10 +22,12 @@ deps = httmock python-dateutil pylint<1.8 - pylint-django<0.9 + pylint-django<0.8.1 django-webtest pyquery lxml git+https://git.entrouvert.org/debian/django-ckeditor.git commands = - py.test {env:FAST:} {env:COVERAGE:} {posargs:tests/} + django18: py.test {posargs: --junitxml=test_{envname}_results.xml tests/} + django111: ./pylint.sh welco/ + django111: py.test {posargs: --junitxml=test_{envname}_results.xml --cov-report xml --cov-report html --cov=welco/ tests/}