-
Notifications
You must be signed in to change notification settings - Fork 2
/
.gitlab-ci.yml
277 lines (266 loc) · 9.05 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
stages:
- prepare
- build
- test
- deploy
variables:
GIT_SUBMODULE_STRATEGY: recursive
VIRTER_VERSION: v0.28.0
VMSHED_VERSION: v0.22.1
KUSTOMIZE_VERSION: v5.5.0
K8S_TEST_VERSION: v2.7.4
HELM_VERSION: v3.16.2
prepare-bins:
rules:
- if: $CI_COMMIT_TAG
- if: $CI_MERGE_REQUEST_ID
- if: $CI_COMMIT_BRANCH == 'master'
- if: $CI_COMMIT_BRANCH == 'v2'
image: ${LINBIT_DOCKER_REGISTRY}/build-helpers:latest
stage: prepare
script:
- . /usr/local/bin/gitlab-utils.sh
- ci_prepare_tools
- ci_fetch_binary virter virter-$VIRTER_VERSION https://github.com/LINBIT/virter/releases/download/$VIRTER_VERSION/virter-linux-amd64
- ci_fetch_binary vmshed vmshed-$VMSHED_VERSION https://github.com/LINBIT/vmshed/releases/download/$VMSHED_VERSION/vmshed-linux-amd64
- ci_fetch_binary create-k8s-test-configs create-k8s-test-configs-$K8S_TEST_VERSION $LINBIT_REGISTRY_URL/repository/tools/create-k8s-test-configs:$K8S_TEST_VERSION
- ci_fetch_tar kustomize-$KUSTOMIZE_VERSION "https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize%2F${KUSTOMIZE_VERSION}/kustomize_${KUSTOMIZE_VERSION}_linux_amd64.tar.gz" -z
- ci_fetch_tar helm-$HELM_VERSION "https://get.helm.sh/helm-${HELM_VERSION}-linux-amd64.tar.gz" -z
cache:
key: bin-$VIRTER_VERSION-$VMSHED_VERSION-$K8S_TEST_VERSION-$KUSTOMIZE_VERSION-$HELM_VERSION
paths:
- download
artifacts:
paths:
- download
- bin
build_operator:
image: ${LINBIT_DOCKER_REGISTRY}/container-tools:latest
variables:
TAG: v2-dev-${CI_COMMIT_SHORT_SHA}
VERSION: $TAG-$CI_COMMIT_SHA
NOCACHE: "false"
PLATFORMS: ${PUBLISH_PLATFORMS}
REGISTRY: ${LINBIT_DOCKER_REGISTRY}/linstor-operator-test
rules:
- if: $CI_COMMIT_TAG
variables:
TAG: $CI_COMMIT_TAG
NOCACHE: "true"
- if: $CI_MERGE_REQUEST_ID
- if: $CI_COMMIT_BRANCH == 'master'
- if: $CI_COMMIT_BRANCH == 'v2'
stage: build
script:
- docker buildx bake --pull --push --no-cache=$NOCACHE
- echo "OPERATOR_IMAGE=$LINBIT_DOCKER_REGISTRY/linstor-operator-test/linstor-operator:$TAG" > .build.env
artifacts:
reports:
dotenv:
- .build.env
build_static_deployment:
image:
name: python:3
entrypoint: [""]
rules:
- if: $CI_COMMIT_TAG
- if: $CI_MERGE_REQUEST_ID
- if: $CI_COMMIT_BRANCH == 'master'
- if: $CI_COMMIT_BRANCH == 'v2'
stage: build
before_script:
- mkdir -p .cache/pip
- pip install --cache-dir .cache/pip pyyaml
script:
- bin/kustomize build ./deploy/default > static-deployment.yaml
- hack/get-image-list.py static-deployment.yaml > image.list
cache:
paths:
- .cache/pip
artifacts:
paths:
- static-deployment.yaml
- image.list
build_helm_deployment:
image:
name: python:3
entrypoint: [""]
rules:
- if: $CI_COMMIT_TAG
- if: $CI_MERGE_REQUEST_ID
- if: $CI_COMMIT_BRANCH == 'master'
- if: $CI_COMMIT_BRANCH == 'v2'
stage: build
script:
- bin/helm package charts/linbit-sds charts/linstor-operator
cache:
artifacts:
paths:
- "*.tgz"
container_scanning:
stage: test
rules:
- if: $CI_MERGE_REQUEST_ID
- if: $CI_COMMIT_BRANCH == 'master'
- if: $CI_COMMIT_BRANCH == 'v2'
- if: $CI_COMMIT_TAG
image:
name: docker.io/aquasec/trivy:latest
entrypoint: [""]
script:
- trivy --version
- trivy image --exit-code 0 --format template --template "@/contrib/html.tpl" -o container-scan.html "$OPERATOR_IMAGE"
# Prints full report
- trivy image --exit-code 0 "$OPERATOR_IMAGE"
# Fail on critical (unfixed) vulnerabilities
- trivy image --exit-code 1 --ignore-unfixed --severity CRITICAL "$OPERATOR_IMAGE"
# Ideally, we would use container_scanning for the artifact here. That is currently a paid feature, so we have to use code quality
artifacts:
when: always
expose_as: "Container Scan"
paths:
- container-scan.html
.test:
stage: test
script:
- set -ex
- export PATH=$CI_PROJECT_DIR/bin:$PATH
- create-k8s-test-configs -stable-releases-to-check=$RELEASES_TO_CHECK -include-next=$INCLUDE_NEXT -base-image=alma-9 -output-dir=.
- ( cd deploy/default ; kustomize edit set image controller=$OPERATOR_IMAGE ; kustomize edit add patch --kind Deployment --name controller-manager --patch '[{"op":"add","path":"/spec/template/spec/containers/0/args/-","value":"--linstor-node-cache-duration=15s"}]' )
- >
vmshed
--error-details=false
--nvms $(( ${LINBIT_CI_MAX_CPUS:-20} / 3 ))
--pull-template "${LINBIT_DOCKER_REGISTRY}/vm/{{ .Image }}:latest"
--variant "$VARIANT"
--torun "$TO_RUN"
--set values.DockerRegistryMirror=https://${DOCKER_REGISTRY_MIRROR}
--set values.DrbdRegistryMirror=https://${DRBD_REGISTRY_MIRROR}
--set values.K8sGcrIoMirror=https://${K8S_REGISTRY_MIRROR}
--set values.RegistryK8sIoMirror=https://${REGISTRY_K8S_IO_MIRROR}
--set values.DrbdIoUser=${PUBLISH_REGISTRY_USER}
--set values.DrbdIoPassword=${PUBLISH_REGISTRY_PASSWORD}
--set values.JustKubeadmImage=${LINBIT_DOCKER_REGISTRY}/linstor-kubernetes-tests/just-kubeadm:${K8S_TEST_VERSION}
--set values.HelmImage=${LINBIT_DOCKER_REGISTRY}/linstor-kubernetes-tests/helm:${K8S_TEST_VERSION}
--set values.TestImage=${LINBIT_DOCKER_REGISTRY}/linstor-kubernetes-tests/tests:${K8S_TEST_VERSION}
--set values.DeploymentVersion=v2
--set values.DeploymentV2Source=/virter/workspace/deploy/default
--set "values.Skip=$SKIP"
--set "values.Focus=$FOCUS"
artifacts:
when: always
paths:
- tests-out/
reports:
junit:
# These reports are created by vmshed, reporting if the test command itself succeeded.
- tests-out/test-results/*.xml
# These reports are created by the test binaries, holding details about all tests that ran.
- tests-out/log/**/*-report.xml
test-fast:
tags:
- libvirt-xs
extends: .test
rules:
- if: $CI_MERGE_REQUEST_ID
- if: $CI_COMMIT_BRANCH == 'master'
- if: $CI_COMMIT_BRANCH == 'v2'
- if: $CI_COMMIT_TAG
timeout: 1h
variables:
TO_RUN: operator
VARIANT: dualstack
RELEASES_TO_CHECK: "4"
INCLUDE_NEXT: "true"
test-full:
tags:
- libvirt
timeout: 8h
extends: .test
rules:
- if: $CI_MERGE_REQUEST_ID
when: manual
allow_failure: true
- if: $CI_COMMIT_BRANCH == 'v2'
when: manual
allow_failure: true
- if: $CI_COMMIT_TAG
when: manual
allow_failure: true
variables:
RELEASES_TO_CHECK: "4"
INCLUDE_NEXT: "true"
SKIP: "Slow|LinuxOnly|xfs|ext3|ext4|immediate-binding|retain policy|readOnly|read-only|exec|multiple|subPath"
VARIANT: "ipv4,ipv6,dualstack"
publish-image:
stage: deploy
image: ${LINBIT_DOCKER_REGISTRY}/container-tools:latest
variables:
DOCKER_AUTH_CONFIG_FROM: DOCKER_PUBLISH_AUTH_CONFIG_FILE
REGISTRY: ${PUBLISH_REGISTRY}
PLATFORMS: ${PUBLISH_PLATFORMS}
TAG: v2-dev-${CI_COMMIT_SHORT_SHA}
VERSION: $TAG-$CI_COMMIT_SHA
rules:
- if: $CI_COMMIT_BRANCH == 'v2'
when: manual
allow_failure: true
- if: $CI_COMMIT_TAG
variables:
TAG: $CI_COMMIT_TAG
script:
- docker buildx bake --pull --push
publish-config:
stage: deploy
image:
name: python:3
rules:
- if: $CI_COMMIT_TAG
variables:
RELEASE_VERSION: $CI_COMMIT_TAG
- if: $CI_COMMIT_BRANCH == 'v2'
when: manual
allow_failure: true
variables:
RELEASE_VERSION: v2.99.0+$CI_COMMIT_REF_SLUG.$CI_COMMIT_SHORT_SHA
- if: $CI_MERGE_REQUEST_ID
when: manual
allow_failure: true
variables:
RELEASE_VERSION: v2.99.0+$CI_COMMIT_REF_SLUG.$CI_COMMIT_SHORT_SHA
variables:
UPSTREAM: git@github.com:LINBIT/linstor-operator-builder.git
GIT_AUTHOR_NAME: LinbitPRBot
GIT_COMMITTER_NAME: LinbitPRBot
GIT_AUTHOR_EMAIL: linbitprbot@users.noreply.github.com
GIT_COMMITTER_EMAIL: linbitprbot@users.noreply.github.com
before_script:
- mkdir -p .cache/pip
- pip install --cache-dir .cache/pip pyyaml semver
script:
- mkdir -p $HOME/.ssh
- ln -snf $GITHUB_KNOWN_HOSTS $HOME/.ssh/known_hosts
- eval $(ssh-agent -s)
- cat $GITHUB_DEPLOY_KEY | ssh-add -
- git clone -b gh-pages --single-branch --depth=1 "$UPSTREAM" gh-pages
- mkdir -p gh-pages/static
- cp --no-clobber -t gh-pages *.tgz
- cp static-deployment.yaml "gh-pages/static/$RELEASE_VERSION.yaml"
- cp image.list "gh-pages/static/$RELEASE_VERSION.image-list.txt"
- ln -snf "$RELEASE_VERSION.yaml" "gh-pages/static/latest.yaml"
- ln -snf "$RELEASE_VERSION.image-list.txt" "gh-pages/static/latest.image-list.txt"
- hack/generate-release-info.py gh-pages/static | tee gh-pages/content/releases.json
- bin/helm repo index --url https://charts.linstor.io gh-pages
- git -C gh-pages add .
- git -C gh-pages diff --staged
- if [ -n "$CI_COMMIT_TAG" ]; then
- git -C gh-pages commit -m "Release $RELEASE_VERSION"
- git -C gh-pages push "$UPSTREAM" gh-pages:gh-pages
- fi
cache:
paths:
- .cache/pip
artifacts:
paths:
- gh-pages/static
- gh-pages/content