Include pylint into Jenkinsfile

Change-Id: Ica10d5aeba78f1f605965d688f7f41287f0b1c46
Reviewed-on: https://forge.frm2.tum.de/review/19555
Tested-by: JenkinsCodeReview <bjoern_pedersen@frm2.tum.de>
Reviewed-by: Enrico Faulhaber <enrico.faulhaber@frm2.tum.de>
This commit is contained in:
Björn Pedersen
2018-12-06 16:01:28 +01:00
committed by Enrico Faulhaber
parent dec643f522
commit a8bc6606af

101
ci/Jenkinsfile vendored
View File

@ -25,10 +25,75 @@ change-merged''',
this.verifyresult = [:]
def changedFiles = '';
def run_tests(pyver)
{
writeFile file: 'setup.cfg', text: '''
def run_pylint(pyver) {
def status = 'OK'
changedFiles = sh returnStdout: true, script: '''\
#!/bin/bash
git diff HEAD~1... --name-only --diff-filter=ARCM -- \\*.py
'''
changedFiles = changedFiles.replaceAll("[\r\n]", " ").trim()
res = sh returnStatus: true, script: """\
#!/bin/bash -x
. /home/jenkins/secopvenv/bin/activate
pip install -r requirements-dev.txt
pip install -r requirements.txt
pip install isort pylint
python setup.py develop
export PYTHONIOENCODING=utf8
echo "$changedFiles"
if [[ -n "$changedFiles" ]]; then
set -o pipefail
pylint $changedFiles | tee pylint_results.txt
isort -df $changedFiles | tee isort_results.txt
fi
"""
withCredentials([string(credentialsId: 'GERRITHTTP',
variable: 'GERRITHTTP')]) {
sh '''\
#!/bin/bash
/home/jenkins/tools2/bin/pylint2gerrit
'''
} // credentials
echo "pylint result: $res"
if ( res != 0 ) {
currentBuild.result='FAILURE'
this.verifyresult.put('pylint'+ pyver, -1)
status = 'FAILURE'
}
gerritverificationpublisher([
verifyStatusValue: this.verifyresult['pylint'+pyver],
verifyStatusCategory: 'pylint ',
verifyStatusName: 'pylint-'+pyver,
verifyStatusReporter: 'jenkins',
verifyStatusRerun: '!recheck'])
warnings([ canComputeNew: false,
canRunOnFailed: true,
defaultEncoding: '',
excludePattern: '',
healthy: '',
includePattern: '',
messagesPattern: '',
parserConfigurations: [[parserName: 'PyLint', pattern: 'pylint_*.txt']],
unHealthy: '',
failedTotalAll: '0',
unstableTotalAll: '1'
])
if (status == 'FAILURE') {
throw new Exception('Failure in pylint with ' + pyver)
}
} // run_pylint
def run_tests(pyver) {
stage('Test:' + pyver) {
writeFile file: 'setup.cfg', text: '''
[tool:pytest]
addopts = --junit-xml=pytest.xml --junit-prefix=''' + pyver
@ -36,7 +101,7 @@ addopts = --junit-xml=pytest.xml --junit-prefix=''' + pyver
verifyresult.put(pyver, 0)
try {
timeout(5) {
sh '''\
sh '''\
#!/bin/bash
. /home/jenkins/secopvenv/bin/activate
pip install -r requirements-dev.txt
@ -44,25 +109,26 @@ pip install -r requirements.txt
python setup.py develop
make test
'''
verifyresult.put(pyver, 1)
verifyresult.put(pyver, 1)
}
} catch (all) {
currentBuild.result = 'FAILURE'
status = 'FAILURE'
verifyresult.put(pyver, -1)
}
gerritverificationpublisher([
verifyStatusValue: verifyresult[pyver],
verifyStatusCategory: 'test ',
verifyStatusName: 'pytest-'+pyver,
verifyStatusReporter: 'jenkins',
verifyStatusRerun: '!recheck'])
gerritverificationpublisher([
verifyStatusValue: verifyresult[pyver],
verifyStatusCategory: 'test ',
verifyStatusName: 'pytest-'+pyver,
verifyStatusReporter: 'jenkins',
verifyStatusRerun: '!recheck'])
step([$class: 'JUnitResultArchiver', allowEmptyResults: true,
keepLongStdio: true, testResults: 'pytest.xml'])
if (status == 'FAILURE') {
throw new Exception('Failure in test with ' + pyver)
}
}
}
def run_docs() {
@ -74,6 +140,7 @@ def run_docs() {
python setup.py develop
'''
}
stage('check links') {
sh '''
. /home/jenkins/secopvenv/bin/activate
@ -81,30 +148,35 @@ def run_docs() {
make -C doc linkcheck
'''
}
stage('build html') {
sh '''
. /home/jenkins/secopvenv/bin/activate
make -C doc html
'''
}
stage('build singlehtml') {
sh '''
. /home/jenkins/secopvenv/bin/activate
make -C doc singlehtml
'''
}
stage('build latexpdf') {
sh '''
. /home/jenkins/secopvenv/bin/activate
make -C doc latexpdf
'''
}
stage('build man') {
sh '''
. /home/jenkins/secopvenv/bin/activate
make -C doc man
'''
}
stage('store html doc for build') {
publishHTML([allowMissing: false, alwaysLinkToLastBuild: false, keepAll: true, reportDir: 'doc/_build/html', reportFiles: 'index.html', reportName: 'Built documentation', reportTitles: ''])
gerritverificationpublisher([
@ -169,7 +241,12 @@ node("master") {
img.inside {
run_tests('python2')
}},
'Docs': {
'Pylint': {
img = docker.image('secop_base:latest')
img.inside {
run_pylint('python2')
}},
'Docs': {
img = docker.image('secop_docs:latest')
img.inside {
run_docs()