##// END OF EJS Templates
jenkinsfile: combine coverage files from different DB runs
domruf -
r6849:0acb4676 default
parent child Browse files
Show More
@@ -1,14 +1,19 b''
1 1 [run]
2 2 omit =
3 3 # the bin scripts are not part of the Kallithea web app
4 4 kallithea/bin/*
5 5 # we ship with no active extensions
6 6 kallithea/config/rcextensions/*
7 7 # dbmigrate and paster_commands are not part of the Kallithea web app
8 8 kallithea/lib/dbmigrate/*
9 9 kallithea/lib/paster_commands/*
10 10 # the tests themselves should not be part of the coverage report
11 11 kallithea/tests/*
12 12 # the scm hooks are not run in the kallithea process
13 13 kallithea/config/post_receive_tmpl.py
14 14 kallithea/config/pre_receive_tmpl.py
15
16 [paths]
17 source =
18 kallithea/
19 **/workspace/*/kallithea
@@ -1,181 +1,206 b''
1 1 def createvirtualenv = ''
2 2 def activatevirtualenv = ''
3 3
4 4 node {
5 5 if (isUnix()) {
6 6 createvirtualenv = 'rm -r $JENKINS_HOME/venv/$JOB_NAME || true && virtualenv $JENKINS_HOME/venv/$JOB_NAME'
7 7 activatevirtualenv = '. $JENKINS_HOME/venv/$JOB_NAME/bin/activate'
8 8 } else {
9 9 createvirtualenv = 'rmdir /s /q %JENKINS_HOME%\\venv\\%JOB_NAME% || true && virtualenv %JENKINS_HOME%\\venv\\%JOB_NAME%'
10 10 activatevirtualenv = 'call %JENKINS_HOME%\\venv\\%JOB_NAME%\\Scripts\\activate.bat'
11 11 }
12 12
13 13 stage('checkout') {
14 14 checkout scm
15 15 if (isUnix()) {
16 16 sh 'hg --config extensions.purge= purge --all'
17 17 } else {
18 18 bat 'hg --config extensions.purge= purge --all'
19 19 }
20 20 }
21 21 stage('virtual env') {
22 22 def virtualenvscript = """$createvirtualenv
23 23 $activatevirtualenv
24 24 python -m pip install --upgrade pip
25 25 pip install --upgrade setuptools
26 26 pip install --upgrade pylint
27 27 pip install --upgrade pytest-cov
28 28 """
29 29 if (isUnix()) {
30 30 virtualenvscript += """
31 31 pip install --upgrade python-ldap
32 32 pip install --upgrade python-pam
33 33 """
34 34 sh virtualenvscript
35 35 } else {
36 36 bat virtualenvscript
37 37 }
38 38 }
39 39 stage('setup') {
40 40 def virtualenvscript = """$activatevirtualenv
41 41 pip install --upgrade -e .
42 42 pip install -r dev_requirements.txt
43 43 python setup.py compile_catalog
44 44 """
45 45 if (isUnix()) {
46 46 sh virtualenvscript
47 47 } else {
48 48 bat virtualenvscript
49 49 }
50 50 stash name: 'kallithea', useDefaultExcludes: false
51 51 }
52 52 stage('pylint') {
53 53 sh script: """$activatevirtualenv
54 54 pylint -j 0 --disable=C -f parseable kallithea > pylint.out
55 55 """, returnStatus: true
56 56 archiveArtifacts 'pylint.out'
57 57 try {
58 58 step([$class: 'WarningsPublisher', canComputeNew: false, canResolveRelativePaths: false, defaultEncoding: '', excludePattern: '', healthy: '', includePattern: '', messagesPattern: '', parserConfigurations: [[parserName: 'PyLint', pattern: 'pylint.out']], unHealthy: ''])
59 59 } catch (java.lang.IllegalArgumentException exc) {
60 60 echo "You need to install the 'Warnings Plug-in' to display the pylint report."
61 61 currentBuild.result = 'UNSTABLE'
62 62 echo "Caught: ${exc}"
63 63 }
64 64 }
65 65 }
66 66
67 67 def pytests = [:]
68 68 pytests['sqlite'] = {
69 69 node {
70 70 ws {
71 71 deleteDir()
72 72 unstash name: 'kallithea'
73 73 if (isUnix()) {
74 74 sh script: """$activatevirtualenv
75 py.test -p no:sugar --cov-config .coveragerc --junit-xml=pytest_sqlite.xml --cov=kallithea --cov-report xml
75 py.test -p no:sugar --cov-config .coveragerc --junit-xml=pytest_sqlite.xml --cov=kallithea
76 76 """, returnStatus: true
77 77 } else {
78 78 bat script: """$activatevirtualenv
79 py.test -p no:sugar --cov-config .coveragerc --junit-xml=pytest_sqlite.xml --cov=kallithea --cov-report xml
79 py.test -p no:sugar --cov-config .coveragerc --junit-xml=pytest_sqlite.xml --cov=kallithea
80 80 """, returnStatus: true
81 81 }
82 82 sh 'sed --in-place "s/\\(classname=[\'\\"]\\)/\\1SQLITE./g" pytest_sqlite.xml'
83 83 archiveArtifacts 'pytest_sqlite.xml'
84 84 junit 'pytest_sqlite.xml'
85 try {
86 step([$class: 'CoberturaPublisher', autoUpdateHealth: false, autoUpdateStability: false, coberturaReportFile: 'coverage.xml', failNoReports: false, failUnhealthy: false, failUnstable: false, maxNumberOfBuilds: 0, onlyStable: false, zoomCoverageChart: false])
87 } catch (java.lang.IllegalArgumentException exc) {
88 echo "You need to install the pipeline compatible 'CoberturaPublisher Plug-in' to display the coverage report."
89 currentBuild.result = 'UNSTABLE'
90 echo "Caught: ${exc}"
91 }
85 writeFile(file: '.coverage.sqlite', text: readFile('.coverage'))
86 stash name: 'coverage.sqlite', includes: '.coverage.sqlite'
92 87 }
93 88 }
94 89 }
95 90
96 91 pytests['de'] = {
97 92 node {
98 93 if (isUnix()) {
99 94 ws {
100 95 deleteDir()
101 96 unstash name: 'kallithea'
102 97 withEnv(['LANG=de_DE.UTF-8',
103 98 'LANGUAGE=de',
104 99 'LC_ADDRESS=de_DE.UTF-8',
105 100 'LC_IDENTIFICATION=de_DE.UTF-8',
106 101 'LC_MEASUREMENT=de_DE.UTF-8',
107 102 'LC_MONETARY=de_DE.UTF-8',
108 103 'LC_NAME=de_DE.UTF-8',
109 104 'LC_NUMERIC=de_DE.UTF-8',
110 105 'LC_PAPER=de_DE.UTF-8',
111 106 'LC_TELEPHONE=de_DE.UTF-8',
112 107 'LC_TIME=de_DE.UTF-8',
113 108 ]) {
114 109 sh script: """$activatevirtualenv
115 py.test -p no:sugar --cov-config .coveragerc --junit-xml=pytest_de.xml --cov=kallithea --cov-report xml
110 py.test -p no:sugar --cov-config .coveragerc --junit-xml=pytest_de.xml --cov=kallithea
116 111 """, returnStatus: true
117 112 }
118 113 sh 'sed --in-place "s/\\(classname=[\'\\"]\\)/\\1DE./g" pytest_de.xml'
119 114 archiveArtifacts 'pytest_de.xml'
120 115 junit 'pytest_de.xml'
116 writeFile(file: '.coverage.de', text: readFile('.coverage'))
117 stash name: 'coverage.de', includes: '.coverage.de'
121 118 }
122 119 }
123 120 }
124 121 }
125 122 pytests['mysql'] = {
126 123 node {
127 124 if (isUnix()) {
128 125 ws {
129 126 deleteDir()
130 127 unstash name: 'kallithea'
131 128 sh """$activatevirtualenv
132 129 pip install --upgrade MySQL-python
133 130 """
134 131 withEnv(['TEST_DB=mysql://kallithea:kallithea@jenkins_mysql/kallithea_test?charset=utf8']) {
135 132 if (isUnix()) {
136 133 sh script: """$activatevirtualenv
137 py.test -p no:sugar --cov-config .coveragerc --junit-xml=pytest_mysql.xml --cov=kallithea --cov-report xml
134 py.test -p no:sugar --cov-config .coveragerc --junit-xml=pytest_mysql.xml --cov=kallithea
138 135 """, returnStatus: true
139 136 } else {
140 137 bat script: """$activatevirtualenv
141 py.test -p no:sugar --cov-config .coveragerc --junit-xml=pytest_mysql.xml --cov=kallithea --cov-report xml
138 py.test -p no:sugar --cov-config .coveragerc --junit-xml=pytest_mysql.xml --cov=kallithea
142 139 """, returnStatus: true
143 140 }
144 141 }
145 142 sh 'sed --in-place "s/\\(classname=[\'\\"]\\)/\\1MYSQL./g" pytest_mysql.xml'
146 143 archiveArtifacts 'pytest_mysql.xml'
147 144 junit 'pytest_mysql.xml'
145 writeFile(file: '.coverage.mysql', text: readFile('.coverage'))
146 stash name: 'coverage.mysql', includes: '.coverage.mysql'
148 147 }
149 148 }
150 149 }
151 150 }
152 151 pytests['postgresql'] = {
153 152 node {
154 153 if (isUnix()) {
155 154 ws {
156 155 deleteDir()
157 156 unstash name: 'kallithea'
158 157 sh """$activatevirtualenv
159 158 pip install --upgrade psycopg2
160 159 """
161 160 withEnv(['TEST_DB=postgresql://kallithea:kallithea@jenkins_postgresql/kallithea_test']) {
162 161 if (isUnix()) {
163 162 sh script: """$activatevirtualenv
164 py.test -p no:sugar --cov-config .coveragerc --junit-xml=pytest_postgresql.xml --cov=kallithea --cov-report xml
163 py.test -p no:sugar --cov-config .coveragerc --junit-xml=pytest_postgresql.xml --cov=kallithea
165 164 """, returnStatus: true
166 165 } else {
167 166 bat script: """$activatevirtualenv
168 py.test -p no:sugar --cov-config .coveragerc --junit-xml=pytest_postgresql.xml --cov=kallithea --cov-report xml
167 py.test -p no:sugar --cov-config .coveragerc --junit-xml=pytest_postgresql.xml --cov=kallithea
169 168 """, returnStatus: true
170 169 }
171 170 }
172 171 sh 'sed --in-place "s/\\(classname=[\'\\"]\\)/\\1POSTGRES./g" pytest_postgresql.xml'
173 172 archiveArtifacts 'pytest_postgresql.xml'
174 173 junit 'pytest_postgresql.xml'
174 writeFile(file: '.coverage.postgresql', text: readFile('.coverage'))
175 stash name: 'coverage.postgresql', includes: '.coverage.postgresql'
175 176 }
176 177 }
177 178 }
178 179 }
179 180 stage('Tests') {
180 181 parallel pytests
182 node {
183 unstash 'coverage.sqlite'
184 unstash 'coverage.de'
185 unstash 'coverage.mysql'
186 unstash 'coverage.postgresql'
187 if (isUnix()) {
188 sh script: """$activatevirtualenv
189 coverage combine .coverage.sqlite .coverage.de .coverage.mysql .coverage.postgresql
190 coverage xml
191 """, returnStatus: true
192 } else {
193 bat script: """$activatevirtualenv
194 coverage combine .coverage.sqlite .coverage.de .coverage.mysql .coverage.postgresql
195 coverage xml
196 """, returnStatus: true
181 197 }
198 try {
199 step([$class: 'CoberturaPublisher', autoUpdateHealth: false, autoUpdateStability: false, coberturaReportFile: 'coverage.xml', failNoReports: false, failUnhealthy: false, failUnstable: false, maxNumberOfBuilds: 0, onlyStable: false, zoomCoverageChart: false])
200 } catch (java.lang.IllegalArgumentException exc) {
201 echo "You need to install the pipeline compatible 'CoberturaPublisher Plug-in' to display the coverage report."
202 currentBuild.result = 'UNSTABLE'
203 echo "Caught: ${exc}"
204 }
205 }
206 }
General Comments 0
You need to be logged in to leave comments. Login now