changeset 6924:0acb46763886

jenkinsfile: combine coverage files from different DB runs
author domruf <dominikruf@gmail.com>
date Mon, 21 Aug 2017 21:42:28 +0200
parents d2f20f3d2117
children 58713c2ebfff
files .coveragerc Jenkinsfile
diffstat 2 files changed, 44 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/.coveragerc	Sun Aug 13 15:43:03 2017 +0200
+++ b/.coveragerc	Mon Aug 21 21:42:28 2017 +0200
@@ -12,3 +12,8 @@
     # 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
--- a/Jenkinsfile	Sun Aug 13 15:43:03 2017 +0200
+++ b/Jenkinsfile	Mon Aug 21 21:42:28 2017 +0200
@@ -72,23 +72,18 @@
             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 @@
                     '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 @@
                 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 @@
                 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}"
+        }
+    }
 }