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
101
ci/Jenkinsfile
vendored
101
ci/Jenkinsfile
vendored
@ -25,10 +25,75 @@ change-merged''',
|
|||||||
|
|
||||||
|
|
||||||
this.verifyresult = [:]
|
this.verifyresult = [:]
|
||||||
|
def changedFiles = '';
|
||||||
|
|
||||||
def run_tests(pyver)
|
|
||||||
{
|
def run_pylint(pyver) {
|
||||||
writeFile file: 'setup.cfg', text: '''
|
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]
|
[tool:pytest]
|
||||||
addopts = --junit-xml=pytest.xml --junit-prefix=''' + pyver
|
addopts = --junit-xml=pytest.xml --junit-prefix=''' + pyver
|
||||||
|
|
||||||
@ -36,7 +101,7 @@ addopts = --junit-xml=pytest.xml --junit-prefix=''' + pyver
|
|||||||
verifyresult.put(pyver, 0)
|
verifyresult.put(pyver, 0)
|
||||||
try {
|
try {
|
||||||
timeout(5) {
|
timeout(5) {
|
||||||
sh '''\
|
sh '''\
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
. /home/jenkins/secopvenv/bin/activate
|
. /home/jenkins/secopvenv/bin/activate
|
||||||
pip install -r requirements-dev.txt
|
pip install -r requirements-dev.txt
|
||||||
@ -44,25 +109,26 @@ pip install -r requirements.txt
|
|||||||
python setup.py develop
|
python setup.py develop
|
||||||
make test
|
make test
|
||||||
'''
|
'''
|
||||||
verifyresult.put(pyver, 1)
|
verifyresult.put(pyver, 1)
|
||||||
}
|
}
|
||||||
} catch (all) {
|
} catch (all) {
|
||||||
currentBuild.result = 'FAILURE'
|
currentBuild.result = 'FAILURE'
|
||||||
status = 'FAILURE'
|
status = 'FAILURE'
|
||||||
verifyresult.put(pyver, -1)
|
verifyresult.put(pyver, -1)
|
||||||
}
|
}
|
||||||
gerritverificationpublisher([
|
gerritverificationpublisher([
|
||||||
verifyStatusValue: verifyresult[pyver],
|
verifyStatusValue: verifyresult[pyver],
|
||||||
verifyStatusCategory: 'test ',
|
verifyStatusCategory: 'test ',
|
||||||
verifyStatusName: 'pytest-'+pyver,
|
verifyStatusName: 'pytest-'+pyver,
|
||||||
verifyStatusReporter: 'jenkins',
|
verifyStatusReporter: 'jenkins',
|
||||||
verifyStatusRerun: '!recheck'])
|
verifyStatusRerun: '!recheck'])
|
||||||
|
|
||||||
step([$class: 'JUnitResultArchiver', allowEmptyResults: true,
|
step([$class: 'JUnitResultArchiver', allowEmptyResults: true,
|
||||||
keepLongStdio: true, testResults: 'pytest.xml'])
|
keepLongStdio: true, testResults: 'pytest.xml'])
|
||||||
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([
|
||||||
@ -169,7 +241,12 @@ node("master") {
|
|||||||
img.inside {
|
img.inside {
|
||||||
run_tests('python2')
|
run_tests('python2')
|
||||||
}},
|
}},
|
||||||
'Docs': {
|
'Pylint': {
|
||||||
|
img = docker.image('secop_base:latest')
|
||||||
|
img.inside {
|
||||||
|
run_pylint('python2')
|
||||||
|
}},
|
||||||
|
'Docs': {
|
||||||
img = docker.image('secop_docs:latest')
|
img = docker.image('secop_docs:latest')
|
||||||
img.inside {
|
img.inside {
|
||||||
run_docs()
|
run_docs()
|
||||||
|
Reference in New Issue
Block a user