-
Notifications
You must be signed in to change notification settings - Fork 23
/
.evg.yml
445 lines (428 loc) · 15.5 KB
/
.evg.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
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
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
functions:
"fetch_go":
- command: shell.exec
params:
shell: "bash"
script: |
set -e
wget --quiet ${go_url}
tar xvf ./go1*gz
"fetch_baas_artifacts": &fetch_baas_artifacts
- command: shell.exec
params:
shell: "bash"
script: | # find all baas release branches, sort them, and grab the latest release's commit id
git ls-remote [email protected]:10gen/baas.git | grep refs/heads/v20 | sort -k2 | awk '{ print "baas_revision: \""$1"\"" }' | tail -n 1 > baas.yml
- command: expansions.update
params:
file: baas.yml
- command: s3.get
params:
aws_key: ${stitch_cloud_aws_key}
aws_secret: ${stitch_cloud_aws_secret}
remote_file: ${baas_revision}-race.tgz
bucket: stitch-cloud-versions
local_file: baas_artifacts.tgz
- command: shell.exec
params:
shell: "bash"
script: |
set -e
mkdir baas_artifacts
tar zvxf baas_artifacts.tgz -C baas_artifacts
"setup_node": &setup_node
command: shell.exec
params:
shell: "bash"
script: |
set -e
export ROOT_DIR=`pwd`
export NVM_DIR="$ROOT_DIR/.nvm"
if [ ! -d "$NVM_DIR" ]; then
git clone https://github.com/nvm-sh/nvm.git "$NVM_DIR"
cd "$NVM_DIR"
git checkout `git describe --abbrev=0 --tags --match "v[0-9]*" $(git rev-list --tags --max-count=1)`
fi
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
nvm install ${node_version}
nvm use ${node_version}
"setup_project":
- command: git.get_project
params:
directory: realm-cli
"setup_mongod":
- command: shell.exec
params:
shell: "bash"
script: |
set -v
curl --silent ${mongodb_url} | tar xvz
- command: shell.exec
params:
shell: "bash"
background: true
script: |
set -v
cd mongodb-*
echo "starting mongod..."
mkdir db_files
./bin/mongod --dbpath ./db_files --port 26000 --replSet "test" &
echo "waiting for mongod to start up"
- command: shell.exec
params:
shell: "bash"
script: |
set -e
cd mongodb-*
echo "waiting for mongod to start up"
./bin/mongo --nodb --eval 'assert.soon(function(x){try{var d = new Mongo("localhost:26000"); return true}catch(e){return false}}, "timed out connecting")'
./bin/mongo --port 26000 --eval 'rs.initiate()'
echo "mongod is up."
"setup_baas_server":
- command: shell.exec
params:
shell: "bash"
script: |
wget --quiet "${libmongo_url}"
chmod +x libmongo.so
- command: shell.exec
params:
shell: "bash"
script: |
git clone [email protected]:10gen/baas.git
- command: shell.exec
params:
shell: "bash"
script: |
set -e
cd baas
mkdir -p etc/dylib
cd etc/dylib
curl -s "${baas_supportlib_url}" | tar xvfz - --strip-components=1
- command: shell.exec
params:
shell: "bash"
script: |
set -e
mkdir -p baas/etc/transpiler/bin
cp baas_artifacts/transpiler baas/etc/transpiler/bin/
"start_server":
- command: shell.exec
params:
shell: "bash"
background: true
script: |
export ROOT_DIR=`pwd`
export PATH="$ROOT_DIR:$PATH"
export GOROOT=$ROOT_DIR/go
export PATH=$GOROOT/bin:$PATH
cd $ROOT_DIR/baas
export PATH="$ROOT_DIR/baas/etc/transpiler/bin:$PATH"
export LD_LIBRARY_PATH="$ROOT_DIR/baas/etc/dylib/lib"
export AWS_ACCESS_KEY_ID='${baas_test_aws_key}'
export AWS_SECRET_ACCESS_KEY='${baas_test_aws_secret}'
go run cmd/server/main.go --configFile $ROOT_DIR/baas/etc/configs/test_cli_config.json
- command: shell.exec
params:
shell: "bash"
script: |
counter=0
until $(curl --output /dev/null --silent --head --fail ${realm_server_url}); do
echo "checking for API server to be up..."
sleep 1
let counter++
if [ $counter -gt 100 ]; then
exit 1
fi
done
tasks:
- name: test_unit
exec_timeout_secs: 3600
commands:
- func: "fetch_go"
vars:
go_url: ${go_115_url}
- func: "setup_project"
- command: shell.exec
params:
shell: "bash"
script: |
set -v
set -e
export ROOT_DIR=`pwd`
export PATH="$ROOT_DIR:$PATH"
export PATH="$ROOT_DIR/realm-cli/etc/bin:$PATH"
export GOROOT=$ROOT_DIR/go
export PATH=$GOROOT/bin:$PATH
cd $ROOT_DIR/realm-cli
go test -v -covermode=count -coverprofile=$ROOT_DIR/cover.out $(go list github.com/10gen/realm-cli/...) > $ROOT_DIR/realm-cli.suite
- command: s3.put
params:
aws_key: ${test_aws_key}
aws_secret: ${test_aws_secret}
local_file: cover.out
remote_file: ${task_id}/cover.out
bucket: baas-test-artifacts
content_type: text/plain
permissions: public-read
- name: test_e2e
exec_timeout_secs: 3600
commands:
- func: "fetch_go"
vars:
go_url: ${go_115_url}
- func: "setup_project"
- command: shell.exec
params:
shell: "bash"
script: |
set -v
set -e
export ROOT_DIR=`pwd`
export PATH="$ROOT_DIR:$PATH"
export PATH="$ROOT_DIR/realm-cli/etc/bin:$PATH"
export GOROOT=$ROOT_DIR/go
export PATH=$GOROOT/bin:$PATH
cd $ROOT_DIR/realm-cli
go test -v -covermode=count -coverprofile=$ROOT_DIR/cover.out $(go list github.com/10gen/realm-cli/e2e/...) > $ROOT_DIR/realm-cli.suite
- command: s3.put
params:
aws_key: ${test_aws_key}
aws_secret: ${test_aws_secret}
local_file: cover.out
remote_file: ${task_id}/cover.out
bucket: baas-test-artifacts
content_type: text/plain
permissions: public-read
- name: test_with_cloud
exec_timeout_secs: 3600
commands:
- func: "fetch_go"
vars:
go_url: ${go_117_url}
- func: "fetch_baas_artifacts"
- func: "setup_node"
- func: "setup_project"
- func: "setup_mongod"
- func: "setup_baas_server"
- func: "start_server"
- command: shell.exec
params:
shell: "bash"
script: |
set -v
set -e
export ROOT_DIR=`pwd`
export PATH="$ROOT_DIR:$PATH"
export GOROOT=$ROOT_DIR/go
export PATH=$GOROOT/bin:$PATH
export BAAS_NO_SKIP_TEST=1
export BAAS_MONGODB_CLOUD_GROUP_COUNT="${baas_mongodb_cloud_group_count}"
export BAAS_MONGODB_CLOUD_GROUP_ID="${baas_mongodb_cloud_group_id}"
export BAAS_MONGODB_CLOUD_USERNAME="${baas_mongodb_cloud_username}"
export BAAS_MONGODB_CLOUD_API_KEY="${baas_mongodb_cloud_api_key}"
export BAAS_MONGODB_CLOUD_ADMIN_USERNAME="${baas_mongodb_cloud_admin_username}"
export BAAS_MONGODB_CLOUD_ADMIN_API_KEY="${baas_mongodb_cloud_admin_api_key}"
export BAAS_MONGODB_CLOUD_API_BASE_URL="${atlas_server_url}"
export BAAS_MONGODB_EXPIRED_ACCESS_TOKEN="${baas_mongodb_expired_access_token}"
export BAAS_SERVER_BASE_URL="${realm_server_url}"
cd $ROOT_DIR/realm-cli
go test -v -covermode=count -coverprofile=$ROOT_DIR/cover.out $(go list github.com/10gen/realm-cli/internal/cloud/...) -timeout 25m > $ROOT_DIR/realm-cli.suite
- command: s3.put
params:
aws_key: ${test_aws_key}
aws_secret: ${test_aws_secret}
local_file: cover.out
remote_file: ${task_id}/cover.out
bucket: baas-test-artifacts
content_type: text/plain
permissions: public-read
- name: lint
commands:
- func: "fetch_go"
vars:
go_url: ${go_115_url}
- func: "setup_project"
- command: shell.exec
params:
shell: "bash"
script: |
export ROOT_DIR=`pwd`
export GOROOT=$ROOT_DIR/go
export PATH=$GOROOT/bin:$PATH
cd $ROOT_DIR/realm-cli
go run github.com/golangci/golangci-lint/cmd/golangci-lint run ./...
- name: build_publish_clis
depends_on:
- name: lint
- name: test_unit
- name: test_with_cloud
- name: test_e2e
patchable: false
commands:
- func: "fetch_go"
vars:
go_url: ${go_115_url}
- func: "setup_project"
- command: shell.exec
params:
shell: "bash"
script: |
set -e
export ROOT_DIR=`pwd`
export PATH="$ROOT_DIR:$PATH"
export GOROOT=$ROOT_DIR/go
export PATH=$GOROOT/bin:$PATH
cd $ROOT_DIR/realm-cli
curl https://stedolan.github.io/jq/download/linux64/jq > jq && chmod +x jq
export VERSION=`cat package.json | ./jq '.version' | sed -e 's/^"//' -e 's/"$//'`
export GOARCH=amd64
export SEGMENT_WRITE_KEY="${realm_cli_segment_write_key}"
export GOOS=linux
export OSARCH=linux-amd64
echo "Building realm-cli for $GOOS on $GOARCH"
REPLACE_VARS="-ldflags \"-X github.com/10gen/realm-cli/internal/cli.Version=$VERSION -X github.com/10gen/realm-cli/internal/cli.OSArch=$OSARCH -X github.com/10gen/realm-cli/internal/telemetry.segmentWriteKey=$SEGMENT_WRITE_KEY\""
eval go build $REPLACE_VARS -o realm-cli-linux-amd64 main.go
export GOOS=darwin
export OSARCH=macos-amd64
REPLACE_VARS="-ldflags \"-X github.com/10gen/realm-cli/internal/cli.Version=$VERSION -X github.com/10gen/realm-cli/internal/cli.OSArch=$OSARCH -X github.com/10gen/realm-cli/internal/telemetry.segmentWriteKey=$SEGMENT_WRITE_KEY\""
echo "Building realm-cli for $GOOS on $GOARCH"
eval go build $REPLACE_VARS -o realm-cli-macos-amd64 main.go
export GOOS=windows
export OSARCH=windows-amd64
REPLACE_VARS="-ldflags \"-X github.com/10gen/realm-cli/internal/cli.Version=$VERSION -X github.com/10gen/realm-cli/internal/cli.OSArch=$OSARCH -X github.com/10gen/realm-cli/internal/telemetry.segmentWriteKey=$SEGMENT_WRITE_KEY\""
echo "Building realm-cli for $GOOS on $GOARCH"
eval go build $REPLACE_VARS -o realm-cli-windows-amd64 main.go
- command: s3.put
params:
aws_key: ${artifacts_aws_key}
aws_secret: ${artifacts_aws_secret}
local_file: realm-cli/realm-cli-linux-amd64
remote_file: ${build_id}/linux-amd64/realm-cli
bucket: realm-clis
content_type: application/octet-stream
permissions: public-read
- command: s3.put
params:
aws_key: ${artifacts_aws_key}
aws_secret: ${artifacts_aws_secret}
local_file: realm-cli/realm-cli-macos-amd64
remote_file: ${build_id}/macos-amd64/realm-cli
bucket: realm-clis
content_type: application/octet-stream
permissions: public-read
- command: s3.put
params:
aws_key: ${artifacts_aws_key}
aws_secret: ${artifacts_aws_secret}
local_file: realm-cli/realm-cli-windows-amd64
remote_file: ${build_id}/windows-amd64/realm-cli.exe
bucket: realm-clis
content_type: application/octet-stream
permissions: public-read
- name: release_tag
depends_on:
- name: lint
- name: test_unit
- name: test_with_cloud
- name: test_e2e
- name: build_publish_clis
patchable: false
commands:
- func: "setup_node"
- func: "setup_project"
- command: s3.get
params:
aws_key: ${artifacts_aws_key}
aws_secret: ${artifacts_aws_secret}
remote_file: versions/cloud-prod/CURRENT
bucket: realm-clis
local_file: manifest.json
- command: shell.exec
params:
shell: "bash"
script: |
set -e
cd realm-cli
curl https://stedolan.github.io/jq/download/linux64/jq > jq && chmod +x jq
export VERSION=`cat package.json | ./jq '.version' | sed -e 's/^"//' -e 's/"$//'`
if [ "${branch_name}" != "master" ]; then
echo "skipping release: not on master branch"
exit 0
fi
if [ $(git tag -l "v$VERSION") ]; then
echo "skipping release: tag already exists"
exit 0
fi
echo "updating manifest"
./contrib/manifest.js ${build_id} $VERSION ../manifest.json
echo "tagging release: v$VERSION"
PREVIOUS_VERSION=$(git describe --tags $(git rev-list --tags --max-count=1))
BODY=$(git log --no-merges $PREVIOUS_VERSION..HEAD --pretty="format:%s (%h); %an" | sed '$d')
git tag -a -m "Changelog since $PREVIOUS_VERSION:" -m "$BODY" "v$VERSION"
git push origin master --tags
touch release.true
- command: s3.put
params:
aws_key: ${artifacts_aws_key}
aws_secret: ${artifacts_aws_secret}
local_file: manifest.json
remote_file: versions/cloud-prod/CURRENT
bucket: realm-clis
content_type: application/octet-stream
permissions: public-read
- command: shell.exec
params:
shell: "bash"
silent: true
script: |
set -e
cd realm-cli
if [ ! -f release.true ]; then
# not a release build
exit 0
fi
cat > .npmrc <<EOL
_auth = ${npm_auth}
always-auth = true
email = ${npm_email}
registry=${npm_registry}
EOL
- command: shell.exec
params:
shell: "bash"
script: |
set -e
cd realm-cli
if [ ! -f release.true ]; then
# not a release build
exit 0
fi
echo "publishing release to npm"
npm publish --unsafe-perm
post:
- command: gotest.parse_files
params:
files: ["*.suite"]
buildvariants:
- name: rhel70
display_name: rhel70
run_on:
- rhel70
expansions:
atlas_server_url: "https://cloud-dev.mongodb.com"
baas_supportlib_url: "https://s3.amazonaws.com/stitch-artifacts/stitch-support/stitch-support-rhel-70-4.3.2-721-ge791a2e-patch-5e2a6ad2a4cf473ae2e67b09.tgz"
go_115_url: "https://dl.google.com/go/go1.15.11.linux-amd64.tar.gz"
go_117_url: "https://dl.google.com/go/go1.17.2.linux-amd64.tar.gz"
libmongo_url: "https://stitch-artifacts.s3.amazonaws.com/stitch-mongo-libs/stitch_mongo_libs_linux_64_patch_f323e4411e1b2d9011b88d7f6855654c8432f2ee_6179e0e92a60ed55e5ecc820_21_10_27_23_30_03/libmongo.so"
mongodb_url: "https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-4.0.2.tgz"
realm_server_url: "http://localhost:9090"
yarn_url: "https://s3.amazonaws.com/stitch-artifacts/yarn/latest.tar.gz"
node_version: 12.16.2
tasks:
- name: test_unit
- name: test_with_cloud
- name: test_e2e
- name: lint
- name: build_publish_clis
- name: release_tag