create jenkins pipeline job (#24805)
This commit is contained in:
parent
1bf0e762c8
commit
7bc89df159
|
@ -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()
|
||||
}
|
||||
}
|
||||
}
|
27
jenkins.sh
27
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
|
||||
|
|
|
@ -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
|
|
@ -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('/', '-'),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
11
tox.ini
11
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]
|
||||
|
|
Loading…
Reference in New Issue