forked from NVIDIA/gpu-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.common-ci.yml
231 lines (203 loc) · 5.61 KB
/
.common-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
default:
image: docker:stable
services:
- name: docker:stable-dind
command: ["--experimental"]
variables:
TF_VAR_FILE: "$CI_PROJECT_DIR/tests/terraform.tfvars"
TF_VAR_project_name: "gpu-operator"
GIT_SUBMODULE_STRATEGY: recursive
stages:
- image
- lint
- go-checks
- go-build
- unit-tests
- build
- tests
- scan
- deploy
- aws_kube_setup
- e2e_tests
- aws_kube_clean
- release
helm-lint:
stage: lint
allow_failure: true
image:
name: alpine/git
entrypoint: ['/usr/bin/env']
before_script:
- apk add --update curl openssl bash git openssh make
- curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash
script:
- helm lint deployments/gpu-operator/
.dev-image:
variables:
IMAGE: "${CI_REGISTRY_IMAGE}"
IMAGE_TAG: "${CI_COMMIT_REF_SLUG}"
build-dev-image:
extends:
- .dev-image
stage: image
script:
- apk --no-cache add make bash
- make .build-image
- docker login -u "${CI_REGISTRY_USER}" -p "${CI_REGISTRY_PASSWORD}" "${CI_REGISTRY}"
- make .push-build-image
.requires-build-image:
image: ${CI_REGISTRY_IMAGE}:${CI_COMMIT_REF_SLUG}-build
.go-check:
extends:
- .requires-build-image
stage: go-checks
fmt:
extends:
- .go-check
script:
- make assert-fmt
vet:
extends:
- .go-check
script:
- make vet
go-lint:
extends:
- .go-check
script:
- make lint
allow_failure: true
ineffassign:
extends:
- .go-check
script:
- make ineffassign
misspell:
extends:
- .go-check
script:
- make misspell
go-build:
extends:
- .requires-build-image
stage: go-build
script:
- make build
unit-tests:
extends:
- .requires-build-image
stage: unit-tests
script:
- make coverage
# Define targets for the gpu-operator and gpu-operator-validator images
.target-gpu-operator:
variables:
TARGET: "ubi8"
IMAGE_NAME: "gpu-operator"
.target-gpu-operator-validator:
variables:
TARGET: "ubi8"
SUBCOMPONENT: "validator"
IMAGE_NAME: "gpu-operator-validator"
# The .build step forms the base of the image builds with each variant
# defined as a build-${VARIANT} step.
.build:
stage: build
variables:
REGISTRY: "${CI_REGISTRY_IMAGE}"
VERSION: "${CI_COMMIT_SHA}"
before_script:
- apk add make
- docker login -u "${CI_REGISTRY_USER}" -p "${CI_REGISTRY_PASSWORD}" "${CI_REGISTRY}"
script:
- make build-${TARGET}
- make push-${TARGET}
build:gpu-operator:
extends:
- .build
- .target-gpu-operator
build:gpu-operator-validator:
extends:
- .build
- .target-gpu-operator-validator
# .deploy forms the base of the deployment jobs which push images to the CI registry.
# This is extended with the version to be deployed (e.g. the SHA or TAG) and the
# target os.
.deploy:
stage: deploy
before_script:
# In the case where we are deploying a different version to the CI_COMMIT_SHA, we
# need to tag the image.
# Note: a leading 'v' is stripped from the version if present
- 'echo Version: ${VERSION} ; [[ -n "${VERSION}" ]] || exit 1'
- apk add --no-cache make bash
- 'echo "Logging in to CI registry ${CI_REGISTRY}"'
- docker login -u "${CI_REGISTRY_USER}" -p "${CI_REGISTRY_PASSWORD}" "${CI_REGISTRY}"
- docker pull "${CI_REGISTRY_IMAGE}/${IMAGE_NAME}:${CI_COMMIT_SHA}-${TARGET}"
script:
- docker tag "${CI_REGISTRY_IMAGE}/${IMAGE_NAME}:${CI_COMMIT_SHA}-${TARGET}" "${OUT_IMAGE}:${VERSION}-${TARGET}"
# Log in to the "output" registry, tag the image and push the image
- 'echo "Logging in to output registry ${OUT_REGISTRY}"'
- docker logout
- docker login -u "${OUT_REGISTRY_USER}" -p "${OUT_REGISTRY_TOKEN}" "${OUT_REGISTRY}"
- make IMAGE=${OUT_IMAGE} VERSION=${VERSION} push-${TARGET}
# .deploy:sha sets the internal deployment version to the git SHA and deploys to the CI
# container registry
.deploy:sha-ci:
extends: .deploy
variables:
VERSION: "${CI_COMMIT_SHA}"
OUT_REGISTRY_USER: "${CI_REGISTRY_USER}"
OUT_REGISTRY_TOKEN: "${CI_REGISTRY_PASSWORD}"
OUT_REGISTRY: "${CI_REGISTRY}"
OUT_IMAGE: "${CI_REGISTRY_IMAGE}/${IMAGE_NAME}"
deploy:sha-ci-gpu-operator:
extends:
- .deploy:sha-ci
- .target-gpu-operator
dependencies:
- build:gpu-operator
deploy:sha-ci-gpu-operator-validator:
extends:
- .deploy:sha-ci
- .target-gpu-operator-validator
dependencies:
- build:gpu-operator-validator
# A release job is a deployment job that has a different output version / image
.release:
extends: .deploy
stage: release
variables:
# We use the CI_COMMIT_SHORT_SHA and override this for external releases
VERSION: "${CI_COMMIT_SHORT_SHA}"
# Define a staging release step that pushes an image to an internal "staging" repository
# This is triggered for all pipelines (i.e. not only tags) to test the pipeline steps
# outside of the release process.
.release:staging:
extends: .release
variables:
OUT_REGISTRY_USER: "${CI_REGISTRY_USER}"
OUT_REGISTRY_TOKEN: "${CI_REGISTRY_PASSWORD}"
OUT_REGISTRY: "${CI_REGISTRY}"
OUT_IMAGE: "${CI_REGISTRY_IMAGE}/staging/${IMAGE_NAME}"
.release:external:
extends: .release
rules:
- if: $CI_COMMIT_TAG
variables:
VERSION: "${CI_COMMIT_TAG}"
- if: $CI_COMMIT_BRANCH == $RELEASE_DEVEL_BRANCH
variables:
VERSION: "${RELEASE_DEVEL_TAG}"
release:staging-gpu-operator:
extends:
- .release:staging
- .target-gpu-operator
dependencies:
- deploy:sha-ci-gpu-operator
release:staging-gpu-operator-validator:
extends:
- .release:staging
- .target-gpu-operator-validator
dependencies:
- deploy:sha-ci-gpu-operator-validator