Changeset - 0acb46763886
[Not reviewed]
default
0 2 0
domruf - 9 years ago 2017-08-21 21:42:28
dominikruf@gmail.com
jenkinsfile: combine coverage files from different DB runs
2 files changed with 44 insertions and 14 deletions:
0 comments (0 inline, 0 general)
.coveragerc
Show inline comments
 
@@ -12,3 +12,8 @@ omit =
 
    # the scm hooks are not run in the kallithea process
 
    kallithea/config/post_receive_tmpl.py
 
    kallithea/config/pre_receive_tmpl.py
 

	
 
[paths]
 
source =
 
    kallithea/
 
    **/workspace/*/kallithea
Jenkinsfile
Show inline comments
 
@@ -72,23 +72,18 @@ pytests['sqlite'] = {
 
            unstash name: 'kallithea'
 
            if (isUnix()) {
 
                sh script: """$activatevirtualenv
 
                    py.test -p no:sugar --cov-config .coveragerc --junit-xml=pytest_sqlite.xml --cov=kallithea --cov-report xml
 
                    py.test -p no:sugar --cov-config .coveragerc --junit-xml=pytest_sqlite.xml --cov=kallithea
 
                    """, returnStatus: true
 
            } else {
 
                bat script: """$activatevirtualenv
 
                    py.test -p no:sugar --cov-config .coveragerc --junit-xml=pytest_sqlite.xml --cov=kallithea --cov-report xml
 
                    py.test -p no:sugar --cov-config .coveragerc --junit-xml=pytest_sqlite.xml --cov=kallithea
 
                    """, returnStatus: true
 
            }
 
            sh 'sed --in-place "s/\\(classname=[\'\\"]\\)/\\1SQLITE./g" pytest_sqlite.xml'
 
            archiveArtifacts 'pytest_sqlite.xml'
 
            junit 'pytest_sqlite.xml'
 
            try {
 
                step([$class: 'CoberturaPublisher', autoUpdateHealth: false, autoUpdateStability: false, coberturaReportFile: 'coverage.xml', failNoReports: false, failUnhealthy: false, failUnstable: false, maxNumberOfBuilds: 0, onlyStable: false, zoomCoverageChart: false])
 
            } catch (java.lang.IllegalArgumentException exc) {
 
                echo "You need to install the pipeline compatible 'CoberturaPublisher Plug-in' to display the coverage report."
 
                currentBuild.result = 'UNSTABLE'
 
                echo "Caught: ${exc}"
 
            }
 
            writeFile(file: '.coverage.sqlite', text: readFile('.coverage'))
 
            stash name: 'coverage.sqlite', includes: '.coverage.sqlite'
 
        }
 
    }
 
}
 
@@ -112,12 +107,14 @@ pytests['de'] = {
 
                    'LC_TIME=de_DE.UTF-8',
 
                ]) {
 
                    sh script: """$activatevirtualenv
 
                        py.test -p no:sugar --cov-config .coveragerc --junit-xml=pytest_de.xml --cov=kallithea --cov-report xml
 
                        py.test -p no:sugar --cov-config .coveragerc --junit-xml=pytest_de.xml --cov=kallithea
 
                        """, returnStatus: true
 
                }
 
                sh 'sed --in-place "s/\\(classname=[\'\\"]\\)/\\1DE./g" pytest_de.xml'
 
                archiveArtifacts 'pytest_de.xml'
 
                junit 'pytest_de.xml'
 
                writeFile(file: '.coverage.de', text: readFile('.coverage'))
 
                stash name: 'coverage.de', includes: '.coverage.de'
 
            }
 
        }
 
    }
 
@@ -134,17 +131,19 @@ pytests['mysql'] = {
 
                withEnv(['TEST_DB=mysql://kallithea:kallithea@jenkins_mysql/kallithea_test?charset=utf8']) {
 
                    if (isUnix()) {
 
                        sh script: """$activatevirtualenv
 
                            py.test -p no:sugar --cov-config .coveragerc --junit-xml=pytest_mysql.xml --cov=kallithea --cov-report xml
 
                            py.test -p no:sugar --cov-config .coveragerc --junit-xml=pytest_mysql.xml --cov=kallithea
 
                            """, returnStatus: true
 
                    } else {
 
                        bat script: """$activatevirtualenv
 
                            py.test -p no:sugar --cov-config .coveragerc --junit-xml=pytest_mysql.xml --cov=kallithea --cov-report xml
 
                            py.test -p no:sugar --cov-config .coveragerc --junit-xml=pytest_mysql.xml --cov=kallithea
 
                            """, returnStatus: true
 
                    }
 
                }
 
                sh 'sed --in-place "s/\\(classname=[\'\\"]\\)/\\1MYSQL./g" pytest_mysql.xml'
 
                archiveArtifacts 'pytest_mysql.xml'
 
                junit 'pytest_mysql.xml'
 
                writeFile(file: '.coverage.mysql', text: readFile('.coverage'))
 
                stash name: 'coverage.mysql', includes: '.coverage.mysql'
 
            }
 
        }
 
    }
 
@@ -161,21 +160,47 @@ pytests['postgresql'] = {
 
                withEnv(['TEST_DB=postgresql://kallithea:kallithea@jenkins_postgresql/kallithea_test']) {
 
                    if (isUnix()) {
 
                        sh script: """$activatevirtualenv
 
                            py.test -p no:sugar --cov-config .coveragerc --junit-xml=pytest_postgresql.xml --cov=kallithea --cov-report xml
 
                            py.test -p no:sugar --cov-config .coveragerc --junit-xml=pytest_postgresql.xml --cov=kallithea
 
                            """, returnStatus: true
 
                    } else {
 
                        bat script: """$activatevirtualenv
 
                            py.test -p no:sugar --cov-config .coveragerc --junit-xml=pytest_postgresql.xml --cov=kallithea --cov-report xml
 
                            py.test -p no:sugar --cov-config .coveragerc --junit-xml=pytest_postgresql.xml --cov=kallithea
 
                            """, returnStatus: true
 
                    }
 
                }
 
                sh 'sed --in-place "s/\\(classname=[\'\\"]\\)/\\1POSTGRES./g" pytest_postgresql.xml'
 
                archiveArtifacts 'pytest_postgresql.xml'
 
                junit 'pytest_postgresql.xml'
 
                writeFile(file: '.coverage.postgresql', text: readFile('.coverage'))
 
                stash name: 'coverage.postgresql', includes: '.coverage.postgresql'
 
            }
 
        }
 
    }
 
}
 
stage('Tests') {
 
    parallel pytests
 
    node {
 
        unstash 'coverage.sqlite'
 
        unstash 'coverage.de'
 
        unstash 'coverage.mysql'
 
        unstash 'coverage.postgresql'
 
        if (isUnix()) {
 
            sh script: """$activatevirtualenv
 
                coverage combine .coverage.sqlite .coverage.de .coverage.mysql .coverage.postgresql
 
                coverage xml
 
                """, returnStatus: true
 
        } else {
 
            bat script: """$activatevirtualenv
 
                coverage combine .coverage.sqlite .coverage.de .coverage.mysql .coverage.postgresql
 
                coverage xml
 
                """, returnStatus: true
 
        }
 
        try {
 
            step([$class: 'CoberturaPublisher', autoUpdateHealth: false, autoUpdateStability: false, coberturaReportFile: 'coverage.xml', failNoReports: false, failUnhealthy: false, failUnstable: false, maxNumberOfBuilds: 0, onlyStable: false, zoomCoverageChart: false])
 
        } catch (java.lang.IllegalArgumentException exc) {
 
            echo "You need to install the pipeline compatible 'CoberturaPublisher Plug-in' to display the coverage report."
 
            currentBuild.result = 'UNSTABLE'
 
            echo "Caught: ${exc}"
 
        }
 
    }
 
}
0 comments (0 inline, 0 general)