use Jenkinsfile (#14810)
- Copied from authentic2-auth-kerberos - Removal of .coveragerc as it prevented coverage from working, dunno why.
This commit is contained in:
parent
803907f00f
commit
91f726ed4f
|
@ -1,2 +0,0 @@
|
|||
[run]
|
||||
omit = tests/*
|
|
@ -0,0 +1,45 @@
|
|||
@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')
|
||||
}
|
||||
sh './merge-junit-results.py junit-*.xml >junit.xml'
|
||||
junit 'junit.xml'
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Packaging') {
|
||||
steps {
|
||||
script {
|
||||
if (env.JOB_NAME == 'django-mellon' && env.GIT_BRANCH == 'origin/master') {
|
||||
sh 'sudo -H -u eobuilder /usr/local/bin/eobuilder django-mellon'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
post {
|
||||
always {
|
||||
script {
|
||||
utils = new Utils()
|
||||
utils.mail_notify(currentBuild, env, 'admin+jenkins-django-mellon@entrouvert.com')
|
||||
}
|
||||
}
|
||||
success {
|
||||
cleanWs()
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
#!/usr/bin/env python
|
||||
#
|
||||
# Corey Goldberg, Dec 2012
|
||||
#
|
||||
|
||||
import os
|
||||
import sys
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
|
||||
"""Merge multiple JUnit XML files into a single results file.
|
||||
Output dumps to sdtdout.
|
||||
example usage:
|
||||
$ python merge_junit_results.py results1.xml results2.xml > results.xml
|
||||
"""
|
||||
|
||||
|
||||
def main():
|
||||
args = sys.argv[1:]
|
||||
if not args:
|
||||
usage()
|
||||
sys.exit(2)
|
||||
if '-h' in args or '--help' in args:
|
||||
usage()
|
||||
sys.exit(2)
|
||||
merge_results(args[:])
|
||||
|
||||
|
||||
def merge_results(xml_files):
|
||||
failures = 0
|
||||
tests = 0
|
||||
errors = 0
|
||||
time = 0.0
|
||||
cases = []
|
||||
|
||||
for file_name in xml_files:
|
||||
tree = ET.parse(file_name)
|
||||
test_suite = tree.getroot()
|
||||
failures += int(test_suite.attrib['failures'])
|
||||
tests += int(test_suite.attrib['tests'])
|
||||
errors += int(test_suite.attrib['errors'])
|
||||
time += float(test_suite.attrib['time'])
|
||||
name = test_suite.attrib.get('name', '')
|
||||
for child in test_suite.getchildren():
|
||||
child.attrib['classname'] = '%s-%s' % (name, child.attrib.get('classname', ''))
|
||||
cases.append(test_suite.getchildren())
|
||||
|
||||
new_root = ET.Element('testsuite')
|
||||
new_root.attrib['failures'] = '%s' % failures
|
||||
new_root.attrib['tests'] = '%s' % tests
|
||||
new_root.attrib['errors'] = '%s' % errors
|
||||
new_root.attrib['time'] = '%s' % time
|
||||
for case in cases:
|
||||
new_root.extend(case)
|
||||
new_tree = ET.ElementTree(new_root)
|
||||
ET.dump(new_tree)
|
||||
|
||||
|
||||
def usage():
|
||||
this_file = os.path.basename(__file__)
|
||||
print('Usage: %s results1.xml results2.xml' % this_file)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
|
@ -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
|
14
tox.ini
14
tox.ini
|
@ -10,10 +10,9 @@ setenv =
|
|||
PYTHONPATH=.
|
||||
sqlite: DB_ENGINE=sqlite3
|
||||
pg: DB_ENGINE=postgresql_psycopg2
|
||||
coverage: COVERAGE=--junit-xml=junit-{envname}.xml --cov=mellon --cov-report xml
|
||||
coverage: COVERAGE=--cov=mellon --cov-branch --cov-append --cov-report xml --cov-report html
|
||||
usedevelop =
|
||||
coverage: true
|
||||
nocoverage: false
|
||||
deps =
|
||||
dj18: django>1.8,<1.9
|
||||
dj111: django>1.11,<1.12
|
||||
|
@ -34,5 +33,12 @@ deps =
|
|||
commands =
|
||||
py2: ./getlasso.sh
|
||||
py3: ./getlasso3.sh
|
||||
py.test --random {env:COVERAGE:} {posargs:tests}
|
||||
coverage: mv coverage.xml coverage-{envname}.xml
|
||||
py.test -o junit_suite_name={envname} --junit-xml=junit-{envname}.xml --random {env:COVERAGE:} {posargs:tests}
|
||||
|
||||
[testenv:pylint]
|
||||
basepython = python2.7
|
||||
deps =
|
||||
pylint<1.8
|
||||
pylint-django<0.8.1
|
||||
commands =
|
||||
pylint: ./pylint.sh mellon
|
||||
|
|
Loading…
Reference in New Issue