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