@@ -13,7 +13,8 @@ pipeline {
13
13
DEPENDENCIES = " "
14
14
BACKEND_PROFILES = " eea.kitkat:testing"
15
15
BACKEND_ADDONS = " "
16
- VOLTO = " 16"
16
+ VOLTO = " 17"
17
+ VOLTO16_BREAKING_CHANGES = " no"
17
18
IMAGE_NAME = BUILD_TAG . toLowerCase()
18
19
}
19
20
@@ -44,6 +45,7 @@ pipeline {
44
45
}
45
46
steps {
46
47
script {
48
+ checkout scm
47
49
withCredentials([string(credentialsId : ' eea-jenkins-token' , variable : ' GITHUB_TOKEN' )]) {
48
50
check_result = sh script : ''' docker run --pull always -i --rm --name="$IMAGE_NAME-gitflow-check" -e GIT_TOKEN="$GITHUB_TOKEN" -e GIT_BRANCH="$BRANCH_NAME" -e GIT_ORG="$GIT_ORG" -e GIT_NAME="$GIT_NAME" eeacms/gitflow /check_if_testing_needed.sh''' , returnStatus : true
49
51
@@ -61,33 +63,34 @@ pipeline {
61
63
allOf {
62
64
not { environment name : ' CHANGE_ID' , value : ' ' }
63
65
environment name : ' CHANGE_TARGET' , value : ' develop'
64
- environment name : ' SKIP_TESTS' , value : ' '
65
66
}
66
67
allOf {
67
68
environment name : ' CHANGE_ID' , value : ' '
68
69
anyOf {
69
70
not { changelog ' .*^Automated release [0-9\\ .]+$' }
70
71
branch ' master'
71
72
}
72
- environment name : ' SKIP_TESTS' , value : ' '
73
73
}
74
74
}
75
75
}
76
- stages {
77
- stage(' Build test image' ) {
78
- steps {
79
- checkout scm
80
- sh ''' docker build --pull --build-arg="VOLTO_VERSION=$VOLTO" --build-arg="ADDON_NAME=$NAMESPACE/$GIT_NAME" --build-arg="ADDON_PATH=$GIT_NAME" . -t $IMAGE_NAME-frontend'''
76
+ parallel {
77
+
78
+ stage(' Volto 17' ) {
79
+ agent { node { label ' docker-1.13' } }
80
+ stages {
81
+ stage(' Build test image' ) {
82
+ steps {
83
+ sh ''' docker build --pull --build-arg="VOLTO_VERSION=$VOLTO" --build-arg="ADDON_NAME=$NAMESPACE/$GIT_NAME" --build-arg="ADDON_PATH=$GIT_NAME" . -t $IMAGE_NAME-frontend'''
84
+ }
81
85
}
82
- }
83
-
84
- stage(' Fix code' ) {
85
- when {
86
+
87
+ stage(' Fix code' ) {
88
+ when {
86
89
environment name : ' CHANGE_ID' , value : ' '
87
90
not { branch ' master' }
88
- }
89
- steps {
90
- script {
91
+ }
92
+ steps {
93
+ script {
91
94
fix_result = sh(script : ''' docker run --name="$IMAGE_NAME-fix" --entrypoint=make --workdir=/app/src/addons/$GIT_NAME $IMAGE_NAME-frontend ci-fix''' , returnStatus : true )
92
95
sh ''' docker cp $IMAGE_NAME-fix:/app/src/addons/$GIT_NAME/src .'''
93
96
sh ''' docker rm -v $IMAGE_NAME-fix'''
@@ -105,31 +108,31 @@ pipeline {
105
108
sh ''' exit 1'''
106
109
}
107
110
}
111
+ }
108
112
}
109
- }
110
113
111
- stage(' ES lint' ) {
112
- steps {
113
- sh ''' docker run --rm --name="$IMAGE_NAME-eslint" --entrypoint=make --workdir=/app/src/addons/$GIT_NAME $IMAGE_NAME-frontend lint'''
114
+ stage(' ES lint' ) {
115
+ when { environment name : ' SKIP_TESTS' , value : ' ' }
116
+ steps {
117
+ sh ''' docker run --rm --name="$IMAGE_NAME-eslint" --entrypoint=make --workdir=/app/src/addons/$GIT_NAME $IMAGE_NAME-frontend lint'''
118
+ }
114
119
}
115
- }
116
120
117
- stage(' Style lint' ) {
118
- steps {
119
- sh ''' docker run --rm --name="$IMAGE_NAME-stylelint" --entrypoint=make --workdir=/app/src/addons/$GIT_NAME $IMAGE_NAME-frontend stylelint'''
121
+ stage(' Style lint' ) {
122
+ when { environment name : ' SKIP_TESTS' , value : ' ' }
123
+ steps {
124
+ sh ''' docker run --rm --name="$IMAGE_NAME-stylelint" --entrypoint=make --workdir=/app/src/addons/$GIT_NAME $IMAGE_NAME-frontend stylelint'''
125
+ }
120
126
}
121
- }
122
127
123
- stage(' Prettier' ) {
124
- steps {
125
- sh ''' docker run --rm --name="$IMAGE_NAME-prettier" --entrypoint=make --workdir=/app/src/addons/$GIT_NAME $IMAGE_NAME-frontend prettier'''
128
+ stage(' Prettier' ) {
129
+ when { environment name : ' SKIP_TESTS' , value : ' ' }
130
+ steps {
131
+ sh ''' docker run --rm --name="$IMAGE_NAME-prettier" --entrypoint=make --workdir=/app/src/addons/$GIT_NAME $IMAGE_NAME-frontend prettier'''
132
+ }
126
133
}
127
- }
128
-
129
- stage(' Coverage Tests' ) {
130
- parallel {
131
-
132
- stage(' Unit tests' ) {
134
+ stage(' Unit tests' ) {
135
+ when { environment name : ' SKIP_TESTS' , value : ' ' }
133
136
steps {
134
137
script {
135
138
try {
@@ -155,17 +158,24 @@ pipeline {
155
158
}
156
159
}
157
160
}
158
- }
161
+ }
159
162
160
- stage(' Integration tests' ) {
163
+ stage(' Integration tests' ) {
164
+ when { environment name : ' SKIP_TESTS' , value : ' ' }
161
165
steps {
162
166
script {
163
167
try {
164
168
sh ''' docker run --pull always --rm -d --name="$IMAGE_NAME-plone" -e SITE="Plone" -e PROFILES="$BACKEND_PROFILES" -e ADDONS="$BACKEND_ADDONS" eeacms/plone-backend'''
165
- sh ''' docker run -d --shm-size=3g --link $IMAGE_NAME-plone:plone --name="$IMAGE_NAME-cypress" -e "RAZZLE_INTERNAL_API_PATH=http://plone:8080/Plone" --entrypoint=make --workdir=/app/src/addons/$GIT_NAME $IMAGE_NAME-frontend start-ci'''
169
+ sh ''' docker run -d --shm-size=4g --link $IMAGE_NAME-plone:plone --name="$IMAGE_NAME-cypress" -e "RAZZLE_INTERNAL_API_PATH=http://plone:8080/Plone" --entrypoint=make --workdir=/app/src/addons/$GIT_NAME $IMAGE_NAME-frontend start-ci'''
170
+ frontend = sh script :''' docker exec --workdir=/app/src/addons/${GIT_NAME} $IMAGE_NAME-cypress make check-ci''' , returnStatus : true
171
+ if ( frontend != 0 ) {
172
+ sh ''' docker logs $IMAGE_NAME-cypress; exit 1'''
173
+ }
174
+
166
175
sh ''' timeout -s 9 1800 docker exec --workdir=/app/src/addons/${GIT_NAME} $IMAGE_NAME-cypress make cypress-ci'''
167
176
} finally {
168
177
try {
178
+ if ( frontend == 0 ) {
169
179
sh ''' rm -rf cypress-videos cypress-results cypress-coverage cypress-screenshots'''
170
180
sh ''' mkdir -p cypress-videos cypress-results cypress-coverage cypress-screenshots'''
171
181
videos = sh script : ''' docker cp $IMAGE_NAME-cypress:/app/src/addons/$GIT_NAME/cypress/videos cypress-videos/''' , returnStatus : true
@@ -189,6 +199,7 @@ pipeline {
189
199
sh ''' for file in $(find cypress-results -name *.xml); do if [ $(grep -E 'failures="[1-9].*"' $file | wc -l) -eq 0 ]; then testname=$(grep -E 'file=.*failures="0"' $file | sed 's#.* file=".*\\ /\\ (.*\\ .[jsxt]\\ +\\ )" time.*#\\ 1#' ); rm -f cypress-videos/videos/$testname.mp4; fi; done'''
190
200
archiveArtifacts artifacts : ' cypress-videos/**/*.mp4' , fingerprint : true , allowEmptyArchive : true
191
201
}
202
+ }
192
203
} finally {
193
204
catchError(buildResult : ' SUCCESS' , stageResult : ' SUCCESS' ) {
194
205
junit testResults : ' cypress-results/**/*.xml' , allowEmptyResults : true
@@ -204,26 +215,19 @@ pipeline {
204
215
}
205
216
}
206
217
}
207
- }
208
218
}
209
- }
210
- }
211
- post {
212
- always {
213
- sh script : " docker rmi $IMAGE_NAME -frontend" , returnStatus : true
214
- }
215
- }
216
- }
217
219
218
220
stage(' Report to SonarQube' ) {
219
221
when {
220
222
anyOf {
221
223
allOf {
222
224
not { environment name : ' CHANGE_ID' , value : ' ' }
223
225
environment name : ' CHANGE_TARGET' , value : ' develop'
226
+ environment name : ' SKIP_TESTS' , value : ' '
224
227
}
225
228
allOf {
226
229
environment name : ' CHANGE_ID' , value : ' '
230
+ environment name : ' SKIP_TESTS' , value : ' '
227
231
anyOf {
228
232
allOf {
229
233
branch ' develop'
@@ -248,14 +252,107 @@ pipeline {
248
252
}
249
253
}
250
254
255
+
256
+ }
257
+ }
258
+
259
+ stage(' Volto 16' ) {
260
+ agent { node { label ' integration' } }
261
+ when {
262
+ environment name : ' SKIP_TESTS' , value : ' '
263
+ not { environment name : ' VOLTO16_BREAKING_CHANGES' , value : ' yes' }
264
+ }
265
+ stages {
266
+ stage(' Build test image' ) {
267
+ steps {
268
+ sh ''' docker build --pull --build-arg="VOLTO_VERSION=16" --build-arg="ADDON_NAME=$NAMESPACE/$GIT_NAME" --build-arg="ADDON_PATH=$GIT_NAME" . -t $IMAGE_NAME-frontend16'''
269
+ }
270
+ }
271
+
272
+ stage(' Unit tests Volto 16' ) {
273
+ steps {
274
+ script {
275
+ try {
276
+ sh ''' docker run --name="$IMAGE_NAME-volto16" --entrypoint=make --workdir=/app/src/addons/$GIT_NAME $IMAGE_NAME-frontend16 test-ci'''
277
+ sh ''' rm -rf xunit-reports16'''
278
+ sh ''' mkdir -p xunit-reports16'''
279
+ sh ''' docker cp $IMAGE_NAME-volto16:/app/junit.xml xunit-reports16/'''
280
+ } finally {
281
+ catchError(buildResult : ' SUCCESS' , stageResult : ' SUCCESS' ) {
282
+ junit testResults : ' xunit-reports16/junit.xml' , allowEmptyResults : true
283
+ }
284
+ sh script : ''' docker rm -v $IMAGE_NAME-volto16''' , returnStatus : true
285
+ }
286
+ }
287
+ }
288
+ }
289
+
290
+ stage(' Integration tests Volto 16' ) {
291
+ steps {
292
+ script {
293
+ try {
294
+ sh ''' docker run --pull always --rm -d --name="$IMAGE_NAME-plone16" -e SITE="Plone" -e PROFILES="$BACKEND_PROFILES" -e ADDONS="$BACKEND_ADDONS" eeacms/plone-backend'''
295
+ sh ''' docker run -d --shm-size=4g --link $IMAGE_NAME-plone16:plone --name="$IMAGE_NAME-cypress16" -e "RAZZLE_INTERNAL_API_PATH=http://plone:8080/Plone" --entrypoint=make --workdir=/app/src/addons/$GIT_NAME $IMAGE_NAME-frontend16 start-ci'''
296
+ frontend = sh script :''' docker exec --workdir=/app/src/addons/${GIT_NAME} $IMAGE_NAME-cypress16 make check-ci''' , returnStatus : true
297
+ if ( frontend != 0 ) {
298
+ sh ''' docker logs $IMAGE_NAME-cypress16; exit 1'''
299
+ }
300
+ sh ''' timeout -s 9 1800 docker exec --workdir=/app/src/addons/${GIT_NAME} $IMAGE_NAME-cypress16 make cypress-ci'''
301
+ } finally {
302
+ try {
303
+ if ( frontend == 0 ) {
304
+ sh ''' rm -rf cypress-videos16 cypress-results16 cypress-coverage16 cypress-screenshots16'''
305
+ sh ''' mkdir -p cypress-videos16 cypress-results16 cypress-coverage16 cypress-screenshots16'''
306
+ videos = sh script : ''' docker cp $IMAGE_NAME-cypress16:/app/src/addons/$GIT_NAME/cypress/videos cypress-videos16/''' , returnStatus : true
307
+ sh ''' docker cp $IMAGE_NAME-cypress16:/app/src/addons/$GIT_NAME/cypress/reports cypress-results16/'''
308
+ screenshots = sh script : ''' docker cp $IMAGE_NAME-cypress16:/app/src/addons/$GIT_NAME/cypress/screenshots cypress-screenshots16''' , returnStatus : true
309
+
310
+ archiveArtifacts artifacts : ' cypress-screenshots16/**' , fingerprint : true , allowEmptyArchive : true
311
+
312
+ if ( videos == 0 ) {
313
+ sh ''' for file in $(find cypress-results16 -name *.xml); do if [ $(grep -E 'failures="[1-9].*"' $file | wc -l) -eq 0 ]; then testname=$(grep -E 'file=.*failures="0"' $file | sed 's#.* file=".*\\ /\\ (.*\\ .[jsxt]\\ +\\ )" time.*#\\ 1#' ); rm -f cypress-videos16/videos/$testname.mp4; fi; done'''
314
+ archiveArtifacts artifacts : ' cypress-videos16/**/*.mp4' , fingerprint : true , allowEmptyArchive : true
315
+ }
316
+ }
317
+ } finally {
318
+ catchError(buildResult : ' SUCCESS' , stageResult : ' SUCCESS' ) {
319
+ junit testResults : ' cypress-results16/**/*.xml' , allowEmptyResults : true
320
+ }
321
+ catchError(buildResult : ' SUCCESS' , stageResult : ' SUCCESS' ) {
322
+ sh ''' docker logs $IMAGE_NAME-cypress16'''
323
+ }
324
+ sh script : " docker stop $IMAGE_NAME -cypress16" , returnStatus : true
325
+ sh script : " docker stop $IMAGE_NAME -plone16" , returnStatus : true
326
+ sh script : " docker rm -v $IMAGE_NAME -plone16" , returnStatus : true
327
+ sh script : " docker rm -v $IMAGE_NAME -cypress16" , returnStatus : true
328
+ }
329
+ }
330
+ }
331
+ }
332
+ }
333
+
334
+ }
335
+ }
336
+ }
337
+ post {
338
+ always {
339
+ sh script : " docker rmi $IMAGE_NAME -frontend" , returnStatus : true
340
+ sh script : " docker rmi $IMAGE_NAME -frontend16" , returnStatus : true
341
+ }
342
+ }
343
+ }
344
+
345
+
251
346
stage(' SonarQube compare to master' ) {
252
347
when {
253
348
anyOf {
254
349
allOf {
255
350
not { environment name : ' CHANGE_ID' , value : ' ' }
256
351
environment name : ' CHANGE_TARGET' , value : ' develop'
352
+ environment name : ' SKIP_TESTS' , value : ' '
257
353
}
258
354
allOf {
355
+ environment name : ' SKIP_TESTS' , value : ' '
259
356
environment name : ' CHANGE_ID' , value : ' '
260
357
branch ' develop'
261
358
not { changelog ' .*^Automated release [0-9\\ .]+$' }
@@ -316,3 +413,4 @@ pipeline {
316
413
}
317
414
}
318
415
}
416
+
0 commit comments