forked from linagora/openpaas-esn
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.gitlab-ci.yml
381 lines (350 loc) · 10.8 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
380
381
# 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
.curl-tpl: &curl-tpl
variables:
GIT_STRATEGY: none
tags:
- curl
before_script:
- apk add --no-cache curl jq
.build-pkg-tpl: &build-pkg-tpl
<<: *curl-tpl
only:
- master@linagora/lgs/openpaas/esn
except:
variables:
- $SKIP_BUILD_PKG
.test-template: &test-template
image: node:8.15.0
stage: test
tags:
- docker
cache:
<<: *cache-tpl
variables:
TZ: "America/New_York"
before_script:
- npm install -g grunt-cli
- '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
.test-template-svc: &test-template-svc
<<: *test-template
services:
- name: elasticsearch:2.3.2
alias: elasticsearch
- name: mongo:3.2.0
alias: mongo
- name: redis:latest
alias: redis
- name: rabbitmq:3.6.5-management
alias: rabbitmq
variables:
MONGO_HOST: mongo
MONGO_PORT: 27017
AMQP_HOST: rabbitmq
AMQP_PORT: 5672
ELASTICSEARCH_HOST : elasticsearch
ELASTICSEARCH_PORT: 9200
REDIS_HOST: redis
REDIS_PORT: 6379
prepare:
image: node:8.15.0
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:
- npm install
# Weird behaviour: at the time, npm postinstall was not called.
- ./node_modules/.bin/bower install --allow-root
- 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-svc
script:
- grunt -v --chunk=1 gitlab-test-unit-storage
- grunt -v --chunk=1 gitlab-test-modules-unit-storage
modules-midway-test:
<<: *test-template-svc
script:
- grunt -v --chunk=1 gitlab-test-modules-midway
midway-backend-test:
<<: *test-template-svc
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
.build_pkg_deb_openpaas_jessie:
<<: *build-pkg-tpl
stage: build
script:
- curl -s -X POST
-F "token=${BUILD_PACKAGE_CI_TOKEN}"
-F "ref=master"
-F "variables[REPO]=https://ci.linagora.com/linagora/lgs/openpaas/esn.git"
-F "variables[VERSION_FILE]=package.json"
-F "variables[PACKAGE_NAME]=openpaas"
-F "variables[DOCKERFILE]=debian/jessie/openpaas/Dockerfile"
https://ci.linagora.com/api/v4/projects/338/trigger/pipeline | jq .
.build_pkg_deb_openpaas_stretch:
<<: *build-pkg-tpl
stage: build
script:
- curl -s -X POST
-F "token=${BUILD_PACKAGE_CI_TOKEN}"
-F "ref=master"
-F "variables[REPO]=https://ci.linagora.com/linagora/lgs/openpaas/esn.git"
-F "variables[VERSION_FILE]=package.json"
-F "variables[PACKAGE_NAME]=openpaas"
-F "variables[DOCKERFILE]=debian/stretch/openpaas/Dockerfile"
https://ci.linagora.com/api/v4/projects/338/trigger/pipeline | jq .
.build_pkg_rpm_openpaas:
<<: *build-pkg-tpl
stage: build
script:
- curl -s -X POST
-F "token=${BUILD_PACKAGE_CI_TOKEN}"
-F "ref=master"
-F "variables[REPO]=https://ci.linagora.com/linagora/lgs/openpaas/esn.git"
-F "variables[VERSION_FILE]=package.json"
-F "variables[PACKAGE_NAME]=openpaas"
-F "variables[DOCKERFILE]=redhat/7/openpaas/Dockerfile"
https://ci.linagora.com/api/v4/projects/338/trigger/pipeline | jq .
.build_pkg_deb_openpaas-james_jessie:
<<: *build-pkg-tpl
stage: build
script:
- curl -s -X POST
-F "token=${BUILD_PACKAGE_CI_TOKEN}"
-F "ref=master"
-F "variables[REPO]=https://ci.linagora.com/linagora/lgs/openpaas/esn.git"
-F "variables[VERSION_FILE]=package.json"
-F "variables[PACKAGE_NAME]=openpaas-james"
-F "variables[DOCKERFILE]=debian/jessie/openpaas-james/Dockerfile"
https://ci.linagora.com/api/v4/projects/338/trigger/pipeline | jq .
.build_pkg_deb_openpaas-james_stretch:
<<: *build-pkg-tpl
stage: build
script:
- curl -s -X POST
-F "token=${BUILD_PACKAGE_CI_TOKEN}"
-F "ref=master"
-F "variables[REPO]=https://ci.linagora.com/linagora/lgs/openpaas/esn.git"
-F "variables[VERSION_FILE]=package.json"
-F "variables[PACKAGE_NAME]=openpaas-james"
-F "variables[DOCKERFILE]=debian/stretch/openpaas-james/Dockerfile"
https://ci.linagora.com/api/v4/projects/338/trigger/pipeline | jq .
.build_pkg_rpm_openpaas-james:
<<: *build-pkg-tpl
stage: build
script:
- curl -s -X POST
-F "token=${BUILD_PACKAGE_CI_TOKEN}"
-F "ref=master"
-F "variables[REPO]=https://ci.linagora.com/linagora/lgs/openpaas/esn.git"
-F "variables[VERSION_FILE]=package.json"
-F "variables[PACKAGE_NAME]=openpaas-james"
-F "variables[DOCKERFILE]=redhat/7/openpaas-james/Dockerfile"
https://ci.linagora.com/api/v4/projects/338/trigger/pipeline | jq .
# 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
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
alias: docker-dind
docker-snapshot:
<<: *build-docker-tpl
stage: build
variables:
DOCKER_HOST: "tcp://docker-dind"
DOCKER_IMAGE_PRIVATE: "docker-registry.linagora.com:5000/openpaas-snapshots/openpaas-esn"
script:
- guess-version.sh guest
- source version.env
- docker-tag-computing.sh ${VERSION} docker-tag-and-push.env
- docker login -u ${REGISTRY_USER} -p ${REGISTRY_TOKEN} docker-registry.linagora.com:5000
- docker build . -t build:latest
- docker-tag-and-push.sh build:latest ${DOCKER_IMAGE_PRIVATE}
- docker logout
only:
- master@linagora/lgs/openpaas/esn
- /^release-.*/@linagora/lgs/openpaas/esn
except:
variables:
- $SKIP_BUILD_DOCKER
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 build:latest
- docker-tag-and-push.sh build:latest ${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