This repository has been archived by the owner on Feb 16, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy path.evergreen.yaml
291 lines (264 loc) · 8.65 KB
/
.evergreen.yaml
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
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
---
functions:
"fetch_source":
- command: git.get_project
params:
directory: src/atlas-service-broker
- command: shell.exec
params:
script: mkdir bin
"go_unit_tests":
- command: shell.exec
type: system
params:
working_dir: src/atlas-service-broker
script: |
go test -v ./pkg/... | tee unit_result.suite
- command: gotest.parse_files
params:
files: ["src/atlas-service-broker/unit_result.suite"]
"go_vet":
- command: shell.exec
type: system
params:
working_dir: src/atlas-service-broker
script: |
go vet ./...
"setup_snyk":
- command: shell.exec
type: system
params:
script: |
mkdir bin
curl -L -o bin/snyk https://github.com/snyk/snyk/releases/download/v1.216.0/snyk-linux
chmod +x bin/snyk
"snyk_snapshot":
- command: shell.exec
type: system
params:
working_dir: src/atlas-service-broker
script: |
export PATH="${workdir}/bin:$PATH"
snyk auth ${snyk-evergreen-upload-atlas-service-broker}
snyk monitor
"integration_tests":
- command: shell.exec
params:
working_dir: src/atlas-service-broker
script: |
export ATLAS_BASE_URL=${atlas_base_url}
export ATLAS_GROUP_ID=${atlas_group_id}
export ATLAS_PUBLIC_KEY=${atlas_public_key}
export ATLAS_PRIVATE_KEY=${atlas_private_key}
go test -timeout 1h -v ./test/integration | tee int_result.suite
- command: gotest.parse_files
params:
files: ["src/atlas-service-broker/int_result.suite"]
"get_tagged_version":
- command: shell.exec
params:
working_dir: src/atlas-service-broker
script: |
# Get version from tag on head and throw error if none exists
# Remove the character v at the beginning of the string if any, and keep the rest
export VERSION=$(git tag -l --points-at HEAD | sed 's/^v\(.*\)/\1/')
[[ -z "$VERSION" ]] && { echo "No version tag on HEAD" ; exit 1; }
echo "version: \"$VERSION\"" > version_expansion.yaml
- command: expansions.update
params:
ignore_missing_file: true
file: src/atlas-service-broker/version_expansion.yaml
"build_binaries":
- command: shell.exec
params:
working_dir: src/atlas-service-broker
script: |
./dev/scripts/build-production-binary.sh artifacts/atlas-service-broker-linux-arm64-${version}
# Upload integration test binary to S3. MMS will use this binary as part of the Atlas test suite.
"upload_test_binary":
- command: shell.exec
params:
working_dir: src/atlas-service-broker
script: |
# Output build info to metadata file
echo '{ "master": { "int_test": "artifacts/${revision}/int-test", "git_hash": "${revision}" } }' > builds.json
go test -v -timeout 1h -c -o artifacts/${revision}/int-test ./test/integration
- command: s3.put
params:
aws_key: ${aws_key}
aws_secret: ${aws_secret}
local_file: src/atlas-service-broker/artifacts/${revision}/int-test
remote_file: atlas-service-broker/artifacts/${revision}/int-test
bucket: mciuploads
content_type: application/octet-stream
permissions: public-read
- command: s3.put
params:
aws_key: ${aws_key}
aws_secret: ${aws_secret}
local_file: src/atlas-service-broker/builds.json
remote_file: atlas-service-broker/builds.json
bucket: mciuploads
content_type: application/json
permissions: public-read
"setup_hub":
- command: shell.exec
params:
script: |
curl -LO https://github.com/github/hub/releases/download/v2.12.3/hub-linux-amd64-2.12.3.tgz
tar -zxvf hub-linux-amd64-2.12.3.tgz
mv hub-linux-amd64-2.12.3/bin/hub bin/
echo "Installed Hub CLI"
"publish_github_release":
- command: shell.exec
params:
working_dir: src/atlas-service-broker
script: |
export GITHUB_TOKEN=${github_token}
# Get all artifacts and turn them into a list with --attach flags
ARTIFACTS_ATTACH=$(ls artifacts | xargs -I {} echo "--attach artifacts/{} ")
export ARTIFACTS_ATTACH
${workdir}/bin/hub release create --message "Atlas Service Broker ${version}" $ARTIFACTS_ATTACH v${version}
"setup_docker":
- command: shell.exec
params:
script: |
sudo pacman --refresh --noconfirm -S community/docker
systemctl start docker.service
"teardown_docker":
- command: shell.exec
params:
script: |
# Remove all Docker images
docker rmi -f $(docker images -a -q) &> /dev/null || true
"build_docker":
- command: shell.exec
params:
working_dir: src/atlas-service-broker
script: |
docker build . -t ${docker_repo}/${docker_name}
"publish_docker":
- command: shell.exec
params:
working_dir: src/atlas-service-broker
script: |
docker login --username ${docker_username} --password ${docker_password} ${docker_repo}
docker image tag ${docker_repo}/${docker_name} ${docker_repo}/${docker_name}:${version}
docker push ${docker_repo}/${docker_name}:${version}
# Tag image as "latest" if version is stable.
if [[ ${version} =~ [0-9]+.[0-9]+.[0-9]+$ ]]; then
docker image tag ${docker_repo}/${docker_name}:${version} ${docker_repo}/${docker_name}:latest
docker push ${docker_repo}/${docker_name}:latest
fi
"setup_kubernetes":
- command: shell.exec
params:
script: |
# Setup local Kubernetes cluster
./src/atlas-service-broker/dev/scripts/evergreen-kubernetes-setup.sh ${workdir}/bin ${docker_repo}/${docker_name}
"teardown_kubernetes":
- command: shell.exec
params:
script: |
export PATH="${workdir}/bin:$PATH"
kind delete cluster
"e2e_tests_kubernetes":
- command: shell.exec
params:
working_dir: src/atlas-service-broker
script: |
export PATH="${workdir}/bin:$PATH"
export ATLAS_BASE_URL=${atlas_base_url}
export ATLAS_GROUP_ID=${atlas_group_id}
export ATLAS_PUBLIC_KEY=${atlas_public_key}
export ATLAS_PRIVATE_KEY=${atlas_private_key}
export DOCKER_IMAGE="${docker_repo}/${docker_name}:e2e-test"
KUBECONFIG=$(kind get kubeconfig-path)
export KUBECONFIG
go test -timeout 1h -v ./test/e2e | tee e2e_kubernetes_result.suite
- command: gotest.parse_files
params:
files: ["src/atlas-service-broker/e2e_kubernetes_result.suite"]
tasks:
- name: unit_tests
commands:
- func: "go_unit_tests"
- name: vet
commands:
- func: "go_vet"
- name: snyk_snapshot
commands:
- func: "setup_snyk"
- func: "snyk_snapshot"
- name: integration_tests
commands:
- func: "integration_tests"
- name: upload_test_binary
patch_only: true
commands:
- func: "fetch_source"
- func: "upload_test_binary"
- name: release_github
patch_only: true
commands:
- func: "fetch_source"
- func: "get_tagged_version"
- func: "build_binaries"
- func: "setup_hub"
- func: "publish_github_release"
- name: release_docker
patch_only: true
depends_on:
- name: release_github
commands:
- func: "fetch_source"
- func: "get_tagged_version"
- func: "setup_docker"
- func: "build_docker"
- func: "publish_docker"
- name: e2e_tests_kubernetes
commands:
- func: "e2e_tests_kubernetes"
task_groups:
- name: code_health_task_group
setup_group:
- func: "fetch_source"
tasks:
- vet
- snyk_snapshot
- name: test_task_group
setup_group:
- func: "fetch_source"
tasks:
- unit_tests
- integration_tests
- name: e2e_task_group
setup_group:
- func: "fetch_source"
- func: "setup_docker"
- func: "build_docker"
- func: "setup_kubernetes"
tasks:
- e2e_tests_kubernetes
teardown_group:
- func: "teardown_kubernetes"
- func: "teardown_docker"
buildvariants:
- name: test
display_name: test
run_on: archlinux-test
tasks:
- test_task_group
- e2e_task_group
- name: code_health
display_name: code_health
run_on: archlinux-test
tasks:
- code_health_task_group
- name: release
display_name: release
run_on: archlinux-test
tasks:
- upload_test_binary
- release_github
- release_docker