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:

committed by
Enrico Faulhaber

parent
dec643f522
commit
a8bc6606af
81
ci/Jenkinsfile
vendored
81
ci/Jenkinsfile
vendored
@ -25,9 +25,74 @@ change-merged''',
|
|||||||
|
|
||||||
|
|
||||||
this.verifyresult = [:]
|
this.verifyresult = [:]
|
||||||
|
def changedFiles = '';
|
||||||
|
|
||||||
def run_tests(pyver)
|
|
||||||
{
|
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: '''
|
writeFile file: 'setup.cfg', text: '''
|
||||||
[tool:pytest]
|
[tool:pytest]
|
||||||
addopts = --junit-xml=pytest.xml --junit-prefix=''' + pyver
|
addopts = --junit-xml=pytest.xml --junit-prefix=''' + pyver
|
||||||
@ -63,6 +128,7 @@ make test
|
|||||||
if (status == 'FAILURE') {
|
if (status == 'FAILURE') {
|
||||||
throw new Exception('Failure in test with ' + pyver)
|
throw new Exception('Failure in test with ' + pyver)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def run_docs() {
|
def run_docs() {
|
||||||
@ -74,6 +140,7 @@ def run_docs() {
|
|||||||
python setup.py develop
|
python setup.py develop
|
||||||
'''
|
'''
|
||||||
}
|
}
|
||||||
|
|
||||||
stage('check links') {
|
stage('check links') {
|
||||||
sh '''
|
sh '''
|
||||||
. /home/jenkins/secopvenv/bin/activate
|
. /home/jenkins/secopvenv/bin/activate
|
||||||
@ -81,30 +148,35 @@ def run_docs() {
|
|||||||
make -C doc linkcheck
|
make -C doc linkcheck
|
||||||
'''
|
'''
|
||||||
}
|
}
|
||||||
|
|
||||||
stage('build html') {
|
stage('build html') {
|
||||||
sh '''
|
sh '''
|
||||||
. /home/jenkins/secopvenv/bin/activate
|
. /home/jenkins/secopvenv/bin/activate
|
||||||
make -C doc html
|
make -C doc html
|
||||||
'''
|
'''
|
||||||
}
|
}
|
||||||
|
|
||||||
stage('build singlehtml') {
|
stage('build singlehtml') {
|
||||||
sh '''
|
sh '''
|
||||||
. /home/jenkins/secopvenv/bin/activate
|
. /home/jenkins/secopvenv/bin/activate
|
||||||
make -C doc singlehtml
|
make -C doc singlehtml
|
||||||
'''
|
'''
|
||||||
}
|
}
|
||||||
|
|
||||||
stage('build latexpdf') {
|
stage('build latexpdf') {
|
||||||
sh '''
|
sh '''
|
||||||
. /home/jenkins/secopvenv/bin/activate
|
. /home/jenkins/secopvenv/bin/activate
|
||||||
make -C doc latexpdf
|
make -C doc latexpdf
|
||||||
'''
|
'''
|
||||||
}
|
}
|
||||||
|
|
||||||
stage('build man') {
|
stage('build man') {
|
||||||
sh '''
|
sh '''
|
||||||
. /home/jenkins/secopvenv/bin/activate
|
. /home/jenkins/secopvenv/bin/activate
|
||||||
make -C doc man
|
make -C doc man
|
||||||
'''
|
'''
|
||||||
}
|
}
|
||||||
|
|
||||||
stage('store html doc for build') {
|
stage('store html doc for build') {
|
||||||
publishHTML([allowMissing: false, alwaysLinkToLastBuild: false, keepAll: true, reportDir: 'doc/_build/html', reportFiles: 'index.html', reportName: 'Built documentation', reportTitles: ''])
|
publishHTML([allowMissing: false, alwaysLinkToLastBuild: false, keepAll: true, reportDir: 'doc/_build/html', reportFiles: 'index.html', reportName: 'Built documentation', reportTitles: ''])
|
||||||
gerritverificationpublisher([
|
gerritverificationpublisher([
|
||||||
@ -168,6 +240,11 @@ node("master") {
|
|||||||
img = docker.image('secop_base:latest')
|
img = docker.image('secop_base:latest')
|
||||||
img.inside {
|
img.inside {
|
||||||
run_tests('python2')
|
run_tests('python2')
|
||||||
|
}},
|
||||||
|
'Pylint': {
|
||||||
|
img = docker.image('secop_base:latest')
|
||||||
|
img.inside {
|
||||||
|
run_pylint('python2')
|
||||||
}},
|
}},
|
||||||
'Docs': {
|
'Docs': {
|
||||||
img = docker.image('secop_docs:latest')
|
img = docker.image('secop_docs:latest')
|
||||||
|
Reference in New Issue
Block a user