@@ -67,6 +67,43 @@ pipeline {
6767 }
6868 }
6969
70+ stage(' Test' ) {
71+ environment {
72+ VIRTUAL_ENV = " ${ WORKSPACE} /.venv"
73+ PATH = " ${ VIRTUAL_ENV} /bin:${ PATH} "
74+ }
75+ steps {
76+ script {
77+ // run pytest
78+ sh ' VCR_RECORD_MODE=none pytest --maxfail=1 --cov=sketch_map_tool --cov-report=xml tests'
79+ // run static analysis with sonar-scanner
80+ def scannerHome = tool ' SonarScanner 4'
81+ withSonarQubeEnv(' sonarcloud GIScience/ohsome' ) {
82+ SONAR_CLI_PARAMETER =
83+ " -Dsonar.python.coverage.reportPaths=${ WORKSPACE} /coverage.xml " +
84+ " -Dsonar.projectVersion=${ VERSION} "
85+ if (env. CHANGE_ID ) {
86+ SONAR_CLI_PARAMETER + = ' ' +
87+ " -Dsonar.pullrequest.key=${ env.CHANGE_ID} " +
88+ " -Dsonar.pullrequest.branch=${ env.CHANGE_BRANCH} " +
89+ " -Dsonar.pullrequest.base=${ env.CHANGE_TARGET} "
90+ } else {
91+ SONAR_CLI_PARAMETER + = ' ' +
92+ " -Dsonar.branch.name=${ env.BRANCH_NAME} "
93+ }
94+ sh " ${ scannerHome} /bin/sonar-scanner " + SONAR_CLI_PARAMETER
95+ }
96+ // run other static code analysis and checks
97+ sh ' pre-commit run --all-files'
98+ }
99+ }
100+ post {
101+ failure {
102+ rocket_testfail()
103+ }
104+ }
105+ }
106+
70107 stage(' Build and publish Docker image for main' ) {
71108 agent {
72109 kubernetes {
@@ -106,42 +143,6 @@ pipeline {
106143 }
107144 }
108145
109- stage(' Test' ) {
110- environment {
111- VIRTUAL_ENV = " ${ WORKSPACE} /.venv"
112- PATH = " ${ VIRTUAL_ENV} /bin:${ PATH} "
113- }
114- steps {
115- script {
116- // run pytest
117- sh ' VCR_RECORD_MODE=none pytest --maxfail=1 --cov=sketch_map_tool --cov-report=xml tests'
118- // run static analysis with sonar-scanner
119- def scannerHome = tool ' SonarScanner 4'
120- withSonarQubeEnv(' sonarcloud GIScience/ohsome' ) {
121- SONAR_CLI_PARAMETER =
122- " -Dsonar.python.coverage.reportPaths=${ WORKSPACE} /coverage.xml " +
123- " -Dsonar.projectVersion=${ VERSION} "
124- if (env. CHANGE_ID ) {
125- SONAR_CLI_PARAMETER + = ' ' +
126- " -Dsonar.pullrequest.key=${ env.CHANGE_ID} " +
127- " -Dsonar.pullrequest.branch=${ env.CHANGE_BRANCH} " +
128- " -Dsonar.pullrequest.base=${ env.CHANGE_TARGET} "
129- } else {
130- SONAR_CLI_PARAMETER + = ' ' +
131- " -Dsonar.branch.name=${ env.BRANCH_NAME} "
132- }
133- sh " ${ scannerHome} /bin/sonar-scanner " + SONAR_CLI_PARAMETER
134- }
135- // run other static code analysis and checks
136- sh ' pre-commit run --all-files'
137- }
138- }
139- post {
140- failure {
141- rocket_testfail()
142- }
143- }
144- }
145146
146147 stage(' Wrapping Up' ) {
147148 steps {
0 commit comments