add Jenkinsfile, support dj111, prepare for python3, improve tox.ini (fixes #30321)
This commit is contained in:
parent
d9f9f68a69
commit
c720648330
|
@ -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 == 'authentic2-auth-kerberos' && env.GIT_BRANCH == 'origin/master') {
|
||||
sh 'sudo -H -u eobuilder /usr/local/bin/eobuilder authentic2-auth-kerberos'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
post {
|
||||
always {
|
||||
script {
|
||||
utils = new Utils()
|
||||
utils.mail_notify(currentBuild, env, 'admin+jenkins-authentic2-auth-kerberos@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
|
24
setup.py
24
setup.py
|
@ -9,7 +9,7 @@ from setuptools.command.sdist import sdist
|
|||
|
||||
class version_sdist(sdist):
|
||||
def run(self):
|
||||
print "creating VERSION file"
|
||||
print("creating VERSION file")
|
||||
if os.path.exists('VERSION'):
|
||||
os.remove('VERSION')
|
||||
version = get_version()
|
||||
|
@ -17,29 +17,35 @@ class version_sdist(sdist):
|
|||
version_file.write(version)
|
||||
version_file.close()
|
||||
sdist.run(self)
|
||||
print "removing VERSION file"
|
||||
print("removing VERSION file")
|
||||
if os.path.exists('VERSION'):
|
||||
os.remove('VERSION')
|
||||
|
||||
|
||||
def get_version():
|
||||
'''Use the VERSION, if absent generates a version with git describe, if not
|
||||
tag exists, take 0.0.0- and add the length of the commit log.
|
||||
tag exists, take 0.0- and add the length of the commit log.
|
||||
'''
|
||||
if os.path.exists('VERSION'):
|
||||
with open('VERSION', 'r') as v:
|
||||
return v.read()
|
||||
if os.path.exists('.git'):
|
||||
p = subprocess.Popen(['git', 'describe', '--dirty', '--match=v*'], stdout=subprocess.PIPE,
|
||||
p = subprocess.Popen(['git', 'describe', '--dirty=.dirty','--match=v*'], stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE)
|
||||
result = p.communicate()[0]
|
||||
if p.returncode == 0:
|
||||
result = result.split()[0][1:]
|
||||
result = result.decode('ascii').strip()[1:] # strip spaces/newlines and initial v
|
||||
if '-' in result: # not a tagged version
|
||||
real_number, commit_count, commit_hash = result.split('-', 2)
|
||||
version = '%s.post%s+%s' % (real_number, commit_count, commit_hash)
|
||||
else:
|
||||
version = result
|
||||
return version
|
||||
else:
|
||||
result = '0.0.0-%s' % len(subprocess.check_output(
|
||||
['git', 'rev-list', 'HEAD']).splitlines())
|
||||
return result.replace('-', '.').replace('.g', '+g')
|
||||
return '0.0.0'
|
||||
return '0.0.post%s' % len(
|
||||
subprocess.check_output(
|
||||
['git', 'rev-list', 'HEAD']).splitlines())
|
||||
return '0.0'
|
||||
|
||||
|
||||
setup(
|
||||
|
|
|
@ -9,7 +9,6 @@ from django.core.exceptions import ImproperlyConfigured
|
|||
from django_kerberos.backends import KerberosBackend
|
||||
from authentic2.backends.ldap_backend import LDAPBackend
|
||||
from authentic2.ldap_utils import FilterFormatter
|
||||
from authentic2.user_login_failure import user_login_success
|
||||
|
||||
from . import app_settings
|
||||
|
||||
|
@ -31,12 +30,12 @@ class A2KerberosBackend(KerberosBackend):
|
|||
def provision_user(self, principal, user):
|
||||
pass
|
||||
|
||||
def authenticate(self, principal=None, **kwargs):
|
||||
def authenticate(self, principal=None, request=None):
|
||||
if not app_settings.ENABLE:
|
||||
return
|
||||
if not app_settings.DJANGO_BACKEND:
|
||||
return
|
||||
return super(A2KerberosBackend, self).authenticate(principal=principal, **kwargs)
|
||||
return super(A2KerberosBackend, self).authenticate(principal=principal)
|
||||
|
||||
def get_saml2_authn_context(self):
|
||||
import lasso
|
||||
|
@ -48,7 +47,7 @@ LDAPBackend._VALID_CONFIG_KEYS.append('principal_filter')
|
|||
|
||||
|
||||
class A2LdapKerberosBackend(LDAPBackend):
|
||||
def authenticate(self, principal=None, **kwargs):
|
||||
def authenticate(self, principal=None, request=None):
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
if not app_settings.ENABLE:
|
||||
|
@ -77,7 +76,7 @@ class A2LdapKerberosBackend(LDAPBackend):
|
|||
return
|
||||
if block['limit_to_realm'] and realm != block['realm']:
|
||||
return
|
||||
if not '{username}' in block['principal_filter']:
|
||||
if '{username}' not in block['principal_filter']:
|
||||
logger.warning('principal_filter does not contain the {username} pattern: %r',
|
||||
block['principal_filter'])
|
||||
return
|
||||
|
|
29
tox.ini
29
tox.ini
|
@ -5,20 +5,21 @@
|
|||
|
||||
|
||||
[tox]
|
||||
envlist = {coverage,nocoverage}-{dj18,dj111}-{pg,sqlite},package
|
||||
toxworkdir = {env:TMPDIR:/tmp}/tox-{env:USER}/authentic2-auth-kerberos/{env:BRANCH_NAME:}
|
||||
envlist = py27-coverage-{dj18,dj111}-{pg,sqlite},pylint
|
||||
|
||||
[testenv]
|
||||
whitelist_externals =
|
||||
/bin/mv
|
||||
/bin/rm
|
||||
setenv =
|
||||
AUTHENTIC2_SETTINGS_FILE=tests/settings.py
|
||||
DJANGO_SETTINGS_MODULE=authentic2.settings
|
||||
sqlite: DB_ENGINE=sqlite3
|
||||
pg: DB_ENGINE=postgresql_psycopg2
|
||||
coverage: COVERAGE=--junit-xml=junit.xml --cov=src --cov-report xml
|
||||
coverage: COVERAGE=--cov=src --cov-branch --cov-append --cov-report xml --cov-report html
|
||||
usedevelop =
|
||||
coverage: true
|
||||
nocoverage: false
|
||||
deps =
|
||||
dj18: django>1.8,<1.9
|
||||
dj18: django-tables2<1.1
|
||||
|
@ -31,22 +32,14 @@ deps =
|
|||
pytest-django
|
||||
ldaptools
|
||||
http://git.entrouvert.org/authentic.git/snapshot/authentic-master.tar.bz2
|
||||
django-kerberos
|
||||
commands =
|
||||
./getlasso.sh
|
||||
py.test {env:COVERAGE:} {posargs:tests}
|
||||
coverage: mv coverage.xml coverage-{envname}.xml
|
||||
py.test {env:COVERAGE:} -o junit_suite_name={envname} --junit-xml=junit-{envname}.xml {posargs:tests}
|
||||
|
||||
[testenv:package]
|
||||
# eobuilder is not on pypi, too bad
|
||||
whitelist_externals =
|
||||
/bin/sh
|
||||
deps = setuptools
|
||||
pip<8
|
||||
pyasn1
|
||||
ndg-httpsclient
|
||||
pyopenssl
|
||||
skipdist = True
|
||||
[testenv:pylint]
|
||||
basepython = python2.7
|
||||
deps =
|
||||
pylint<1.8
|
||||
pylint-django<0.8.1
|
||||
commands =
|
||||
pip install -U --find-links https://jenkins.entrouvert.org/packages/ eobuilder
|
||||
sh -c "sudo -u eobuilder -E env HOME=/var/lib/eobuilder PATH=$PATH $VIRTUAL_ENV/bin/eobuilder-ctl -d wheezy,jessie {posargs:authentic2-auth-kerberos}"
|
||||
pylint: ./pylint.sh src/authentic2_auth_kerberos/
|
||||
|
|
Loading…
Reference in New Issue