diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..d7dfe26 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,39 @@ +@Library('eo-jenkins-lib@master') import eo.Utils + +pipeline { + agent any + stages { + stage('Unit Tests') { + steps { + sh './jenkins.sh' + } + } + stage('Packaging') { + steps { + script { + if (env.JOB_NAME == 'authentic2-auth-fc' && env.GIT_BRANCH == 'origin/master') { + sh 'sudo -H -u eobuilder /usr/local/bin/eobuilder authentic2-auth-fc' + } + } + } + } + } + post { + always { + script { + utils = new Utils() + utils.mail_notify(currentBuild, env, 'admin+jenkins-authentic2-auth-fc@entrouvert.com') + utils.publish_coverage('coverage-*.xml') + utils.publish_coverage_native( + 'index.html', 'htmlcov-coverage-dj18-pg', 'Coverage a2-auth-fc PG') + utils.publish_coverage_native( + 'index.html', 'htmlcov-coverage-dj18-sqlite', 'Coverage a2-auth-fc SQLITE') + utils.publish_pylint('pylint.out') + } + junit 'junit-*.xml' + } + success { + cleanWs() + } + } +} diff --git a/jenkins.sh b/jenkins.sh new file mode 100755 index 0000000..2c4fca0 --- /dev/null +++ b/jenkins.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +set -e + +for DIRECTORY in "htmlcov" "htmlcov-coverage-dj18-authentic-pg" "htmlcov-coverage-dj18-rbac-pg" "venv" +do + if [ -d "$DIRECTORY" ]; then + rm -r $DIRECTORY + fi +done + +virtualenv venv +venv/bin/pip install tox +venv/bin/tox -rv 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/tox.ini b/tox.ini index fb8d8eb..066ebd7 100644 --- a/tox.ini +++ b/tox.ini @@ -5,22 +5,25 @@ [tox] toxworkdir = {env:TMPDIR:/tmp}/tox-{env:USER}/authentic2-auth-fc/ -envlist = {coverage,nocoverage}-{dj18}-{pg,sqlite} +envlist = coverage-dj18-{pg,sqlite} [testenv] +whitelist_externals = + /bin/mv + /bin/rm setenv = AUTHENTIC2_SETTINGS_FILE=tests/settings.py DJANGO_SETTINGS_MODULE=authentic2.settings sqlite: DB_ENGINE=django.db.backends.sqlite3 pg: DB_ENGINE=django.db.backends.postgresql_psycopg2 - coverage: COVERAGE=--junitxml=junit-{envname}.xml --cov-report xml --cov=src/ --cov-config .coveragerc + coverage: COVERAGE=--junitxml=junit-{envname}.xml --cov-report xml --cov-report html --cov=src/ --cov-config .coveragerc fast: FAST=--nomigrations usedevelop = coverage: True nocoverage: False deps = dj18: django>1.8,<1.9 - dj19: django>1.8,<1.9 + dj18: django-tables2<1.1 pg: psycopg2 coverage pytest-cov @@ -36,8 +39,12 @@ deps = pyquery httmock pytz - requests<=2.11.1 - ../authentic2 + requests + git+https://git.entrouvert.org/authentic.git commands = ./getlasso.sh py.test {env:FAST:} {env:COVERAGE:} {posargs:tests/} + coverage: mv coverage.xml coverage-{envname}.xml + coverage: rm -rf htmlcov-{envname} + coverage: mv htmlcov htmlcov-{envname} + coverage-dj111-pg: ./pylint.sh src/authentic2-auth-fc/