-
Notifications
You must be signed in to change notification settings - Fork 181
/
.gitlab-ci.yml
158 lines (148 loc) · 4.7 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
stages:
- unit-test
- build
- deploy-dev
- e2e-tests-dev
- deploy-staging
- tests-staging
- prod-rollout
- cleanup-dev
run-unit-tests:
stage: unit-test
# This resource group is configured with process_mode=oldest_first to make sure the pipelines are run serially.
resource_group: production
# A copy of golang image in dockerhub.
image: $CNS_IMAGE_GOLANG
script:
- make test
build-images:
stage: build
# This resource group is configured with process_mode=oldest_first to make sure the pipelines are run serially.
resource_group: production
# A copy of docker image in dockerhub.
image: $CNS_IMAGE_DOCKER
services:
# A copy of docker-dind image in dockerhub.
- $CNS_IMAGE_DOCKER_DIND
variables:
DOCKER_HOST: tcp://localhost:2376
DOCKER_TLS_CERTDIR: "/certs"
DOCKER_TLS_VERIFY: 1
DOCKER_CERT_PATH: "$DOCKER_TLS_CERTDIR/client"
before_script:
# Sleep is needed to make sure that the docker engine is up.
- sleep 60
- docker info
- docker login $CNS_DOCKER_REGISTRY -u $REGISTRY_USER -p $REGISTRY_PWD
script:
- sed -i "s#ARG GOLANG_IMAGE=.*#ARG GOLANG_IMAGE=$CNS_IMAGE_GOLANG#g" images/driver/Dockerfile
- sed -i "s#ARG GOLANG_IMAGE=.*#ARG GOLANG_IMAGE=$CNS_IMAGE_GOLANG#g" images/syncer/Dockerfile
- docker build -f images/driver/Dockerfile -t $CNS_CSI_DRIVER_REPO:$CI_COMMIT_SHORT_SHA --build-arg "VERSION=$CI_COMMIT_SHORT_SHA" --build-arg "GOPROXY=https://proxy.golang.org" .
- docker build -f images/syncer/Dockerfile -t $CNS_CSI_SYNCER_REPO:$CI_COMMIT_SHORT_SHA --build-arg "VERSION=$CI_COMMIT_SHORT_SHA" --build-arg "GOPROXY=https://proxy.golang.org" .
- docker push $CNS_CSI_DRIVER_REPO:$CI_COMMIT_SHORT_SHA
- docker push $CNS_CSI_SYNCER_REPO:$CI_COMMIT_SHORT_SHA
- echo "VSPHERE_CSI_CONTROLLER_IMAGE=$CNS_CSI_DRIVER_REPO:$CI_COMMIT_SHORT_SHA" >> build.env
- echo "VSPHERE_SYNCER_IMAGE=$CNS_CSI_SYNCER_REPO:$CI_COMMIT_SHORT_SHA" >> build.env
artifacts:
reports:
dotenv: build.env
deploy-images-dev:
stage: deploy-dev
# This resource group is configured with process_mode=oldest_first to make sure the pipelines are run serially.
resource_group: production
# Image built from cd-infra/images/ci-deploy/Dockerfile.
image: $CNS_IMAGE_CI_DEPLOY_STAGE
script:
- ./pipeline/deploy.sh
dependencies:
- build-images
artifacts:
paths:
- ./env.json
- ./sv_kubeconfig_content.yaml
reports:
dotenv: build.env
e2e-tests-dev:
stage: e2e-tests-dev
# This resource group is configured with process_mode=oldest_first to make sure the pipelines are run serially.
resource_group: production
# Image built by docker file images/ci/e2e/Dockerfile.
# Command to build new image is
# docker build -t <image-name:version> --platform=Linux/x86_64 -f Dockerfile .
# docker tag <image-name:version> <repo>/<image-name:version>
# docker push <repo>/<image-name:version>
image: $CSI_FVT_GOLANG
dependencies:
- deploy-images-dev
script:
- ./pipeline/e2e-tests.sh
artifacts:
paths:
- ./env.json
- ./sv_kubeconfig_content.yaml
reports:
dotenv: build.env
deploy-images-staging:
stage: deploy-staging
# Image built from cd-infra/images/ci-deploy/Dockerfile.
image: $CNS_IMAGE_CI_DEPLOY_STAGE
script:
- ./pipeline/deploy-staging.sh
dependencies:
- build-images
only:
- master
e2e-tests-staging:
stage: tests-staging
# Image built by docker file images/ci/e2e/Dockerfile.
# Command to build new image is
# docker build -t <image-name:version> --platform=Linux/x86_64 -f Dockerfile .
# docker tag <image-name:version> <repo>/<image-name:version>
# docker push <repo>/<image-name:version>
image: $CSI_FVT_GOLANG
dependencies:
- deploy-images-staging
script:
- ./pipeline/e2e-tests-staging.sh
only:
- master
system-tests-staging:
stage: tests-staging
# Image built from cd-infra//images/ci-e2e/Dockerfile.
image: $CNS_IMAGE_E2E
dependencies:
- deploy-images-staging
script:
- echo "TODO - Add system tests."
only:
- master
perf-tests-staging:
stage: tests-staging
# Image built from cd-infra//images/ci-e2e/Dockerfile.
image: $CNS_IMAGE_E2E
dependencies:
- deploy-images-staging
script:
- echo "TODO - Add perf tests."
only:
- master
patch-prod-images:
stage: prod-rollout
# Image built from cd-infra/images/ci-deploy/Dockerfile
image: $CNS_IMAGE_CI_DEPLOY_STAGE
script:
- ./pipeline/patch-prod.sh
dependencies:
- build-images
only:
- master
cleanup-dev:
stage: cleanup-dev
image: $CNS_IMAGE_CI_DEPLOY_STAGE
when: always
artifacts:
reports:
dotenv: build.env
script:
- chmod 777 pipeline/release-testbed.sh
- ./pipeline/release-testbed.sh