-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.gitlab-ci.yml
434 lines (381 loc) · 12.2 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
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
stages:
- build
- test
- release
- configure
- deploy
# https://docs.gitlab.com/ee/ci/yaml/workflow.html#switch-between-branch-pipelines-and-merge-request-pipelines
.if-default-branch-refs: &if-default-branch-refs
if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
.if-tag: &if-tag
if: '$CI_COMMIT_TAG'
.if-merge-request: &if-merge-request
if: '$CI_MERGE_REQUEST_IID'
# Workflow
###########
workflow:
rules:
- <<: *if-tag
variables:
# Override the IMAGE_SHA variable on tag pipelines to avoid both the default
# branch pipeline and tag pipeline overriding each other's images arbitrarily when
# they are both running at the same time on master.
IMAGE_SHA: ${CI_REGISTRY_IMAGE}:${CI_COMMIT_TAG}
- <<: *if-default-branch-refs
- <<: *if-merge-request
include:
- project: "labs/salt-automation"
file:
- "/gitlab-ci-templates/common/rules.v1.yml"
- "/gitlab-ci-templates/common/saltbert.v1.yml"
- "/gitlab-ci-templates/common/docker-build-meta.v2.yml"
- "/gitlab-ci-templates/common/docker-release-meta.v1.yml"
- "/gitlab-ci-templates/common/config-updater-meta.v1.yml"
- "/gitlab-ci-templates/common/conventional-commits-meta.v1.yml"
- "/gitlab-ci-templates/common/conventional-commits-changelog-meta.v1.yml"
variables:
RELEASE_REGISTRY: docker.io
RELEASE_REGISTRY_IMAGE: index.docker.io/magentaaps/datafordeler
DAFO_IMAGE_SHA: ${CI_REGISTRY_IMAGE}/datafordeler:${CI_COMMIT_SHA}
DAFO_IMAGE_TAG: magentaaps/datafordeler:${CI_COMMIT_TAG}
DAFOSQL_IMAGE_SHA: ${CI_REGISTRY_IMAGE}/datafordeler-test-db:${CI_COMMIT_SHA}
DAFOSQL_IMAGE_TAG: magentaaps/datafordeler-test-db:${CI_COMMIT_TAG}
DAFODOC_IMAGE_SHA: ${CI_REGISTRY_IMAGE}/datafordeler_doc:${CI_COMMIT_SHA}
DAFODOC_IMAGE_TAG: magentaaps/datafordeler_doc:${CI_COMMIT_TAG}
# Build stage
#############
build-mssql-image:
extends: .build-docker
variables:
CI_IMAGE: ${DAFOSQL_IMAGE_SHA}
DOCKERFILE: ${CI_PROJECT_DIR}/docker/Dockerfile.sqlserver
build-image:
extends: .build-docker
variables:
CI_IMAGE: ${DAFO_IMAGE_SHA}
DOCKERFILE: ${CI_PROJECT_DIR}/docker/Dockerfile
build-openapi-image:
extends: .build-docker
variables:
CI_IMAGE: ${DAFODOC_IMAGE_SHA}
DOCKERFILE: ${CI_PROJECT_DIR}/docker/Dockerfile.openapi
# Test stage
#############
.test-default: &test-default
stage: test
needs:
- build-mssql-image
- build-image
image: ${DAFO_IMAGE_SHA}
variables:
GIT_STRATEGY: none
JAVA_OPTS: "-Duser.timezone=Europe/Copenhagen"
#M$ sql variables
ACCEPT_EULA: "Y"
SA_PASSWORD: "testTEST1"
SERVERNAME: "dafodev"
SERVER_PORT: "80"
DATABASE_CLASS: "org.h2.Driver"
DATABASE_URL: "jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1;MVCC=TRUE;INIT=CREATE SCHEMA IF NOT EXISTS DBO"
DATABASE_DIALECT: "org.hibernate.dialect.H2Dialect"
DATABASE_SHOW_SQL: "false"
DATABASE_USERNAME: "sa"
DATABASE_PASSWORD: "testTEST1"
DATABASE_METHOD: "create-drop"
DATABASE_DEFAULT_SCHEMA: "dbo"
SECONDARY_DATABASE_CLASS: "org.h2.Driver"
SECONDARY_DATABASE_URL: "jdbc:h2:mem:db2;DB_CLOSE_DELAY=-1;MVCC=TRUE;INIT=CREATE SCHEMA IF NOT EXISTS DBO"
SECONDARY_DATABASE_DIALECT: "org.hibernate.dialect.H2Dialect"
SECONDARY_DATABASE_SHOW_SQL: "false"
SECONDARY_DATABASE_USERNAME: "sa"
SECONDARY_DATABASE_PASSWORD: "testTEST1"
SECONDARY_DATABASE_METHOD: "create-drop"
SECONDARY_DATABASE_DEFAULT_SCHEMA: "dbo"
SSL_ENABLE: "false"
USER_DATABASE_ENABLED: "false"
USER_DATABASE_SECURITY_DISABLED: "false"
USER_DATABASE_URL: "jdbc:sqlserver://datafordeler-db:1433;databaseName=Datafordeler"
USER_DATABASE_USERNAME: "sa"
USER_DATABASE_PASSWORD: "testTEST1"
STS_METADATA_PATH: "/app/conf/sts_metadata.test.xml"
STATISTICS_ENABLE: "true"
PULL_ENABLE: "true"
CRON_ENABLE: "true"
CPR_PROXY_URL: ""
CPR_LOCAL_COPY_FOLDER: ""
CPR_SUBSCRIPTION_ENABLE: "true"
CPR_ENCRYPTION_KEYFILE: "/tmp/test_cpr_key.json"
CPR_TEST_PERSON_LIST: >
0112977724,0101570010,0101570088,2505811057,0601980010,1105520049,0103897769,1102640019,
0707610042,0902410058,2512474856,1509814844,2512052730,0601980029,3105841026,0101005038,1105801064,0312600013,
2510202794,2501950079,0112947728,0101055035,0401570020,0206025050,0106664862,1105015018,0209025000,3105781007,
2301175038,1502122777,0103232759,1502062774,0904410039,0708614866,2512484916,2509474829,3101827746,0101005089,
1105550193,1111111111,1111111112,1111111113,1111111110,1211111111,
1105550193,1111111111,1111111112,1111111113,3111171114,3111171115,3111171116,3111171117,0101704711,1304283824,
1703501821,0202940001,0202940003,
0104909995,0104909989,0107729995,0108589995,0108629996,0201609995,0201609996,0201919990,0201919995,0201919996,
0211223989,0212159995,0504909989,0504909995,0505059996,0505109990,0505159995,0505209996,0506889996,1007059995,
1110109996,1310169995,1310169996,1502779995,1502799995,1502829995,1509819996,2103009996,2311143995,2509479989,
2512489996,2911829996,3001749995,3103979995
CVR_DEMO_COMPANYFILE: "classpath:company_in.json"
CVR_DEMO_UNITFILE: "classpath:unit.json"
CVR_DEMO_PARTICIPANTFILE: "classpath:person.json"
CVR_LOCAL_COPY_FOLDER: ""
GEO_LOCAL_COPY_FOLDER: ""
ERRORFILE_DIR: "cache/log"
tags:
- docker
services:
- name: ${DAFOSQL_IMAGE_SHA}
alias: datafordeler-db
test-core:
<<: *test-default
before_script:
- cd /code/core
script:
- mvn --batch-mode test
artifacts:
reports:
junit:
- /code/core/target/surefire-reports/*.xml
test-cpr:
<<: *test-default
before_script:
- cd /code/plugin/cpr
script:
- mvn --batch-mode test
artifacts:
reports:
junit:
- /code/plugin/cpr/target/surefire-reports/TEST-*
test-cvr:
<<: *test-default
before_script:
- cd /code/plugin/cvr
script:
- mvn --batch-mode test
artifacts:
reports:
junit: target/surefire-reports/*.xml
test-eboks:
<<: *test-default
before_script:
- cd /code/plugin/eboks
script:
- mvn --batch-mode test
artifacts:
reports:
junit:
- /code/plugin/eboks/target/surefire-reports/*.xml
test-eskat:
<<: *test-default
before_script:
- cd /code/plugin/eskat
script:
- mvn --batch-mode test
artifacts:
reports:
junit:
- /code/plugin/eskat/target/surefire-reports/*.xml
test-geo:
<<: *test-default
before_script:
- cd /code/plugin/geo
script:
- mvn --batch-mode test
artifacts:
reports:
junit:
- /code/plugin/geo/target/surefire-reports/*.xml
test-ger:
<<: *test-default
before_script:
- cd /code/plugin/ger
script:
- mvn --batch-mode test
artifacts:
reports:
junit:
- /code/plugin/ger/target/surefire-reports/*.xml
test-prisme:
<<: *test-default
before_script:
- cd /code/plugin/prisme
script:
- mvn --batch-mode test
artifacts:
reports:
junit:
- /code/plugin/prisme/target/surefire-reports/*.xml
test-combinedPitu:
<<: *test-default
before_script:
- cd /code/plugin/combinedPitu
script:
- mvn --batch-mode test
artifacts:
reports:
junit:
- /code/plugin/pituCombined/target/surefire-reports/TEST-*.xml
test-statistik:
<<: *test-default
before_script:
- cd /code/plugin/statistik
script:
- mvn --batch-mode test
artifacts:
reports:
junit:
- /code/plugin/statistik/target/surefire-reports/*.xml
test-subscription:
<<: *test-default
before_script:
- cd /code/plugin/subscription
script:
- mvn --batch-mode test
artifacts:
reports:
junit: /code/plugin/subscription/target/surefire-reports/*.xml
# Release stage
###############
.release:
stage: release
image: alpine
needs: ["test-core", "test-cpr", "test-cvr", "test-eboks", "test-eskat", "test-geo", "test-ger", "test-prisme", "test-combinedPitu", "test-statistik","test-subscription"]
variables:
GIT_STRATEGY: none # We do not need the source code
before_script:
- apk add skopeo
Release Datafordeler image:
extends:
- .rules:semver-all
- .release
script:
- skopeo copy
--src-creds=${CI_REGISTRY_USER}:${CI_REGISTRY_PASSWORD}
--dest-creds=${RELEASE_REGISTRY_USER}:${RELEASE_REGISTRY_PASSWORD}
"docker://${DAFO_IMAGE_SHA}"
"docker://${DAFO_IMAGE_TAG}"
# TODO: Remove when no longer needed
Release Datafordeler-test-db image:
extends:
- .rules:semver-all
- .release
script:
- skopeo copy
--src-creds=${CI_REGISTRY_USER}:${CI_REGISTRY_PASSWORD}
--dest-creds=${RELEASE_REGISTRY_USER}:${RELEASE_REGISTRY_PASSWORD}
"docker://${DAFOSQL_IMAGE_SHA}"
"docker://${DAFOSQL_IMAGE_TAG}"
# Configure stage
#################
Configure Test:
stage: configure
extends:
- .rules:semver-all
- .config:endpoint-with-tag
needs: ["Release Datafordeler image", "Release Datafordeler-test-db image"]
variables:
ENDPOINT: datafordeler/salt/update-test
Configure Demo:
stage: configure
extends:
- .rules:semver-all
- .config:endpoint-with-tag
needs: ["Release Datafordeler image", "Release Datafordeler-test-db image"]
variables:
ENDPOINT: datafordeler/salt/update-demo
Configure Production:
stage: configure
extends:
- .rules:semver-core
- .config:endpoint-with-tag
needs: ["Release Datafordeler image", "Release Datafordeler-test-db image"]
variables:
ENDPOINT: datafordeler/salt/update-prod
# Deploy stage
##############
Deploy Test 1:
stage: deploy
when: manual
extends:
- .rules:semver-all
- .saltbert
needs: ["Release Datafordeler image", "Release Datafordeler-test-db image", "Configure Test"]
variables:
SALTBERT_ORCHESTRATION: groenland.datafordeler.service-test-1
SALTBERT_URL: https://saltmaster.groenland.magentahosted.dk
environment:
name: test01
url: "https://test.data.gl"
Deploy Test 2:
stage: deploy
when: manual
extends:
- .rules:semver-all
- .saltbert
# Depend on test 1, so we only have one server down at a time
# It needs to be checked that service 1 is up & running before taking down service 2
needs: ["Release Datafordeler image", "Release Datafordeler-test-db image", "Configure Test", "Deploy Test 1"]
variables:
SALTBERT_ORCHESTRATION: groenland.datafordeler.service-test-2
SALTBERT_URL: https://saltmaster.groenland.magentahosted.dk
environment:
name: test02
url: "https://test.data.gl"
Deploy Demo 1:
stage: deploy
when: manual
extends:
- .rules:semver-all
- .saltbert
needs: ["Release Datafordeler image", "Release Datafordeler-test-db image", "Configure Demo"]
variables:
SALTBERT_ORCHESTRATION: groenland.datafordeler.service-demo-1
SALTBERT_URL: https://saltmaster.groenland.magentahosted.dk
environment:
name: demo01
url: "https://demo.test.data.gl"
Deploy Demo 2:
stage: deploy
when: manual
extends:
- .rules:semver-all
- .saltbert
# Depend on test 1, so we only have one server down at a time
# It needs to be checked that service 1 is up & running before taking down service 2
needs: ["Release Datafordeler image", "Release Datafordeler-test-db image", "Configure Test", "Deploy Demo 1"]
variables:
SALTBERT_ORCHESTRATION: groenland.datafordeler.service-demo-2
SALTBERT_URL: https://saltmaster.groenland.magentahosted.dk
environment:
name: demo02
url: "https://demo.test.data.gl"
Deploy Production 1:
stage: deploy
when: manual
extends:
- .rules:semver-core
- .saltbert
needs: ["Release Datafordeler image", "Configure Production"]
variables:
SALTBERT_ORCHESTRATION: groenland.datafordeler.service-prod-1
SALTBERT_URL: https://saltmaster.groenland.magentahosted.dk
environment:
name: production01
url: "https://data.gl"
Deploy Production 2:
stage: deploy
when: manual
extends:
- .rules:semver-core
- .saltbert
# Depend on test 1, so we only have one server down at a time
# It needs to be checked that service 1 is up & running before taking down service 2
needs: ["Release Datafordeler image", "Configure Production", "Deploy Production 1"]
variables:
SALTBERT_ORCHESTRATION: groenland.datafordeler.service-prod-2
SALTBERT_URL: https://saltmaster.groenland.magentahosted.dk
environment:
name: production02
url: "https://data.gl"