-
Notifications
You must be signed in to change notification settings - Fork 12
/
.gitlab-ci.yml
106 lines (96 loc) · 2.93 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
# Copyright (c), NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
include:
- local: '.common-ci.yml'
default:
tags:
- cnt
- container-dev
- docker/multi-arch
- docker/privileged
- os/linux
- type/docker
golang:lint:
stage: lint
image: golang:1.22.0
needs: []
variables:
GIT_SUBMODULE_STRATEGY: recursive
before_script:
- git config --global --add safe.directory ${PWD}
- git fetch origin main
script:
- make lint
golang:unit-tests:
stage: test
image: golang:1.22.0
needs: []
script:
- go mod download
- make test
coverage: /^total:\s+\(statements\)\s+(\d+(?:\.\d+)?%)$/
helm-lint:
stage: helm-lint
image:
name: alpine/git
entrypoint: ['/usr/bin/env']
before_script:
- apk add --update curl curl-dev openssl bash git openssh make
- curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash
script:
- helm lint deployments/helm/k8s-nim-operator/
# Define the image build targets
.image-build:
stage: image-build
variables:
IMAGE_NAME: "${CI_REGISTRY_IMAGE}/staging/k8s-nim-operator"
VERSION: "v1.0.0"
IMG: "${IMAGE_NAME}:${VERSION}-${CI_COMMIT_SHORT_SHA}"
before_script:
- apk add --no-cache bash make
- 'echo "Logging in to CI registry ${CI_REGISTRY}"'
- docker login -u "${CI_REGISTRY_USER}" -p "${CI_REGISTRY_PASSWORD}" "${CI_REGISTRY}"
script:
- make docker-build
image-build:
extends:
- .image-build
# .release forms the base of the deployment jobs which push images to the CI registry.
.release:
stage: release
variables:
IMAGE_NAME: "${CI_REGISTRY_IMAGE}/staging/k8s-nim-operator"
VERSION: "v1.0.0"
IMG: "${IMAGE_NAME}:${VERSION}-${CI_COMMIT_SHORT_SHA}"
before_script:
- apk add --no-cache bash make
- 'echo "Logging in to CI registry ${CI_REGISTRY}"'
- docker login -u "${CI_REGISTRY_USER}" -p "${CI_REGISTRY_PASSWORD}" "${CI_REGISTRY}"
script:
- make docker-push
# 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}"
release:staging:
extends:
- .release:staging
needs:
- image-build