-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
201 lines (182 loc) · 5.51 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
# 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_DOCKER_BUILDER_IMAGE
variables:
CHARTS_TO_PUBLISH: ska-mid-cbf ska-mid-cbf-tmleafnode
# Standardised included jobs
include:
# Helm Chart Publish
# https://developer.skatelescope.org/en/latest/development/software_package_release_procedure.html#package-and-publish-helm-charts-to-the-ska-helm-chart-repository
- project: 'ska-telescope/templates-repository'
file: 'gitlab-ci/includes/helm_publish.yml'
# Create Gitlab CI badges from CI metrics
# https://developer.skatelescope.org/en/latest/tools/continuousintegration.html#automated-collection-of-ci-health-metrics-as-part-of-the-ci-pipeline
- project: 'ska-telescope/templates-repository'
file: 'gitlab-ci/includes/post_step.yml'
# Application image publish
- project: 'ska-telescope/templates-repository'
file: 'gitlab-ci/includes/build_push.yml'
# Application package publish
- project: 'ska-telescope/templates-repository'
file: 'gitlab-ci/includes/build_wheel.yml'
# cache is used to specify a list of files and directories which should be cached between jobs. You can only use paths that are within the project workspace.
# If cache is defined outside the scope of jobs, it means it is set globally and all jobs will use that definition
cache:
paths:
- build
# 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:
- linting
- build_for_test
- test
- build
- publish
- pages
.install_pip: &install_pip |-
apt-get -y update && apt-get install -yq curl python3-distutils
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py && python3 get-pip.py
clean shell runner:
stage: .pre
tags:
- k8srunner
script:
# Gitlab CI badges creation
- pwd
- ls -lR
- rm -rf build/*
# linting stage for branches
linting:
stage: linting
image: artefact.skao.int/ska-tango-images-pytango-builder:9.3.10
tags:
- k8srunner
artifacts:
paths:
- ./build/
script:
- apt-get --allow-releaseinfo-change update
- apt-get -y update
- apt-get install -y python3-pip python3-setuptools python3-wheel --no-install-recommends
- python3 -m pip install pylint2junit
- python3 -m pip install -r requirements.txt
- mkdir -p build/reports
- pylint --output-format=parseable src | tee ./build/mid-cbf-code-analysis.stdout
- pylint --output-format=pylint2junit.JunitReporter src > ./build/reports/linting.xml
- ls -alR
# build and push image on gitlab container registry
# image is used to run integration tests in k8s environment
build-for-test:
stage: build_for_test
image: $SKA_K8S_TOOLS_DOCKER_BUILDER_IMAGE
tags:
- k8srunner
script:
- export IMG="$CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA"
- echo $IMG
- docker build -t "$IMG" .
- echo $CI_REGISTRY
- echo $CI_REGISTRY_IMAGE
- echo -n "$CI_REGISTRY_PASSWORD" | docker login -u "$CI_REGISTRY_USER" --password-stdin $CI_REGISTRY
- docker push $IMG
.test:
stage: test
artifacts:
paths:
- ./build/
unit:
extends: .test
image: artefact.skao.int/ska-tango-images-tango-itango:9.3.5
dependencies:
- build-for-test
tags:
- k8srunner
script:
- make requirements
- make unit_test
environment:
name: test
artifacts:
paths:
- build/
allow_failure: true
integration:
extends: .test
image: $SKA_K8S_TOOLS_DEPLOY_IMAGE
# stage: test
# variables:
# MINIKUBE: "false"
dependencies:
- build-for-test
tags:
- k8srunner
script:
- export KUBE_NAMESPACE="ci-$CI_PROJECT_NAME-$CI_COMMIT_SHORT_SHA"
- make clean
- make k8s
- make test
environment:
name: test
after_script:
- export KUBE_NAMESPACE="ci-$CI_PROJECT_NAME-$CI_COMMIT_SHORT_SHA"
- make describe
- ls -lR
- pwd
- make uninstall-chart
- make delete_namespace
artifacts:
paths:
- ./build/
# Build the docker image and push to artefact repository
# Use script given by System Team
# build:
# only:
# refs:
# - tags
# publish-image:
# stage: publish
# image: nexus.engageska-portugal.pt/ska-docker/deploy:0.4.3
# before_script:
# - docker login -u $DOCKER_REGISTRY_USERNAME -p $DOCKER_REGISTRY_PASSWORD $DOCKER_REGISTRY_HOST
# tags:
# - k8srunner
# script:
# - make build
# - make push
# when: on_success
# only:
# refs:
# - tags
# publish helm charts, runs only for tags
# publish-chart:
# variables:
# CHARTS_TO_PUBLISH: ska-mid-cbf ska-mid-cbf-tmleafnode
# when: manual
# only:
# refs:
# - tags
pages:
stage: pages
dependencies:
- integration
# tags:publish-chart:
# variables:
# CHARTS_TO_PUBLISH: ska-mid-cbf ska-mid-cbf-tmleafnode
# when: manual
# only:
# refs:
# - tags
tags:
- k8srunner
script:
- pwd
- ls -lR
- cp -R build/ public/
- ls -lR public
artifacts:
paths:
- public
expire_in: 30 days