-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
292 lines (267 loc) · 7.53 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
variables:
GIT_SUBMODULE_STRATEGY: recursive
KUBE_HOST: 'https://k8s.stfc.skao.int'
a11y_urls: $KUBE_HOST/$KUBE_NAMESPACE/pht
JS_NODE_VERSION: 20
stages:
- dependencies
- lint
- build
- test
- scan
- pages
- deploy
- integration
- staging
- accessibility
- publish
install_dependencies:
image: node:20.2.0-alpine3.18
stage: dependencies
tags:
- k8srunner
before_script:
- rm -rf node_modules
script:
- 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
cache:
paths:
- node_modules/
policy: push
code_analysis:
image: node:20.2.0-alpine3.18
stage: lint
tags:
- ska-default
cache:
paths:
- node_modules/
policy: pull
before_script:
- mkdir -p build/reports
script:
- yarn install --immutable
- yarn code-analysis
- mv linting.xml build/reports/linting.xml
artifacts:
paths:
- build/
reports:
junit: build/reports/linting.xml
js-lint:
cache:
paths:
# - node_modules/
policy: pull
before_script:
# - mkdir -p build/reports
after_script:
# - yarn install --immutable
# - yarn code-analysis
# - mv linting.xml build/reports/linting.xml
artifacts:
paths:
# - build/
reports:
# junit: build/reports/linting.xml
test_and_coverage:
image: cypress/browsers:node-20.12.2-chrome-124.0.6367.155-1-ff-125.0.3-edge-124.0.2478.80-1
stage: test
tags:
- ska-default
before_script:
- rm -rf node_modules
- mkdir -p build/reports
- mkdir -p build/tests
- mkdir -p build/.nyc_output
- yarn install --immutable
script:
- yarn test:cypress:component:ci
- yarn merge-component-reports
- yarn test:coverage:report:ci
- cp build/reports/cobertura-coverage.xml build/tests/e2e-coverage.xml
artifacts:
reports:
coverage_report:
coverage_format: cobertura
path: build/tests/e2e-coverage.xml
junit: build/tests/component-tests.xml, build/tests/e2e-coverage.xml
paths:
- build/
stop-integration-test:
image: $SKA_K8S_TOOLS_BUILD_DEPLOY
stage: test
tags:
- ska-k8s
when: manual
variables:
KUBE_NAMESPACE: 'ci-$CI_PROJECT_NAME-$CI_COMMIT_SHORT_SHA'
script:
- make k8s-uninstall-chart
- kubectl -n $KUBE_NAMESPACE delete pods,svc,daemonsets,deployments,replicasets,statefulsets,cronjobs,jobs,ingresses,configmaps --all
- make k8s-delete-namespace
environment:
name: test/$CI_COMMIT_REF_SLUG
action: stop
# list the current top level dependencies for the project
list_dependencies:
image: node:20.2.0-alpine3.18
stage: test
tags:
- ska-default
allow_failure: true
#cache:
# paths:
# - node_modules/
# policy: pull
script:
- 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
# Build the application
build:
image: node:20.2.0-alpine3.18
stage: build
tags:
- ska-default
cache:
paths:
- node_modules/
policy: pull
script:
- yarn install --immutable
- yarn build
# export the report
pages:
stage: pages
tags:
- ska-default
dependencies:
# - test-counts
- test_and_coverage
- js-e2e-test
# - list_dependencies
- code_quality
script:
- mv public/* .
- cp -r build/* public
- cp -r .public/* public
artifacts:
paths:
- public
expire_in: 30 days
######################### PHT SPECIFIC STUFF BELOW HERE #################################
.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 PHT: "
echo " https://$KUBE_HOST/$KUBE_NAMESPACE/pht"
echo "Backend API:"
echo " https://$KUBE_HOST/$KUBE_NAMESPACE/pht/api/v2/ui/"
xray-publish:
variables:
XRAY_TEST_RESULT_FILE: ctrf/ctrf-report.json
rules:
- if: '$CI_COMMIT_REF_NAME == "main"'
when: always
- if: '$CI_COMMIT_REF_NAME != "main"'
when: manual
.dev_env: &dev_env
variables:
KUBE_NAMESPACE: 'dev-$CI_PROJECT_NAME-$CI_COMMIT_REF_SLUG'
environment:
name: 'dev-$CI_PROJECT_NAME-$CI_COMMIT_REF_SLUG'
info-dev-environment:
<<: *dev_env
script:
- *info_script
info-integration:
script:
- *info_script
info-staging:
script:
- *info_script
deploy-dev-environment:
<<: *dev_env
test-dev-environment:
<<: *dev_env
stop-dev-environment:
<<: *dev_env
helm-chart-build:
allow_failure: true
########################## PHT SPECIFIC STUFF ABOVE HERE #################################
include:
- template: Code-Quality.gitlab-ci.yml
- template: 'Verify/Accessibility.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 finalizers 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'
# Upload BDD test results to JIRA X-ray
- project: 'ska-telescope/templates-repository'
file: 'gitlab-ci/includes/xray-publish.gitlab-ci.yml'
# TS linting and unit testing
- project: 'ska-telescope/templates-repository'
file: 'gitlab-ci/includes/js-lint.gitlab-ci.yml'
- project: 'ska-telescope/templates-repository'
file: 'gitlab-ci/includes/js-e2e-test.gitlab-ci.yml'
js-e2e-test:
variables:
KUBE_HOST: 'http://ingress-nginx-controller-lb-stfc-techops-production-cicd.ingress-nginx.svc.techops.internal.skao.int'
rules:
- exists:
- cypress/**/*.js
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 ska-default 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'