-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
120 lines (105 loc) · 4.02 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
# GitLab CI in conjunction with GitLab Runner can use Docker Engine to test and build any application.
# Docker, when used with GitLab CI, runs each job in a separate and isolated container using the predefined image that is set up in .gitlab-ci.yml.
# In this case we use the latest python docker image to build and test this project.
image: $SKA_K8S_TOOLS_BUILD_DEPLOY
default:
tags:
- k8srunner
# Standardised included jobs
variables:
CHARTS_TO_PUBLISH: ska-oso-oet
GIT_SUBMODULE_STRATEGY: recursive
# The YAML file defines a set of jobs with constraints stating when they should be run.
# You can specify an unlimited number of jobs which are defined as top-level elements with an arbitrary name and always have to contain at least the script clause.
# In this case we have only the test job which produce an artifacts (it must be placed into a directory called "public")
# It is also specified that only the master branch will be subject of this job.
stages:
- build
- test
- deploy # this is the name of the dev environment stage in the ST template
- cleanup
- lint
- publish
- integration
- staging
- pages
- scan
test-chart-templates:
stage: test
variables:
MINIKUBE: "false"
tags:
- k8srunner
image: $SKA_K8S_TOOLS_DEPLOY_IMAGE
script:
- helm plugin install https://github.com/helm-unittest/helm-unittest.git
- make k8s-chart-test
- mkdir -p ./build/reports
- mv charts/build/chart_template_tests.xml ./build/reports/chart_template_tests.xml
artifacts:
name: "$CI_PROJECT_NAME-$CI_JOB_ID"
paths:
- "build/"
reports:
junit: build/reports/chart_template_tests.xml
# The info script in the templates is for a generic tango environment. We overwrite it to give more useful information
.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 "Address to connect to the deployment of the OET API: "
echo " https://k8s.stfc.skao.int/$KUBE_NAMESPACE/oet/api/v6"
echo "Address to connect to the Swagger UI for the deployment: "
echo " https://k8s.stfc.skao.int/$KUBE_NAMESPACE/oet/api/v6/ui/"
# Currently, the dev template uses ci-dev-$CI_PROJECT_NAME which means only one branch can be deployed at a time, so we overwrite this
.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"
deploy-dev-environment:
<<: *dev_env
needs:
- oci-image-build
test-dev-environment:
<<: *dev_env
info-dev-environment:
<<: *dev_env
script:
- *info_script
stop-dev-environment:
<<: *dev_env
info-integration:
script:
- *info_script
info-staging:
script:
- *info_script
include:
# Python
- project: "ska-telescope/templates-repository"
file: "gitlab-ci/includes/python.gitlab-ci.yml"
# OCI
- project: "ska-telescope/templates-repository"
file: "gitlab-ci/includes/oci-image.gitlab-ci.yml"
# Helm Chart linting and Publish
- project: 'ska-telescope/templates-repository'
file: 'gitlab-ci/includes/helm-chart.gitlab-ci.yml'
# k8s steps
- project: 'ska-telescope/templates-repository'
file: 'gitlab-ci/includes/k8s.gitlab-ci.yml'
# Docs pages
- project: 'ska-telescope/templates-repository'
file: 'gitlab-ci/includes/docs.gitlab-ci.yml'
# .post step finalisers eg: badges
- project: "ska-telescope/templates-repository"
file: "gitlab-ci/includes/finaliser.gitlab-ci.yml"
# Tag Based GitLab Release Management
- project: 'ska-telescope/templates-repository'
file: 'gitlab-ci/includes/release.gitlab-ci.yml'
# change log and release notes
- project: "ska-telescope/templates-repository"
file: "gitlab-ci/includes/changelog.gitlab-ci.yml"
# deploy steps
- project: 'ska-telescope/templates-repository'
file: 'gitlab-ci/includes/deploy.gitlab-ci.yml'