summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Dauvergne <bdauvergne@entrouvert.com>2019-03-02 13:42:48 (GMT)
committerBenjamin Dauvergne <bdauvergne@entrouvert.com>2019-03-02 14:53:56 (GMT)
commit91f726ed4faada5ed992831111f008949fcdcf9e (patch)
tree7dd42a35c14973aebafad56f2422d624397e5744
parent803907f00fcb7b6598cb49b41d13be40ec23a722 (diff)
downloaddjango-mellon-91f726ed4faada5ed992831111f008949fcdcf9e.zip
django-mellon-91f726ed4faada5ed992831111f008949fcdcf9e.tar.gz
django-mellon-91f726ed4faada5ed992831111f008949fcdcf9e.tar.bz2
use Jenkinsfile (#14810)
- Copied from authentic2-auth-kerberos - Removal of .coveragerc as it prevented coverage from working, dunno why.
-rw-r--r--.coveragerc2
-rw-r--r--Jenkinsfile45
-rwxr-xr-xmerge-junit-results.py65
-rwxr-xr-xpylint.sh13
-rw-r--r--tox.ini14
5 files changed, 133 insertions, 6 deletions
diff --git a/.coveragerc b/.coveragerc
deleted file mode 100644
index c712d25..0000000
--- a/.coveragerc
+++ /dev/null
@@ -1,2 +0,0 @@
-[run]
-omit = tests/*
diff --git a/Jenkinsfile b/Jenkinsfile
new file mode 100644
index 0000000..24446ef
--- /dev/null
+++ b/Jenkinsfile
@@ -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()
+ }
+ }
+}
diff --git a/merge-junit-results.py b/merge-junit-results.py
new file mode 100755
index 0000000..a50bc7f
--- /dev/null
+++ b/merge-junit-results.py
@@ -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()
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 514c06c..a2a945a 100644
--- a/tox.ini
+++ b/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