##// END OF EJS Templates
tests: add Jenkinsfile for automatic creation of Jenkins projects for testing Kallithea itself...
domruf -
r6496:8d788789 default
parent child Browse files
Show More
@@ -0,0 +1,165 b''
1 node {
2 def activatevirtualenv = ''
3 if (isUnix()) {
4 activatevirtualenv = '. venv/bin/activate'
5 } else {
6 activatevirtualenv = 'call venv\\Scripts\\activate.bat'
7 }
8
9 stage('checkout') {
10 checkout scm
11 if (isUnix()) {
12 sh 'hg --config extensions.purge= purge --all'
13 } else {
14 bat 'hg --config extensions.purge= purge --all'
15 }
16 }
17 stage('virtual env') {
18 def virtualenvscript = """virtualenv venv
19 $activatevirtualenv
20 python -m pip install --upgrade pip
21 pip install --upgrade setuptools
22 pip install --upgrade pylint
23 pip install --upgrade pytest-cov
24 """
25 if (isUnix()) {
26 virtualenvscript += """
27 pip install --upgrade python-ldap
28 pip install --upgrade python-pam
29 """
30 sh virtualenvscript
31 } else {
32 bat virtualenvscript
33 }
34 }
35 stage('setup') {
36 def virtualenvscript = """$activatevirtualenv
37 pip install --upgrade -e .
38 pip install -r dev_requirements.txt
39 python setup.py compile_catalog
40 """
41 if (isUnix()) {
42 sh virtualenvscript
43 } else {
44 bat virtualenvscript
45 }
46 stash name: 'kallithea', useDefaultExcludes: false
47 }
48 stage('pylint') {
49 sh script: """$activatevirtualenv
50 pylint -j 0 --disable=C -f parseable kallithea > pylint.out
51 """, returnStatus: true
52 archiveArtifacts 'pylint.out'
53 try {
54 step([$class: 'WarningsPublisher', canComputeNew: false, canResolveRelativePaths: false, defaultEncoding: '', excludePattern: '', healthy: '', includePattern: '', messagesPattern: '', parserConfigurations: [[parserName: 'PyLint', pattern: 'pylint.out']], unHealthy: ''])
55 } catch (UnsupportedOperationException exc) {
56 echo "You need to install the 'Warnings Plug-in' to display the pylint report."
57 currentBuild.result = 'UNSTABLE'
58 echo "Caught: ${exc}"
59 }
60 }
61 def pytests = [:]
62 pytests['sqlite'] = {
63 ws {
64 unstash name: 'kallithea'
65 sh 'hg revert kallithea/tests/test.ini'
66 if (isUnix()) {
67 sh script: """$activatevirtualenv
68 hg revert kallithea/tests/test.ini
69 py.test -p no:sugar --cov-config .coveragerc --junit-xml=pytest_sqlite.xml --cov=kallithea --cov-report xml
70 """, returnStatus: true
71 } else {
72 bat script: """$activatevirtualenv
73 py.test -p no:sugar --cov-config .coveragerc --junit-xml=pytest_sqlite.xml --cov=kallithea --cov-report xml
74 """, returnStatus: true
75 }
76 sh 'sed --in-place "s/\\(classname=[\'\\"]\\)/\\1SQLITE./g" pytest_sqlite.xml'
77 archiveArtifacts 'pytest_sqlite.xml'
78 junit 'pytest_sqlite.xml'
79 try {
80 step([$class: 'CoberturaPublisher', autoUpdateHealth: false, autoUpdateStability: false, coberturaReportFile: 'coverage.xml', failNoReports: false, failUnhealthy: false, failUnstable: false, maxNumberOfBuilds: 0, onlyStable: false, zoomCoverageChart: false])
81 } catch (UnsupportedOperationException exc) {
82 echo "You need to install the pipeline compatible 'CoberturaPublisher Plug-in' to display the coverage report."
83 currentBuild.result = 'UNSTABLE'
84 echo "Caught: ${exc}"
85 }
86 }
87 }
88 if (isUnix()) {
89 pytests['de'] = {
90 ws {
91 unstash name: 'kallithea'
92 sh 'hg revert kallithea/tests/test.ini'
93 withEnv(['LANG=de_DE.UTF-8',
94 'LANGUAGE=de',
95 'LC_ADDRESS=de_DE.UTF-8',
96 'LC_IDENTIFICATION=de_DE.UTF-8',
97 'LC_MEASUREMENT=de_DE.UTF-8',
98 'LC_MONETARY=de_DE.UTF-8',
99 'LC_NAME=de_DE.UTF-8',
100 'LC_NUMERIC=de_DE.UTF-8',
101 'LC_PAPER=de_DE.UTF-8',
102 'LC_TELEPHONE=de_DE.UTF-8',
103 'LC_TIME=de_DE.UTF-8',
104 ]) {
105 sh script: """$activatevirtualenv
106 py.test -p no:sugar --cov-config .coveragerc --junit-xml=pytest_de.xml --cov=kallithea --cov-report xml
107 """, returnStatus: true
108 }
109 sh 'sed --in-place "s/\\(classname=[\'\\"]\\)/\\1DE./g" pytest_de.xml'
110 archiveArtifacts 'pytest_de.xml'
111 junit 'pytest_de.xml'
112 }
113 }
114 pytests['mysql'] = {
115 ws {
116 unstash name: 'kallithea'
117 sh 'hg revert kallithea/tests/test.ini'
118 sh """$activatevirtualenv
119 pip install --upgrade MySQL-python
120 """
121 withEnv(['TEST_DB=mysql://kallithea:kallithea@jenkins_mysql/kallithea_test?charset=utf8']) {
122 if (isUnix()) {
123 sh script: """$activatevirtualenv
124 py.test -p no:sugar --cov-config .coveragerc --junit-xml=pytest_mysql.xml --cov=kallithea --cov-report xml
125 """, returnStatus: true
126 } else {
127 bat script: """$activatevirtualenv
128 py.test -p no:sugar --cov-config .coveragerc --junit-xml=pytest_mysql.xml --cov=kallithea --cov-report xml
129 """, returnStatus: true
130 }
131 }
132 sh 'sed --in-place "s/\\(classname=[\'\\"]\\)/\\1MYSQL./g" pytest_mysql.xml'
133 archiveArtifacts 'pytest_mysql.xml'
134 junit 'pytest_mysql.xml'
135 }
136 }
137 pytests['postgresql'] = {
138 ws {
139 unstash name: 'kallithea'
140 sh 'hg revert kallithea/tests/test.ini'
141 sh 'sed -i.bak s/^sqlalchemy\\.url.*$/sqlalchemy.url=postgresql:\\\\/\\\\/kallithea:kallithea@jenkins_postgresql\\\\/kallithea_test/g kallithea/tests/test.ini'
142 sh """$activatevirtualenv
143 pip install --upgrade psycopg2
144 """
145 withEnv(['TEST_DB=postgresql://kallithea:kallithea@jenkins_postgresql/kallithea_test']) {
146 if (isUnix()) {
147 sh script: """$activatevirtualenv
148 py.test -p no:sugar --cov-config .coveragerc --junit-xml=pytest_postgresql.xml --cov=kallithea --cov-report xml
149 """, returnStatus: true
150 } else {
151 bat script: """$activatevirtualenv
152 py.test -p no:sugar --cov-config .coveragerc --junit-xml=pytest_postgresql.xml --cov=kallithea --cov-report xml
153 """, returnStatus: true
154 }
155 }
156 sh 'sed --in-place "s/\\(classname=[\'\\"]\\)/\\1POSTGRES./g" pytest_postgresql.xml'
157 archiveArtifacts 'pytest_postgresql.xml'
158 junit 'pytest_postgresql.xml'
159 }
160 }
161 }
162 stage('Tests') {
163 parallel pytests
164 }
165 }
General Comments 0
You need to be logged in to leave comments. Login now