-
Notifications
You must be signed in to change notification settings - Fork 147
/
.gitlab-ci.yml
379 lines (350 loc) · 10.6 KB
/
.gitlab-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
# vim: syntax=sshconfig textwidth=120 expandtab tabstop=2 softtabstop=2 shiftwidth=2 autoindent
stages:
- prepare
- linters
- test
- test-e2e
- build
- swagger
- deploy
.cache-tpl: &cache-tpl
key: "$CI_COMMIT_REF_SLUG"
paths:
- node_modules
- frontend/components
policy: pull
.test-template: &test-template
image: node:10-stretch
stage: test
tags:
- docker
cache:
<<: *cache-tpl
variables:
TZ: "America/New_York"
before_script:
- npm install -g grunt-cli
- npm install
- 'echo "INFO: NB node packages : $(ls node_modules | wc -l)"'
- 'echo "INFO: NB bower packages : $(ls frontend/components | wc -l)"'
except:
variables:
- $SKIP_TESTS
refs:
- tags@linagora/lgs/openpaas/esn
prepare:
image: node:10-stretch
stage: prepare
tags:
- docker
cache:
<<: *cache-tpl
policy: pull-push
script:
- npm install
# Weird behaviour: at the time, npm postinstall was not called.
- ./node_modules/.bin/bower install --allow-root
- 'echo "INFO: NB node packages : $(ls node_modules | wc -l)"'
- 'echo "INFO: NB bower packages : $(ls frontend/components | wc -l)"'
except:
variables:
- $SKIP_PREPARE
linters:
<<: *test-template
stage: linters
script:
- grunt -v linters
except:
variables:
- $SKIP_LINTERS
refs:
- tags@linagora/lgs/openpaas/esn
check_author:
image: docker-registry.linagora.com:5000/lgs-releases/gitlab-integrity-checks:latest
stage: linters
variables:
GIT_DEPTH: "1"
tags:
- docker-medium
- check-author
script:
- check_author.py check "$GITLAB_USER_EMAIL" "$GITLAB_USER_NAME" --no-accents
except:
refs:
- master@linagora/lgs/openpaas/esn
- tags@linagora/lgs/openpaas/esn
- /^release-.*/@linagora/lgs/openpaas/esn
####### tests without services requirements
frontend-test:
<<: *test-template
script:
- grunt -v test-frontend
modules-frontend-test:
<<: *test-template
script:
- grunt -v test-modules-frontend
- TZ="Pacific/Kiritimati" grunt -v test-modules-frontend
- TZ="Pacific/Midway" grunt -v test-modules-frontend
- TZ="Pacific/Chatham" grunt -v test-modules-frontend
unit-backend-test:
<<: *test-template
script:
- grunt -v --chunk=1 test-unit-backend
modules-unit-backend-test:
<<: *test-template
script:
- grunt -v --chunk=1 test-modules-unit-backend
####### tests with services requirements
unit-storage-test:
<<: *test-template
services:
- name: docker.elastic.co/elasticsearch/elasticsearch:6.3.2
alias: elasticsearch-unit
command: [ "bin/elasticsearch", "-Ediscovery.type=single-node" ]
- name: mongo:3.2.0
alias: mongo-unit
- name: redis:latest
alias: redis-unit
- name: rabbitmq:3.6.5-management
alias: rabbitmq-unit
variables:
MONGO_HOST: mongo-unit
MONGO_PORT: 27017
AMQP_HOST: rabbitmq-unit
AMQP_PORT: 5672
ESN_ELASTIC_HOST: elasticsearch-unit
ELASTICSEARCH_HOST: elasticsearch-unit
ELASTICSEARCH_PORT: 9200
REDIS_HOST: redis-unit
REDIS_PORT: 6379
script:
- grunt -v --chunk=1 gitlab-test-unit-storage
- grunt -v --chunk=1 gitlab-test-modules-unit-storage
modules-midway-test:
<<: *test-template
services:
- name: docker.elastic.co/elasticsearch/elasticsearch:6.3.2
alias: elasticsearch-midway
command: [ "bin/elasticsearch", "-Ediscovery.type=single-node" ]
- name: mongo:3.2.0
alias: mongo-midway
- name: redis:latest
alias: redis-midway
- name: rabbitmq:3.6.5-management
alias: rabbitmq-midway
variables:
MONGO_HOST: mongo-midway
MONGO_PORT: 27017
AMQP_HOST: rabbitmq-midway
AMQP_PORT: 5672
ESN_ELASTIC_HOST: elasticsearch-midway
ELASTICSEARCH_HOST: elasticsearch-midway
ELASTICSEARCH_PORT: 9200
REDIS_HOST: redis-midway
REDIS_PORT: 6379
script:
- grunt -v --chunk=1 gitlab-test-modules-midway
midway-backend-test:
<<: *test-template
services:
- name: docker.elastic.co/elasticsearch/elasticsearch:6.3.2
alias: elasticsearch-backend
command: [ "bin/elasticsearch", "-Ediscovery.type=single-node" ]
- name: mongo:3.2.0
alias: mongo-backend
- name: redis:latest
alias: redis-backend
- name: rabbitmq:3.6.5-management
alias: rabbitmq-backend
variables:
MONGO_HOST: mongo-backend
MONGO_PORT: 27017
AMQP_HOST: rabbitmq-backend
AMQP_PORT: 5672
ESN_ELASTIC_HOST: elasticsearch-backend
ELASTICSEARCH_HOST: elasticsearch-backend
ELASTICSEARCH_PORT: 9200
REDIS_HOST: redis-backend
REDIS_PORT: 6379
script:
- grunt --chunk=1 -v gitlab-test-midway-backend
# Why is it deactivated ?
# This job try to build and test everything !!!
.test-e2e:
stage: test-e2e
before_script:
- export TZ=America/New_York
- . ~/.nvm/nvm.sh && nvm use 8
- npm install -g grunt-cli
cache:
<<: *cache-tpl
script:
- export VIDEO=true
- export VIDEO_FIREFOX_NAME=firefox-$CI_JOB_ID
- export VIDEO_CHROME_NAME=chrome-$CI_JOB_ID
- export VIDEO_DIR="$PWD/e2e-videos"
- npm install
- grunt test-e2e-clean
- grunt test-e2e-prepare $DOCKER_OPTIONS
- BROWSER="firefox" VIDEO_FILE_NAME=$VIDEO_FIREFOX_NAME grunt test-e2e $DOCKER_OPTIONS
- BROWSER="chrome" VIDEO_FILE_NAME=$VIDEO_CHROME_NAME grunt test-e2e $DOCKER_OPTIONS
allow_failure: true
# Maybe this stage should not use test-template,
# the job will not created for tag pipeline.
swagger:
<<: *test-template
stage: swagger
script:
- grunt swagger-generate
- grunt swagger-validate
artifacts:
paths:
- ./doc/REST_API/swagger/swagger.json
deploy-swagger:
stage: deploy
tags:
- deployment
- api.open-paas.org
- shell
environment:
name: api
url: https://api.open-paas.org
only:
- master@linagora/lgs/openpaas/esn
script:
- perl -i -pe's/"host":"localhost:8080"/"schemes":["https"],"host":"demo.open-paas.org"/' ./doc/REST_API/swagger/swagger.json
- cp ./doc/REST_API/swagger/swagger.json /var/www/html
deploy-dev:
stage: deploy
tags:
- dev.open-paas.org
- deployment
environment:
name: dev
url: https://dev.open-paas.org
only:
- master@linagora/lgs/openpaas/esn
script:
- cd /srv/rse.dev
- git fetch --all
- git checkout ${CI_COMMIT_SHA}
- npm install --ignore-scripts --production
- npm update --production
- npm prune
- bower install --production
- bower prune
- git checkout -- .
- sudo /etc/init.d/rse.dev restart
.build-docker-tpl: &build-docker-tpl
image: docker-registry.linagora.com:5000/linshare-snapshots/linshare-dind:latest
tags:
- docker
services:
- name: docker-registry.linagora.com:5000/linshare-snapshots/linshare-dind:latest
command: ["--registry-mirror", "https://mirror.gcr.io"]
alias: docker-dind
####### Build & publish branch base docker images (master branch, release maintaining branches, feature branches)
.docker-internal-registry: &docker-internal-registry
- guess-version.sh guess
- source version.env
- docker-tag-computing.sh ${VERSION} docker-tag-and-push.env
- source docker-tag-and-push.env
- docker login -u ${REGISTRY_USER} -p ${REGISTRY_TOKEN} docker-registry.linagora.com:5000
- docker build . -t localimage
- docker-tag-and-push.sh localimage ${DOCKER_IMAGE_PRIVATE}
- docker logout docker-registry.linagora.com:5000
.docker-public-registry: &docker-public-registry
- docker login -u ${HUB_DOCKER_USER} -p ${HUB_DOCKER_TOKEN}
- docker tag localimage ${DOCKER_IMAGE_PUBLIC}:${DOCKER_PUBLIC_TAG_NAME}
- docker push ${DOCKER_IMAGE_PUBLIC}:${DOCKER_PUBLIC_TAG_NAME}
- docker logout
variables: &docker-branches-variables
DOCKER_HOST: "tcp://docker-dind"
DOCKER_IMAGE_PRIVATE: "docker-registry.linagora.com:5000/openpaas-snapshots/openpaas-esn"
DOCKER_IMAGE_PUBLIC: "linagora/esn"
docker-master:
<<: *build-docker-tpl
stage: build
variables:
<<: *docker-branches-variables
DOCKER_PUBLIC_TAG_NAME: "branch-master"
script:
- *docker-internal-registry
- *docker-public-registry
only:
- master@linagora/lgs/openpaas/esn
except:
variables:
- $SKIP_BUILD_DOCKER
docker-snapshot:
<<: *build-docker-tpl
stage: build
variables:
<<: *docker-branches-variables
script:
- *docker-internal-registry
- export DOCKER_PUBLIC_TAG_NAME=branch-${DOCKER_TAG}
- *docker-public-registry
only:
- /^release-.*/@linagora/lgs/openpaas/esn
except:
variables:
- $SKIP_BUILD_DOCKER
docker-feature:
<<: *build-docker-tpl
stage: build
variables:
<<: *docker-branches-variables
script:
- export DOCKER_PUBLIC_TAG_NAME=${CI_COMMIT_REF_NAME}
- docker login -u ${REGISTRY_USER} -p ${REGISTRY_TOKEN} docker-registry.linagora.com:5000
- docker build . -t localimage
- docker tag localimage ${DOCKER_IMAGE_PRIVATE}:${DOCKER_PUBLIC_TAG_NAME}
- docker push ${DOCKER_IMAGE_PRIVATE}:${DOCKER_PUBLIC_TAG_NAME}
- docker logout docker-registry.linagora.com:5000
- *docker-public-registry
only:
- /^feature-.*/@linagora/lgs/openpaas/esn
except:
variables:
- $SKIP_BUILD_DOCKER
####### Build & publish release
docker-release:
<<: *build-docker-tpl
stage: build
variables:
DOCKER_HOST: "tcp://docker-dind"
DOCKER_IMAGE_PRIVATE: "docker-registry.linagora.com:5000/openpaas-releases/openpaas-esn"
DOCKER_IMAGE_PUBLIC: "linagora/esn"
script:
- docker-tag-computing.sh ${CI_COMMIT_TAG} docker-tag-and-push.env
- docker login -u ${REGISTRY_USER_RELEASE} -p ${REGISTRY_TOKEN_RELEASE} docker-registry.linagora.com:5000
- docker login -u ${HUB_DOCKER_USER} -p ${HUB_DOCKER_TOKEN}
- docker build . -t localimage
- docker-tag-and-push.sh localimage ${DOCKER_IMAGE_PRIVATE} ${DOCKER_IMAGE_PUBLIC}
- docker logout
only:
- tags@linagora/lgs/openpaas/esn
except:
variables:
- $SKIP_BUILD_DOCKER
docker-mark-as-latest-from-tag:
<<: *build-docker-tpl
stage: deploy
variables:
GIT_STRATEGY: none
DOCKER_HOST: "tcp://docker-dind"
DOCKER_IMAGE_PRIVATE: "docker-registry.linagora.com:5000/openpaas-releases/openpaas-esn"
DOCKER_IMAGE_PUBLIC: "linagora/esn"
script:
- docker login -u ${REGISTRY_USER_RELEASE} -p ${REGISTRY_TOKEN_RELEASE} docker-registry.linagora.com:5000
- docker login -u ${HUB_DOCKER_USER} -p ${HUB_DOCKER_TOKEN}
- docker-tag-computing.sh ${CI_COMMIT_TAG} docker-tags.env
- source docker-tags.env
- docker pull ${DOCKER_IMAGE_PRIVATE}:${DOCKER_TAG}
- export DOCKER_TAGS=latest
- docker-tag-and-push.sh ${DOCKER_IMAGE_PRIVATE}:${DOCKER_TAG} ${DOCKER_IMAGE_PRIVATE} ${DOCKER_IMAGE_PUBLIC}
- docker logout
when: manual
only:
- tags@linagora/lgs/openpaas/esn