forked from mongodb/stitch-ios-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.evg.yml
102 lines (92 loc) · 3.67 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
functions:
"fetch_source":
- command: git.get_project
params:
directory: "stitch-ios-sdk"
"set_github_build_status":
- command: shell.exec
params:
silent: true
script: |
status_url=`curl -X POST -d "{}" -H "Content-Type: application/json" "${stitch_evg_hook_url}?secret=${stitch_evg_secret}&versionId=${version_id}"`
if [ "$status_url" = "null" ]; then
exit 0
fi
status_url=`sed -e 's/^"//' -e 's/"$//' <<<"$status_url"`
state=`cat commit_state`
curl -X POST -H "Content-Type: application/json" $status_url -d "{\"state\": \"$state\", \"target_url\": \"https://evergreen.mongodb.com/build/${build_id}\", \"context\": \"continuous-integration/evergreen-ci/${build_variant}\"}"
tasks:
- name: github_pull_request_start
priority: 100
commands:
- command: shell.exec
params:
script: |
if ! [ "${is_patch}" = "true" ]; then
exit 0
fi
echo pending > commit_state
- func: "set_github_build_status"
- name: github_pull_request_end
depends_on:
- name: github_pull_request_start
- name: run_tests
status: "*"
variant: linux-64
commands:
- command: shell.exec
params:
silent: true
script: |
if ! [ "${is_patch}" = "true" ]; then
exit 0
fi
BUILDS=( `curl -H "Auth-Username: ${evg_rest_user}" -H "Api-Key: ${evg_rest_api_key}" https://evergreen.mongodb.org/rest/v1/versions/${version_id} | python -c "import sys, json; builds = json.load(sys.stdin)['builds']; print ' '.join(builds)"` )
for build in "${BUILDS[@]}"
do
curl -H "Auth-Username: ${evg_rest_user}" -H "Api-Key: ${evg_rest_api_key}" https://evergreen.mongodb.org/rest/v1/builds/$build | python -c "import sys, json; tasks = json.load(sys.stdin)['tasks']; sys.exit(0) if all(tasks[task]['status'] == 'success' or task == 'github_pull_request_end' for task in tasks) else sys.exit(1)"
if [ $? -ne 0 ]; then
echo "failure" > commit_state
exit 0
fi
done
echo "success" > commit_state
- func: "set_github_build_status"
- name: run_tests
commands:
- func: "fetch_source"
- command: shell.exec
silent: true
params:
script: |
set -e
cd stitch-ios-sdk
git submodule update --init --recursive
echo "packaging source files"
tar -czf ../source.tgz .
urlencodepipe() {
local LANG=C; local c; while IFS= read -r c; do
case $c in [a-zA-Z0-9.~_-]) printf "$c"; continue ;; esac
printf "$c" | od -An -tx1 | tr ' ' % | tr -d '\n'
done <<EOF
$(fold -w1)
EOF
echo
}
urlencode() { printf "$*" | urlencodepipe ;}
echo "running tests remotely"
TEST_DESTINATION=`urlencode "platform=iOS Simulator,name=iPhone 7 Plus"`
TEST_SCHEMES=`urlencode "StitchCore,ExtendedJson,MongoDBService"`
URL="${device_farm_url}?test_type=ios&test_destination=$TEST_DESTINATION&test_schemes=$TEST_SCHEMES"
RESULT=`cat ../source.tgz | curl $URL -H "Authorization: ${device_farm_secret}" --data-binary @-`
echo $RESULT
echo $RESULT | grep '!!ALL TESTS PASSED!!'
buildvariants:
- name: linux-64
display_name: Linux-64
run_on:
- baas-linux
tasks:
- name: github_pull_request_start
- name: run_tests
- name: github_pull_request_end