-
Notifications
You must be signed in to change notification settings - Fork 7
/
.gitlab-ci.yml
324 lines (295 loc) · 7.71 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
# Main LocoKit Gitlab CI file
#
# This file will trigger API / Front / Doc° / Packages CI
# if some files of their directories have been updated
# or if we want to create a new release,
# it will combine front & api into one docker image.
image:
name: node:16
stages:
- quality
- build
- docker
- publish
- teardown
.default-template:
tags: []
## Front
.front-default-template:
extends: .default-template
needs: []
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
changes:
- front/**.*
.front-publish-template:
extends: .default-template
needs: ["front-build"]
stage: publish
variables:
# VUE_APP_TITLE: 'Plate-forme v-logistique'
# VUE_APP_THEME: 'vlogistique'
# LCK_ENV: 'vlog-staging'
script:
- cd front
- PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true npm ci
- cp front/public/config-${LCK_ENV}.js.dist front/dist/config.js
- npm run build:html
- npx surge front/dist lck-${LCK_ENV}-${CI_COMMIT_REF_SLUG}.surge.sh
environment:
name: review/lck-${LCK_ENV}-${CI_COMMIT_REF_SLUG}
url: http://lck-${LCK_ENV}-${CI_COMMIT_REF_SLUG}.surge.sh
.front-teardown-template:
extends: .default-template
stage: teardown
variables:
GIT_STRATEGY: none
script:
- cd front
- npx surge teardown lck-${LCK_ENV}-${CI_COMMIT_REF_SLUG}.surge.sh
when: manual
environment:
name: review/lck-${LCK_ENV}-${CI_COMMIT_REF_SLUG}
url: http://lck-${LCK_ENV}-${CI_COMMIT_REF_SLUG}.surge.sh
action: stop
front-quality:
extends: .front-default-template
image: buildkite/puppeteer
stage: quality
rules:
- if: '$CI_COMMIT_BRANCH == "master" || $CI_COMMIT_TAG != ""'
script:
- cd front
- npm i -g npm@7
- npm ci
- npm run lint
- npm run storybook:build
- npm run test:unit -- --coverage --reporters=default
coverage: /All files[^|]*\|[^|]*\s+([\d\.]+)/
artifacts:
expire_in: 1 week
name: 'lck-front-quality-${CI_COMMIT_REF_SLUG}'
when: always
paths:
- front/tests/unit/__image_snapshots__
- front/storybook-static
reports:
junit:
- junit.xml
front-build:
extends: .front-default-template
stage: build
needs: ["front-quality"]
rules:
- if: '$CI_COMMIT_BRANCH == "master" || $CI_COMMIT_TAG != ""'
variables:
VUE_APP_I18N_FALLBACK_LOCALE: 'fr'
VUE_APP_TITLE: '{{ lck_app_title }}'
VUE_APP_THEME: '{{ lck_app_theme }}'
script:
- cd front
- PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true npm ci
- npm run build
artifacts:
expire_in: 3 mos
name: 'lck-front-${CI_COMMIT_REF_SLUG}'
paths:
- front/dist/
front-publish-storybook:
extends: .default-template
needs: ["front-quality"]
stage: publish
script:
- npx surge front/storybook-static lck-storybook-${CI_COMMIT_REF_SLUG}.surge.sh
environment:
name: review/lck-storybook-${CI_COMMIT_REF_SLUG}
url: http://lck-storybook-${CI_COMMIT_REF_SLUG}.surge.sh
on_stop: front-teardown-storybook
front-publish-storybook-master:
extends: .default-template
needs: ["front-quality"]
stage: publish
rules:
- if: '$CI_COMMIT_BRANCH == "master"'
script:
- npx surge front/storybook-static lck-storybook.surge.sh
environment:
name: review/lck-storybook
url: http://lck-storybook.surge.sh
front-teardown-storybook:
extends: .front-teardown-template
needs: ["front-publish-storybook"]
environment:
name: review/lck-storybook-${CI_COMMIT_REF_SLUG}
url: http://lck-storybook-${CI_COMMIT_REF_SLUG}.surge.sh
## API
.api-default-template:
extends: .default-template
needs: []
rules:
- changes:
- api/**.*
- if: '$CI_COMMIT_TAG != ""'
when: manual
.api-docker-template:
extends: .api-default-template
image: docker:stable
stage: docker
services:
- docker:dind
needs: ["api-build-lib", "front-build", "docs-build"]
before_script:
- docker -v
- docker info
- echo "${MC_REGISTRY_PASSWORD}" | docker login -u ${MC_REGISTRY_USER} --password-stdin ${MC_REGISTRY}
- docker pull $IMAGE_NAME:latest || true
variables:
# Use TLS https://docs.gitlab.com/ee/ci/docker/using_docker_build.html#tls-enabled
DOCKER_HOST: tcp://docker:2375
DOCKER_DRIVER: overlay2
IMAGE_NAME: "${MC_REGISTRY}/${MC_REGISTRY_IMAGE}"
api-quality:
extends: .api-default-template
stage: quality
variables:
POSTGRES_DB: postgres
POSTGRES_USER: postgres
POSTGRES_PASSWORD: yourPostgresPassword
LCK_PORT: 3030
LCK_HOST: localhost
LCK_DATABASE_URL_TEST: postgres://postgres:yourPostgresPassword@lck-db:5432/postgres
OBJECTION_DEBUG: 'false'
NODE_ENV: test
STORAGE_TYPE: fs
STORAGE_PUBLIC_PATH: /storage
STORAGE_FS_PATH: ../fs-storage
STORAGE_S3_URL: http://lck-s3:9000
STORAGE_S3_ACCESS_KEY: minio
STORAGE_S3_SECRET_KEY: notsecret
STORAGE_S3_PATH_STYLE: 1
STORAGE_S3_SIGNATURE_VERSION: v4
STORAGE_S3_DEFAULT_BUCKET: public
MINIO_ACCESS_KEY: minio
MINIO_SECRET_KEY: notsecret
services:
- name: postgis/postgis:12-3.0
alias: lck-db
- name: minio/minio:latest
alias: lck-s3
command: ["server", "/data"]
script:
- cd api
- npm ci
- npm run lint
- npm test
artifacts:
expire_in: 1 day
name: 'lck-api-${CI_COMMIT_REF_SLUG}-coverage'
paths:
- api/coverage/
reports:
cobertura: api/coverage/cobertura-coverage.xml
api-build-lib:
extends: .api-default-template
stage: build
needs: ["api-quality"]
script:
- cd api
- npm ci
- npm run compile
artifacts:
expire_in: 3 mos
name: 'lck-api-${CI_COMMIT_REF_SLUG}'
paths:
- api/lib/
api-build-docker:
extends: .api-docker-template
variables:
IMAGE_VERSION: "latest"
script:
- docker build --cache-from $IMAGE_NAME:latest --tag $IMAGE_NAME:$IMAGE_VERSION .
- docker push $IMAGE_NAME:$IMAGE_VERSION
# api-build-docker-tagged:
# extends: .api-docker-template
# rules:
# - if: '$CI_COMMIT_TAG != ""'
# when: manual
# variables:
# IMAGE_VERSION: "${CI_COMMIT_TAG}"
# script:
# - docker build --cache-from $IMAGE_NAME:latest --tag $IMAGE_NAME:$IMAGE_VERSION --tag $IMAGE_NAME:latest .
# - docker push $IMAGE_NAME:$IMAGE_VERSION
# - docker push $IMAGE_NAME:latest
## Packages
# include:
# - local: packages/glossary/.gitlab-ci.yml
# rules:
# - changes:
# - packages/glossary/**.*
## Documentation
docs-build:
extends: .default-template
stage: build
variables:
BASE_URL: '/lck-docs/'
script:
- npx vitepress build docs
# - mv docs/.vitepress/dist docs/public/
artifacts:
paths:
- docs/.vitepress/dist
needs: []
rules:
- if: $CI_COMMIT_BRANCH == "master"
- when: manual
- changes:
- docs/**.*
## Packages
### Glossary
pkg-glossary-lint:
extends: .default-template
stage: quality
script:
- npm ci
- npm run lint/glossary
needs: []
rules:
- if: $CI_COMMIT_BRANCH == "master"
- when: manual
- changes:
- packages/glossary/**.*
- if: '$CI_COMMIT_TAG != ""'
when: manual
pkg-glossary-build:
extends: .default-template
stage: build
script:
- npm ci
- npm run build/glossary
artifacts:
expire_in: 1 month
when: always
paths:
- lib
needs: ["pkg-glossary-lint"]
rules:
- if: $CI_COMMIT_BRANCH == "master"
- when: manual
- changes:
- packages/glossary/**.*
- if: '$CI_COMMIT_TAG != ""'
when: manual
pkg-glossary-publish:
extends: .default-template
stage: publish
script:
- echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}">~/.npmrc
- npm publish/glossary
needs: ["pkg-glossary-build"]
rules:
- if: $CI_COMMIT_BRANCH == "master"
- when: manual
- changes:
- packages/glossary/**.*
- if: '$CI_COMMIT_TAG != ""'
when: manual