build: add jenkinsfile

This commit is contained in:
Frédéric Péters 2019-03-31 16:07:21 +02:00
parent 99a8987d6b
commit 59bb0a3116
3 changed files with 66 additions and 6 deletions

43
Jenkinsfile vendored Normal file
View File

@ -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()
}
}
}

16
pylint.sh Executable file
View File

@ -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

13
tox.ini
View File

@ -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/