-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
341 lines (313 loc) · 12 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
default:
image: node:20.2.0-alpine3.18
variables:
GIT_SUBMODULE_STRATEGY: recursive
CI_POETRY_VERSION: 1.8.2
stages:
- dependencies
- lint
- build
- test
- deploy
- deploy-dp
- scan
- pages
- integration
- integration-dp
- staging
- staging-dp
- integration-psi-low
- publish
#Install basic dependencies using yarn
install_dependencies:
stage: dependencies
tags:
- ska-default
before_script:
- rm -rf node_modules
script:
- npm config set registry https://registry.npmjs.org/
- yarn install --immutable
cache:
paths:
- node_modules/
policy: push
#Run the static code analysis
code_analysis:
stage: lint
tags:
- ska-default
cache:
paths:
- node_modules/
policy: pull
before_script:
- mkdir -p build/reports
script:
- npm config set registry https://registry.npmjs.org/
- yarn install --immutable
- yarn code-analysis
- mv linting.xml build/reports/linting.xml
artifacts:
paths:
- build/
# run the cypress test coverage reports
test_and_coverage:
image: cypress/browsers:node-20.11.1-chrome-123.0.6312.58-1-ff-124.0-edge-122.0.2365.92-1
stage: test
tags:
- ska-default
cache:
paths:
- node_modules/
policy: pull
before_script:
- mkdir -p build/reports
- yarn install --immutable
- yarn cypress install
script:
- yarn start &
- yarn test:e2e:headless
- yarn test:coverage:report:ci
- cp build/reports/cobertura-coverage.xml build/reports/code-coverage.xml
artifacts:
paths:
- build/
# list the current top level dependencies for the project
list_dependencies:
stage: test
tags:
- ska-default
allow_failure: true
cache:
paths:
- node_modules/
policy: pull
script:
- npm config set registry https://registry.npmjs.org/
- yarn install --immutable
- yarn list --depth=0 --json >> npm_deps.json
- yarn list --depth=0 >> npm_deps.txt
- mkdir .public
- cp npm_deps.txt .public/
- cp npm_deps.json .public/
artifacts:
paths:
- .public
test-counts:
image: cypress/browsers:node-20.11.1-chrome-123.0.6312.58-1-ff-124.0-edge-122.0.2365.92-1
stage: scan
tags:
- ska-default
cache:
paths:
- node_modules/
policy: pull
before_script:
- mkdir -p build/tests
- yarn install --immutable
- yarn cypress install
script:
- yarn test:cypress:component:ci
- yarn start &
- yarn test:cypress:e2e:ci
- yarn merge-reports
artifacts:
paths:
- build/
# Build the application
build:
stage: build
tags:
- ska-default
cache:
paths:
- node_modules/
policy: pull
script:
- npm config set registry https://registry.npmjs.org/
- yarn install --immutable
- yarn build
# export the report
pages:
stage: pages
tags:
- ska-default
dependencies:
- test-counts
- test_and_coverage
- list_dependencies
- code_quality
script:
- mv public/* .
- cp -r build/* public
- cp -r .public/* public
artifacts:
paths:
- public
expire_in: 30 days
include:
- template: Code-Quality.gitlab-ci.yml
# Docs pages
- project: 'ska-telescope/templates-repository'
file: 'gitlab-ci/includes/docs.gitlab-ci.yml'
# OCI Images
- project: 'ska-telescope/templates-repository'
file: 'gitlab-ci/includes/oci-image.gitlab-ci.yml'
# Tag Based GitLab Release Management
- project: 'ska-telescope/templates-repository'
file: 'gitlab-ci/includes/release.gitlab-ci.yml'
# .post step finalisers eg: badges
- project: 'ska-telescope/templates-repository'
file: 'gitlab-ci/includes/finaliser.gitlab-ci.yml'
# helm chart
- project: 'ska-telescope/templates-repository'
file: 'gitlab-ci/includes/helm-chart.gitlab-ci.yml'
# deploy steps
- project: 'ska-telescope/templates-repository'
file: 'gitlab-ci/includes/deploy.gitlab-ci.yml'
.info_script: &info_script
- |-
echo "Status of pods in $KUBE_NAMESPACE namespace:"
kubectl get pods -n $KUBE_NAMESPACE -o jsonpath="{range .items[*]}{'Pod: '}{.metadata.name}:{'\n'}{'\t'}{'Image: '}{.spec.containers[*].image}{'\n'}{'\t'}{'Status: '}{.status.phase}{'\n'}{end}{'\n'}"
echo "Addresses to connect to the deployment of the Dataproduct Dashboard: "
echo " https://sdhp.stfc.skao.int/$KUBE_NAMESPACE/dashboard/"
echo "Backend API:"
echo " https://sdhp.stfc.skao.int/$KUBE_NAMESPACE/api/"
deploy-dev-environment-dp:
stage: deploy-dp
extends: deploy-dev-environment
when: manual
tags:
- ska-k8srunner-dp
variables:
K8S_CHART_PARAMS: '--set api.container=registry.gitlab.com/ska-telescope/ska-dataproduct-api/ska-dataproduct-api --set api.version=0.10.0-dev.c8de06df0 --set api.imagePullPolicy=Always --set api.vault.useVault=true --set api.vault.pathToSecretVault=kv/data/users/andre_odendaal/sdhp-stfc/ska-sdp-dataproduct-api/integration --set api.postgresql.host=pgdev-lb.cnpgdev.svc.cluster.local --set api.postgresql.user=sdp_sdp_dataproduct_dashboard_integration --set api.postgresql.dbname=integration --set api.postgresql.schema=sdp_sdp_dataproduct_dashboard_integration --set api.postgresql.tableName=data_products_metadata_v2 --set api.elasticsearch.host=https://logging.stfc.skao.int --set api.elasticsearch.user=naledi-team --set api.elasticsearch.indices=ska-dp-dataproduct-sdhp-stfc-integration-v2 --set permissionsApi.image.container=registry.gitlab.com/ska-telescope/ska-permissions-api/ska-permissions-api --set permissionsApi.image.version=1.0.0-dev.c345a48e1 --set permissionsApi.image.imagePullPolicy=Always --set dashboard.container=registry.gitlab.com/ska-telescope/ska-dataproduct-dashboard/ska-dataproduct-dashboard --set dashboard.version=0.10.0-dev.c470fa564 --set dashboard.image.imagePullPolicy=Always --set dashboard.vault.useVault=true --set dashboard.vault.pathToSecretVault=kv/data/users/andre_odendaal/sdhp-stfc/ska-sdp-dataproduct-dashboard/integration'
test-dev-environment-dp:
stage: deploy-dp
extends: test-dev-environment
when: manual
tags:
- ska-k8srunner-dp
needs:
- deploy-dev-environment-dp
info-dev-environment-dp:
stage: deploy-dp
extends: info-dev-environment
tags:
- ska-k8srunner-dp
script:
- *info_script
stop-dev-environment-dp:
stage: deploy-dp
extends: stop-dev-environment
tags:
- ska-k8srunner-dp
deploy-integration-dp:
stage: integration-dp
extends: deploy-integration
when: manual
tags:
- ska-k8srunner-dp
variables:
K8S_CHART_PARAMS: '--set api.vault.useVault=true --set api.vault.pathToSecretVault=kv/data/users/andre_odendaal/sdhp-stfc/ska-sdp-dataproduct-api/integration --set api.postgresql.host=pgdev-lb.cnpgdev.svc.cluster.local --set api.postgresql.user=sdp_sdp_dataproduct_dashboard_integration --set api.postgresql.dbname=integration --set api.postgresql.schema=sdp_sdp_dataproduct_dashboard_integration --set api.postgresql.tableName=data_products_metadata_v2 --set api.elasticsearch.host=https://logging.stfc.skao.int --set api.elasticsearch.user=naledi-team --set api.elasticsearch.indices=ska-dp-dataproduct-sdhp-stfc-integration-v2 --set dashboard.vault.useVault=true --set dashboard.vault.pathToSecretVault=kv/data/users/andre_odendaal/sdhp-stfc/ska-sdp-dataproduct-dashboard/integration'
info-integration-dp:
stage: integration-dp
extends: info-integration
tags:
- ska-k8srunner-dp
script:
- *info_script
redeploy-integration-dp:
stage: integration-dp
extends: redeploy-integration
tags:
- ska-k8srunner-dp
variables:
K8S_CHART_PARAMS: '--set api.vault.useVault=true --set api.vault.pathToSecretVault=kv/data/users/andre_odendaal/sdhp-stfc/ska-sdp-dataproduct-api/integration --set api.postgresql.host=pgdev-lb.cnpgdev.svc.cluster.local --set api.postgresql.user=sdp_sdp_dataproduct_dashboard_integration --set api.postgresql.dbname=integration --set api.postgresql.schema=sdp_sdp_dataproduct_dashboard_integration --set api.postgresql.tableName=data_products_metadata_v2 --set api.elasticsearch.host=https://logging.stfc.skao.int --set api.elasticsearch.user=naledi-team --set api.elasticsearch.indices=ska-dp-dataproduct-sdhp-stfc-integration-v2 --set dashboard.vault.useVault=true --set dashboard.vault.pathToSecretVault=kv/data/users/andre_odendaal/sdhp-stfc/ska-sdp-dataproduct-dashboard/integration'
stop-integration-dp:
stage: integration-dp
extends: stop-integration
tags:
- ska-k8srunner-dp
needs:
- deploy-integration-dp
deploy-staging-dp:
stage: staging-dp
extends: deploy-staging
when: manual
tags:
- ska-k8srunner-dp
variables:
K8S_CHART_PARAMS: '--set api.vault.useVault=true --set api.vault.pathToSecretVault=kv/data/users/andre_odendaal/sdhp-stfc/ska-sdp-dataproduct-api/staging --set api.postgresql.host=pgdev-lb.cnpgdev.svc.cluster.local --set api.postgresql.user=sdp_sdp_dataproduct_dashboard_staging --set api.postgresql.dbname=staging --set api.postgresql.schema=sdp_sdp_dataproduct_dashboard_staging --set api.postgresql.tableName=data_products_metadata_v2 --set api.elasticsearch.host=https://logging.stfc.skao.int --set api.elasticsearch.user=naledi-team --set api.elasticsearch.indices=ska-dp-dataproduct-sdhp-stfc-staging-v1 --set dashboard.vault.useVault=true --set dashboard.vault.pathToSecretVault=kv/data/users/andre_odendaal/sdhp-stfc/ska-sdp-dataproduct-dashboard/staging'
info-staging-dp:
stage: staging-dp
extends: info-staging
tags:
- ska-k8srunner-dp
script:
- *info_script
redeploy-staging-dp:
stage: staging-dp
extends: redeploy-staging
tags:
- ska-k8srunner-dp
variables:
K8S_CHART_PARAMS: '--set api.vault.useVault=true --set api.vault.pathToSecretVault=kv/data/users/andre_odendaal/sdhp-stfc/ska-sdp-dataproduct-api/staging --set api.postgresql.host=pgdev-lb.cnpgdev.svc.cluster.local --set api.postgresql.user=sdp_sdp_dataproduct_dashboard_staging --set api.postgresql.dbname=staging --set api.postgresql.schema=sdp_sdp_dataproduct_dashboard_staging --set api.postgresql.tableName=data_products_metadata_v2 --set api.elasticsearch.host=https://logging.stfc.skao.int --set api.elasticsearch.user=naledi-team --set api.elasticsearch.indices=ska-dp-dataproduct-sdhp-stfc-staging-v1 --set dashboard.vault.useVault=true --set dashboard.vault.pathToSecretVault=kv/data/users/andre_odendaal/sdhp-stfc/ska-sdp-dataproduct-dashboard/staging'
stop-staging-dp:
stage: staging-dp
extends: stop-staging
tags:
- ska-k8srunner-dp
needs:
- deploy-staging-dp
# psi-low
deploy-integration-psi-low:
stage: integration-psi-low
extends: deploy-integration
when: manual
tags:
- k8srunner-psi-low
info-integration-psi-low:
stage: integration-psi-low
extends: info-integration
tags:
- k8srunner-psi-low
script:
- *info_script
redeploy-integration-psi-low:
stage: integration-psi-low
extends: redeploy-integration
tags:
- k8srunner-psi-low
stop-integration-psi-low:
stage: integration-psi-low
extends: stop-integration
tags:
- k8srunner-psi-low
needs:
- deploy-integration-psi-low
code_quality:
# https://docs.gitlab.com/ee/user/project/merge_requests/code_quality.html#generate-an-html-report
artifacts:
paths: [gl-code-quality-report.json]
# disable dind service as it's not needed for k8srunner runners
services: []
tags:
- ska-default
# We need to merge the rules with what we have here on template rules
# https://gitlab.com/ska-telescope/templates-repository/-/blob/master/gitlab-ci/includes/rules.gitlab-ci.yml
# https://docs.gitlab.com/ee/user/project/merge_requests/code_quality.html#using-with-merge-request-pipelines
rules:
- if: '$CODE_QUALITY_DISABLED'
when: never
# don't run branch pipeline if there are open MRs
- if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS && $CI_PIPELINE_SOURCE == "push"
when: never
# run on MRs
- if: $CI_MERGE_REQUEST_IID
# For `$CI_DEFAULT_BRANCH` branch, create a pipeline (this includes on schedules, pushes, merges, etc.).
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
# For tags, create a pipeline.
- if: '$CI_COMMIT_TAG'
# run on branches
- if: '$CI_COMMIT_BRANCH'