summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEmmanuel Cazenave <ecazenave@entrouvert.com>2018-06-29 07:55:42 (GMT)
committerEmmanuel Cazenave <ecazenave@entrouvert.com>2018-07-02 09:56:19 (GMT)
commit7bc89df15925514a81c86c7b71860ed1632ac3bf (patch)
treec10197862985a2e412e26cff64f16f2e33ee3259
parent1bf0e762c84ed7fa526de676249e40a2de1bacc9 (diff)
downloadauthentic-7bc89df15925514a81c86c7b71860ed1632ac3bf.zip
authentic-7bc89df15925514a81c86c7b71860ed1632ac3bf.tar.gz
authentic-7bc89df15925514a81c86c7b71860ed1632ac3bf.tar.bz2
create jenkins pipeline job (#24805)
-rw-r--r--Jenkinsfile39
-rwxr-xr-xjenkins.sh27
-rwxr-xr-xpylint.sh13
-rw-r--r--tests/settings.py2
-rw-r--r--tox.ini11
5 files changed, 70 insertions, 22 deletions
diff --git a/Jenkinsfile b/Jenkinsfile
new file mode 100644
index 0000000..aa18488
--- /dev/null
+++ b/Jenkinsfile
@@ -0,0 +1,39 @@
+@Library('eo-jenkins-lib@wip/publish_coverage_native') import eo.Utils
+
+pipeline {
+ agent any
+ stages {
+ stage('Unit Tests') {
+ steps {
+ sh './jenkins.sh'
+ }
+ }
+ stage('Packaging') {
+ steps {
+ script {
+ if (env.JOB_NAME == 'authentic2' && env.GIT_BRANCH == 'origin/master') {
+ sh 'sudo -H -u eobuilder /usr/local/bin/eobuilder -d jessie authentic'
+ }
+ }
+ }
+ }
+ }
+ post {
+ always {
+ script {
+ utils = new Utils()
+ utils.mail_notify(currentBuild, env, 'admin+jenkins-authentic@entrouvert.com')
+ utils.publish_coverage('coverage-*.xml')
+ utils.publish_coverage_native(
+ 'index.html', 'htmlcov-coverage-dj18-authentic-pg', 'Coverage a2')
+ utils.publish_coverage_native(
+ 'index.html', 'htmlcov-coverage-dj18-rbac-pg', , 'Coverage rbac')
+ utils.publish_pylint('pylint.out')
+ }
+ junit 'junit-*.xml'
+ }
+ success {
+ cleanWs()
+ }
+ }
+}
diff --git a/jenkins.sh b/jenkins.sh
index d38131d..f32ef5c 100755
--- a/jenkins.sh
+++ b/jenkins.sh
@@ -2,20 +2,13 @@
set -e
-./getlasso.sh
-# SNI support for Debian
-pip install --upgrade pyOpenSSL ndg-httpsclient pyasn1
-pip install --upgrade pip\>9
-pip install --upgrade pylint pylint-django 'django<1.9'
-pip install --upgrade tox
-pip install -U 'virtualenv<14'
-rm -f coverage*.xml junit*.xml
-if [[ `date +%H%M` < 630 ]]; then
- # run full tests (with migrations) at night
- tox -r -e 'coverage-dj18-{authentic,rbac}-{pg,sqlite}'
-else
- tox -r -e 'fast-coverage-dj18-{authentic,rbac}-{pg,sqlite}'
-fi
-(pylint -f parseable --rcfile /var/lib/jenkins/pylint.django.rc src/authentic2/ | tee pylint.out) || /bin/true
-./merge-junit-results.py junit-*coverage-dj18-authentic-pg.xml junit-*coverage-dj18-rbac-pg.xml > junit.xml
-./merge-coverage.py -o coverage.xml coverage-*.xml
+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/tests/settings.py b/tests/settings.py
index bdde5b7..fb04cae 100644
--- a/tests/settings.py
+++ b/tests/settings.py
@@ -13,7 +13,7 @@ DATABASES = {
'default': {
'ENGINE': os.environ.get('DB_ENGINE', 'django.db.backends.sqlite3'),
'TEST': {
- 'NAME': 'a2-test',
+ 'NAME': 'a2-test-%s' % os.environ.get("BRANCH_NAME", "").replace('/', '-'),
},
}
}
diff --git a/tox.ini b/tox.ini
index cade4a4..34b425b 100644
--- a/tox.ini
+++ b/tox.ini
@@ -4,7 +4,7 @@
# and then run "tox" from this directory.
[tox]
-toxworkdir = {env:TMPDIR:/tmp}/tox-{env:USER}/authentic/
+toxworkdir = {env:TMPDIR:/tmp}/tox-{env:USER}/authentic/{env:BRANCH_NAME:}
envlist = coverage-dj18-{authentic,rbac}-{pg,sqlite}
[testenv]
@@ -13,9 +13,10 @@ whitelist_externals =
/bin/mv
setenv =
AUTHENTIC2_SETTINGS_FILE=tests/settings.py
+ BRANCH_NAME={env:BRANCH_NAME:}
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
authentic: DJANGO_SETTINGS_MODULE=authentic2.settings
rbac: DJANGO_SETTINGS_MODULE=django_rbac.test_settings
fast: FAST=--nomigrations
@@ -25,7 +26,6 @@ usedevelop =
deps =
pip > 9
dj18: django>1.8,<1.9
- dj19: django>1.8,<1.9
pg: psycopg2
coverage
pytest-cov
@@ -45,8 +45,11 @@ deps =
commands =
./getlasso.sh
authentic: py.test {env:FAST:} {env:COVERAGE:} {posargs:tests/ --random}
- rbac: py.test --nomigrations {env:COVERAGE:} {posargs:tests_rbac/}
+ rbac: py.test {env:FAST:} {env:COVERAGE:} {posargs:tests_rbac/}
coverage: mv coverage.xml coverage-{envname}.xml
+ coverage-dj18-authentic-pg: mv htmlcov htmlcov-coverage-dj18-authentic-pg
+ coverage-dj18-rbac-pg: mv htmlcov htmlcov-coverage-dj18-rbac-pg
+ coverage-dj18-authentic-pg: ./pylint.sh src/authentic2/
[testenv:check]