forked from NVIDIA/gpu-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
135 lines (117 loc) · 4.24 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
variables:
DOCKERHUB: nvidia/gpu-operator
NVCRIO: nvcr.io/nvstaging/cloud-native/gpu-operator
TF_VAR_FILE: "$CI_PROJECT_DIR/tests/terraform.tfvars"
NIGHTLY: "nightly-${CI_COMMIT_SHORT_SHA}"
# Ensure the @OPERATOR_VERSION@ is rewritten before any action is taken
default:
before_script:
- CI_COMMIT_TAG=${CI_COMMIT_TAG:-"${NIGHTLY}"}
- sed -i "s/@OPERATOR_VERSION@/${CI_COMMIT_TAG}/" $(find ./deployments/gpu-operator -type f)
stages:
- gitlab
- unit
- build
- aws_kube_setup
- e2e_tests
- aws_kube_clean
- release
gitlab-builder:
image: docker:stable
stage: gitlab
services:
- docker:stable-dind
script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- apk add --update make
- make devel BUILDER=$CI_REGISTRY_IMAGE:builder
- docker push $CI_REGISTRY_IMAGE:builder
unit-tests:
stage: unit
image: $CI_REGISTRY_IMAGE:builder
script:
- make verify
build-image:
stage: build
image: docker:stable
services:
- docker:stable-dind
script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- apk add --update make
- make image IMAGE=$CI_REGISTRY_IMAGE:$NIGHTLY
- docker push $CI_REGISTRY_IMAGE:$NIGHTLY
e2e_tests:
stage: e2e_tests
image: alpine
script:
- source aws-kube-ci/hostname
- apk add --no-cache openssh-client rsync
- rsync -e "ssh -i aws-kube-ci/key -o StrictHostKeyChecking=no" -av --exclude="vendor/" "${CI_PROJECT_DIR}" "${instance_hostname}:~/"
- rc=0
- (ssh -i aws-kube-ci/key -o StrictHostKeyChecking=no ${instance_hostname} "cd ~/gpu-operator/tests && ./ci-run-e2e.sh ${CI_REGISTRY_IMAGE} ${CI_COMMIT_SHORT_SHA}") || rc=$?
- rsync -e "ssh -i aws-kube-ci/key" -av "${instance_hostname}:/tmp/logs/" logs
- exit $rc
dependencies:
- aws_kube_setup
artifacts:
when: always
paths:
- logs/
include:
project: nvidia/container-infrastructure/aws-kube-ci
file: aws-kube-ci.yml
release-github:
image: docker:stable
services:
- docker:stable-dind
stage: release # Should be after each successful commit
variables:
GIT_STRATEGY: clone
only:
- master
script:
- apk add --update curl openssl bash git openssh make
- curl -L https://git.io/get_helm.sh | bash
- mkdir ~/.ssh && echo "$PRIVATE_SSH_KEY" &> ~/.ssh/id_rsa && chmod 0600 ~/.ssh/id_rsa
- git config --global user.email "[email protected]"
- git config --global user.name "Renaud Gaubert"
# Push Container to Dockerhub
- docker login -u "${REGISTRY_USER}" -p "${REGISTRY_TOKEN}"
- make image IMAGE="${DOCKERHUB}:${CI_COMMIT_TAG}"
- docker push "${DOCKERHUB}:${CI_COMMIT_TAG}"
# Package helm chart
- helm init --client-only
- >
if [[ "${CI_COMMIT_TAG}" != "${NIGHTLY}" ]]; then # this is a tag
helm package --set "operator.repository=nvcr.io/nvidia" \
--set "driver.repository=nvcr.io/nvidia" \
--set "toolkit.repository=nvcr.io/nvidia" \
--set "devicePlugin.repository=nvcr.io/nvidia" \
--set "dcgmExporter.repository=nvcr.io/nvidia" \
--set "dcgmPodExporter.repository=nvcr.io/nvidia" \
deployments/gpu-operator
else
helm package deployments/gpu-operator
fi
- git checkout .
- git fetch origin gh-pages && git checkout gh-pages
- helm repo index . --url https://nvidia.github.io/gpu-operator
- git add ./*.tgz index.yaml
- git commit -m "Release version ${CI_COMMIT_TAG}"
# CI_REPOSITORY_URL=https://gitlab-ci-token:[email protected]/gitlab-examples/ci-debug-trace.git
# should be [email protected]:/gitlab-examples/ci-debug-trace.git
- PUSH_REPO=$(echo "${CI_REPOSITORY_URL}" | sed -e "s|.*@\(.*\)|git@\1|" -e "s|/|:/|" )
- git remote set-url --push origin "${PUSH_REPO}"
- ssh-keyscan gitlab.com >> ~/.ssh/known_hosts
- git push origin gh-pages
release-nvcr:
stage: release
image: docker:stable
only:
- tags # Only when a protected tag is pushed
script:
- apk add --update make
- docker login -u "${NVCRIO_USER}" -p "${NVCRIO_TOKEN}"
- make image IMAGE="${NVCRIO}:${CI_COMMIT_TAG}"
- docker push "${NVCRIO}:${CI_COMMIT_TAG}"