forked from NVIDIA/gpu-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
104 lines (91 loc) · 3.73 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
variables:
DOCKERHUB: nvidia/gpu-operator
NVCRIO: nvcr.io/nvstaging/cloud-native/gpu-operator
TF_VAR_FILE: "$CI_PROJECT_DIR/tests/terraform.tfvars"
NIGHTLY: "1.0.0-nightly-${CI_COMMIT_SHORT_SHA}"
# Ensure the @OPERATOR_VERSION@ is rewritten before any action is taken
default:
before_script:
- if [ -z "${CI_COMMIT_TAG}" ]; then SUBCHART_DIR="nightly" ; else SUBCHART_DIR="stable"; fi
- CI_COMMIT_TAG=${CI_COMMIT_TAG:-"${NIGHTLY}"}
- echo "${CI_COMMIT_TAG}" | grep -qe '^[0-9]\+\.[0-9]\+\.[0-9]\+\(-[^+]\+\)\?\(+.*\)\?$' # check that tag follows SemVer 2.0 form
stages:
- aws_kube_setup
- e2e_tests
- aws_kube_clean
unit-tests:
stage: aws_kube_setup
image: docker:stable
services:
- docker:stable-dind
script:
- apk add --update make
- make devel-image IMAGE=nvidia/gpu-operator TAG_DEVEL=devel
- docker run -t nvidia/gpu-operator:devel make verify
build-image:
stage: aws_kube_setup
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 prod-image IMAGE=$CI_REGISTRY_IMAGE TAG=$CI_COMMIT_TAG
- docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_TAG"
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_TAG}") || 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
ref: 20.05.05
release-github:
image: docker:stable
services:
- docker:stable-dind
stage: aws_kube_clean # Should be after each successful commit
variables:
GIT_STRATEGY: clone
only:
- master
- tags
script:
- apk add --update curl openssl bash git openssh make
- curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | 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}"
- docker pull "$CI_REGISTRY_IMAGE:$CI_COMMIT_TAG"
- docker tag "$CI_REGISTRY_IMAGE:$CI_COMMIT_TAG" "$DOCKERHUB:$CI_COMMIT_TAG"
- docker push "${DOCKERHUB}:${CI_COMMIT_TAG}"
# Package helm chart
- mkdir -p "${SUBCHART_DIR}"
- REPOSITORY="$(dirname "${CI_REGISTRY_IMAGE}")"
- helm package --version "${CI_COMMIT_TAG}" --app-version "${CI_COMMIT_TAG}" -d "${SUBCHART_DIR}" deployments/gpu-operator
- git checkout .
- git fetch origin gh-pages && git checkout gh-pages
- helm repo index ${SUBCHART_DIR} --url https://nvidia.github.io/gpu-operator/${SUBCHART_DIR}
- git add $(find . ${SUBCHART_DIR} -maxdepth 1 -name "*.tgz" -o -name 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