forked from chickenbug/stitch-cli-1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.evg.yml
391 lines (378 loc) · 13.8 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
cloud_dependent_pkg: &cloud_dependent_pkg "commands"
functions:
"fetch_go113":
- command: shell.exec
params:
shell: "bash"
script: |
set -e
wget --quiet ${go_url}
tar xvf ./go1.13*gz
"fetch_yarn":
- command: shell.exec
params:
shell: "bash"
script: |
set -e
curl --silent -OL https://yarnpkg.com/latest.tar.gz
tar zvxf latest.tar.gz
mv yarn-* yarn
"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}
"setup_project":
- command: git.get_project
params:
directory: stitch-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_transpiler": &setup_transpiler
- *setup_node
- command: shell.exec
params:
shell: "bash"
script: |
set -e
set -v
export ROOT_DIR=`pwd`
export PATH="$ROOT_DIR/yarn/bin:$PATH"
export NVM_DIR="$ROOT_DIR/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
nvm use ${node_version}
cd stitch-cli/etc/transpiler
yarn && yarn run build -t ${transpiler_target}
"setup_stitch_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/stitch.git
- command: shell.exec
params:
shell: "bash"
script: |
set -e
cd stitch
mkdir -p etc/dylib
cd etc/dylib
curl -s "${server_stitch_lib_url}" | tar xvfz - --strip-components=1
- command: shell.exec
params:
shell: "bash"
script: |
set -e
export ROOT_DIR=`pwd`
export PATH="$ROOT_DIR/yarn/bin:$PATH"
export NVM_DIR="$ROOT_DIR/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
nvm use ${node_version}
cd stitch/etc/transpiler
curl -OL https://yarnpkg.com/latest.tar.gz
tar zvxf latest.tar.gz
mv yarn-* yarn
yarn install && yarn run build -t ${transpiler_target}
"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/stitch
export PATH="$ROOT_DIR/stitch/etc/transpiler/bin:$PATH"
export LD_LIBRARY_PATH="$ROOT_DIR/stitch/etc/dylib/lib"
which transpiler
cat > atlas_config.json <<EOF
{
"admin": {
"authProviders": [
{
"name": "mongodb-cloud",
"type": "mongodb-cloud",
"config": {
"baseUrl": "https://cloud-dev.mongodb.com",
"adminUsername": "${stitch_mongodb_cloud_atlas_admin_username}",
"adminAPIKey": "${stitch_mongodb_cloud_atlas_admin_api_key}"
},
"metadataFields": [{ "name": "name", "required": false}]
}
]
}
}
EOF
go run cmd/server/main.go --configFile $ROOT_DIR/stitch-cli/testdata/configs/stitch_server_test_config.json --configFile ./atlas_config.json
- command: shell.exec
params:
shell: "bash"
script: |
counter=0
until $(curl --output /dev/null --silent --head --fail ${stitchServerURL}); 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_go113"
- func: "fetch_yarn"
- func: "setup_project"
- func: "setup_transpiler"
- command: shell.exec
params:
shell: "bash"
script: |
set -v
set -e
export ROOT_DIR=`pwd`
export PATH="$ROOT_DIR:$PATH"
export PATH=$PATH:$ROOT_DIR/stitch-cli/etc/transpiler/bin/
export GOROOT=$ROOT_DIR/go
export PATH=$GOROOT/bin:$PATH
cd $ROOT_DIR/stitch-cli
go test -v -covermode=count -coverprofile=$ROOT_DIR/cover.out $(go list github.com/10gen/stitch-cli/...) > $ROOT_DIR/stitch-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: stitch-test-artifacts
content_type: text/plain
permissions: public-read
- name: tests-with-cloud
exec_timeout_secs: 3600
commands:
- func: "fetch_go113"
- func: "fetch_yarn"
- func: "setup_project"
- func: "setup_transpiler"
- func: "setup_mongod"
- func: "setup_stitch_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 PATH=$PATH:$ROOT_DIR/stitch-cli/etc/transpiler/bin/
export GOROOT=$ROOT_DIR/go
export PATH=$GOROOT/bin:$PATH
export STITCH_MONGODB_CLOUD_GROUP_ID="${stitch_mongodb_cloud_group_id}"
export STITCH_MONGODB_CLOUD_USERNAME="${stitch_mongodb_cloud_username}"
export STITCH_MONGODB_CLOUD_API_KEY="${stitch_mongodb_cloud_api_key}"
export STITCH_MONGODB_CLOUD_ADMIN_USERNAME="${stitch_mongodb_cloud_admin_username}"
export STITCH_MONGODB_CLOUD_ADMIN_API_KEY="${stitch_mongodb_cloud_admin_api_key}"
export STITCH_MONGODB_CLOUD_API_BASE_URL="${mongoDBCloudURL}"
export STITCH_SERVER_BASE_URL="${stitchServerURL}"
cd $ROOT_DIR/stitch-cli
go test -v -covermode=count -coverprofile=$ROOT_DIR/cover.out $(go list github.com/10gen/stitch-cli/${cloud_dependent_pkg}/...) -timeout 25m -run TestCloud > $ROOT_DIR/stitch-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: stitch-test-artifacts
content_type: text/plain
permissions: public-read
- name: lint
commands:
- func: "fetch_go113"
- 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/stitch-cli
go run github.com/golangci/golangci-lint/cmd/golangci-lint run ./...
- name: build_publish_clis
depends_on:
- name: test_unit
- name: lint
patchable: false
commands:
- func: "fetch_go113"
- func: "setup_project"
- 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
curl -OL https://yarnpkg.com/latest.tar.gz
tar zvxf latest.tar.gz
mv yarn-* yarn
export PATH="$ROOT_DIR/yarn/bin:$PATH"
export NVM_DIR="$ROOT_DIR/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
cd $ROOT_DIR/stitch-cli
export VERSION="${version}"
export GOARCH=amd64
export GOOS=linux
export OSARCH=linux-amd64
echo "Building stitch-cli for $GOOS on $GOARCH"
REPLACE_VARS="-ldflags \"-X github.com/10gen/stitch-cli/utils.CLIVersion=$VERSION -X github.com/10gen/stitch-cli/utils.cliOSArch=$OSARCH\""
eval go build $REPLACE_VARS -o stitch-cli-linux-amd64 main.go
export GOOS=darwin
export OSARCH=macos-amd64
REPLACE_VARS="-ldflags \"-X github.com/10gen/stitch-cli/utils.CLIVersion=$VERSION -X github.com/10gen/stitch-cli/utils.cliOSArch=$OSARCH\""
echo "Building stitch-cli for $GOOS on $GOARCH"
eval go build $REPLACE_VARS -o stitch-cli-macos-amd64 main.go
export GOOS=windows
export OSARCH=windows-amd64
REPLACE_VARS="-ldflags \"-X github.com/10gen/stitch-cli/utils.CLIVersion=$VERSION -X github.com/10gen/stitch-cli/utils.cliOSArch=$OSARCH\""
echo "Building stitch-cli for $GOOS on $GOARCH"
eval go build $REPLACE_VARS -o stitch-cli-windows-amd64 main.go
# build transpilers
cd etc/transpiler
yarn install
# linux
yarn run build -t node8-linux-x64
mv bin/transpiler bin/transpiler-linux-x64
# mac
yarn run build -t node8-macos-x64
mv bin/transpiler bin/transpiler-macos-x64
# win
yarn run build -t node8-win-x64
mv bin/transpiler.exe bin/transpiler-win-x64
- command: s3.put
params:
aws_key: ${artifacts_aws_key}
aws_secret: ${artifacts_aws_secret}
local_file: stitch-cli/stitch-cli-linux-amd64
remote_file: ${build_id}/linux-amd64/stitch-cli
bucket: stitch-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: stitch-cli/stitch-cli-macos-amd64
remote_file: ${build_id}/macos-amd64/stitch-cli
bucket: stitch-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: stitch-cli/stitch-cli-windows-amd64
remote_file: ${build_id}/windows-amd64/stitch-cli.exe
bucket: stitch-clis
content_type: application/octet-stream
permissions: public-read
# transpilers
- command: s3.put
params:
aws_key: ${artifacts_aws_key}
aws_secret: ${artifacts_aws_secret}
local_file: stitch-cli/etc/transpiler/bin/transpiler-linux-x64
remote_file: ${build_id}/linux-amd64/transpiler
bucket: stitch-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: stitch-cli/etc/transpiler/bin/transpiler-macos-x64
remote_file: ${build_id}/macos-amd64/transpiler
bucket: stitch-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: stitch-cli/etc/transpiler/bin/transpiler-win-x64
remote_file: ${build_id}/windows-amd64/transpiler.exe
bucket: stitch-clis
content_type: application/octet-stream
permissions: public-read
post:
- command: gotest.parse_files
params:
files: ["*.suite"]
buildvariants:
- name: rhel70
display_name: rhel70
run_on:
- rhel70
expansions:
go_url: "https://dl.google.com/go/go1.13.linux-amd64.tar.gz"
server_stitch_lib_url: 'https://s3.amazonaws.com/mciuploads/mongodb-mongo-master/stitch-support/enterprise-rhel-70-64-bit/18ca0d551818d6c8274358b8e6444640bec93c88/stitch-support-4.3.0-120-g18ca0d5.tgz'
mongodb_url: https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-4.0.2.tgz
node_version: 10.15.1
transpiler_target: node8-linux
libmongo_url: 'https://s3.amazonaws.com/stitch-artifacts/stitch-mongo-libs/stitch_mongo_libs_linux_64_patch_f1f04683a9b5612f5a82a2d7f97818ef74a8fb05_5d898ee3306615699f265907_19_09_24_03_35_01/libmongo.so'
mongoDBCloudURL: https://cloud-dev.mongodb.com
stitchServerURL: http://localhost:9090
version: 1.12.0
tasks:
- name: test_unit
- name: tests-with-cloud
- name: lint
- name: build_publish_clis