-
Notifications
You must be signed in to change notification settings - Fork 209
/
Copy pathfunctions.yml
275 lines (250 loc) · 8.77 KB
/
functions.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
functions:
"fetch source":
# Executes git clone and applies the submitted patch, if any
- command: git.get_project
params:
directory: "src"
# Fetch the submodules
- command: shell.exec
params:
working_dir: "src"
script: |
git submodule update --init
# Make an evergreen expansion file with dynamic values
- command: shell.exec
params:
working_dir: "src"
script: |
# Get the current unique version of this checkout
if [ "${is_patch}" = "true" ]; then
CURRENT_VERSION=$(git describe)-patch-${version_id}
else
CURRENT_VERSION=latest
fi
export DRIVERS_TOOLS="$(pwd)/tests/drivers-evergreen-tools"
export PROJECT_DIRECTORY="$(pwd)"
# Python has cygwin path problems on Windows. Detect prospective mongo-orchestration home directory
if [ "Windows_NT" = "$OS" ]; then # Magic variable in cygwin
export DRIVERS_TOOLS=$(cygpath -m $DRIVERS_TOOLS)
export PROJECT_DIRECTORY=$(cygpath -m $PROJECT_DIRECTORY)
fi
export MONGO_ORCHESTRATION_HOME="$DRIVERS_TOOLS/.evergreen/orchestration"
# Note: PHPC no longer has any custom MO configs, but they can be stored here if needed
export PROJECT_ORCHESTRATION_HOME="$PROJECT_DIRECTORY/.evergreen/orchestration"
export MONGODB_BINARIES="$DRIVERS_TOOLS/mongodb/bin"
export UPLOAD_BUCKET="${project}"
cat <<EOT > expansion.yml
CURRENT_VERSION: "$CURRENT_VERSION"
DRIVERS_TOOLS: "$DRIVERS_TOOLS"
MONGO_ORCHESTRATION_HOME: "$MONGO_ORCHESTRATION_HOME"
PROJECT_ORCHESTRATION_HOME: "$PROJECT_ORCHESTRATION_HOME"
MONGODB_BINARIES: "$MONGODB_BINARIES"
UPLOAD_BUCKET: "$UPLOAD_BUCKET"
PROJECT_DIRECTORY: "$PROJECT_DIRECTORY"
PREPARE_SHELL: |
set -o errexit
export DRIVERS_TOOLS="$DRIVERS_TOOLS"
export MONGO_ORCHESTRATION_HOME="$MONGO_ORCHESTRATION_HOME"
export PROJECT_ORCHESTRATION_HOME="$PROJECT_ORCHESTRATION_HOME"
export MONGODB_BINARIES="$MONGODB_BINARIES"
export UPLOAD_BUCKET="$UPLOAD_BUCKET"
export PROJECT_DIRECTORY="$PROJECT_DIRECTORY"
export TMPDIR="$MONGO_ORCHESTRATION_HOME/db"
export PATH="$MONGODB_BINARIES:$PATH"
export PROJECT="${project}"
export SSL_DIR="$DRIVERS_TOOLS/.evergreen/x509gen"
EOT
# See what we've done
cat expansion.yml
# Load the expansion file to make an evergreen variable with the current unique version
- command: expansions.update
params:
file: src/expansion.yml
"prepare resources":
- command: shell.exec
params:
working_dir: src
script: |
${PREPARE_SHELL}
echo "{ \"releases\": { \"default\": \"$MONGODB_BINARIES\" }}" > $MONGO_ORCHESTRATION_HOME/orchestration.config
# Upload build artifacts that other tasks may depend on
# Note this URL needs to be totally unique, while predictable for the next task
# so it can automatically download the artifacts
"upload build":
# Compress and upload the entire build directory
- command: archive.targz_pack
params:
target: "${build_id}.tar.gz"
source_dir: src
include:
- "./**"
- command: s3.put
params:
aws_key: ${aws_key}
aws_secret: ${aws_secret}
bucket: mciuploads
content_type: ${content_type|application/x-gzip}
permissions: public-read
local_file: ${build_id}.tar.gz
remote_file: mongo-php-driver/${build_variant}/${revision}/${task_name}/${version_id}.tar.gz
"fetch build":
- command: subprocess.exec
type: setup
params:
binary: bash
args:
- -c
- rm -rf src
- command: s3.get
params:
aws_key: ${aws_key}
aws_secret: ${aws_secret}
bucket: mciuploads
remote_file: mongo-php-driver/${FETCH_BUILD_VARIANT}/${revision}/${FETCH_BUILD_TASK}/${version_id}.tar.gz
local_file: build.tar.gz
- command: archive.targz_extract
params:
destination: src
path: build.tar.gz
# Fix path names in Makefile
- command: shell.exec
type: test
params:
working_dir: "src"
script: |
${PREPARE_SHELL}
perl -p -i -e "s|/data/mci/[0-9a-z]+/src|${PROJECT_DIRECTORY}|g" Makefile
"compile driver" :
- command: shell.exec
params:
working_dir: "src/src/libmongoc"
add_expansions_to_env: true
script: |
if [ -n "${LIBMONGOC_VERSION}" ]; then
echo "Checking out libmongoc version: ${LIBMONGOC_VERSION}"
git fetch
git checkout ${LIBMONGOC_VERSION}
# Note: compile-unix.sh will run `make libmongoc-version-current`
fi
- command: subprocess.exec
type: test
params:
working_dir: "src"
add_expansions_to_env: true
binary: bash
args:
- ${PROJECT_DIRECTORY}/.evergreen/compile-unix.sh
"upload test results":
- command: attach.xunit_results
params:
# Uploading test results does not work when using ${PROJECT_DIRECTORY},
# so we use an absolute path to work around this
file: "src/test-results.xml"
- command: attach.results
params:
file_location: "${DRIVERS_TOOLS}/results.json"
"bootstrap mongo-orchestration":
- command: shell.exec
params:
include_expansions_in_env:
- MONGODB_VERSION
- TOPOLOGY
- AUTH
- SSL
- STORAGE_ENGINE
- LOAD_BALANCER
- REQUIRE_API_VERSION
- ORCHESTRATION_FILE
script: |
${PREPARE_SHELL}
SKIP_LEGACY_SHELL=true \
bash ${DRIVERS_TOOLS}/.evergreen/run-orchestration.sh
# run-orchestration generates expansion file with MONGODB_URI and CRYPT_SHARED_LIB_PATH
- command: expansions.update
params:
file: mo-expansion.yml
"stop mongo-orchestration":
- command: shell.exec
params:
script: |
${PREPARE_SHELL}
bash ${DRIVERS_TOOLS}/.evergreen/stop-orchestration.sh
"start OCSP responder":
- command: subprocess.exec
params:
binary: bash
background: true
include_expansions_in_env:
- SERVER_TYPE
- OCSP_ALGORITHM
args:
- ${DRIVERS_TOOLS}/.evergreen/ocsp/setup.sh
"stop OCSP responder":
- command: shell.exec
params:
script: |
${PREPARE_SHELL}
bash ${DRIVERS_TOOLS}/.evergreen/ocsp/teardown.sh
"run tests":
- command: shell.exec
type: test
params:
include_expansions_in_env:
- API_VERSION
- CRYPT_SHARED_LIB_PATH
- MONGODB_URI
- APPEND_URI
- SKIP_CRYPT_SHARED
- SSL
- SSL_DIR
- TESTS
working_dir: "src"
script: |
${PREPARE_SHELL}
bash ${PROJECT_DIRECTORY}/.evergreen/run-tests.sh
"cleanup":
- command: shell.exec
params:
script: |
${PREPARE_SHELL}
rm -rf $DRIVERS_TOOLS || true
"fix absolute paths":
- command: shell.exec
params:
script: |
${PREPARE_SHELL}
for filename in $(find ${DRIVERS_TOOLS} -name \*.json); do
perl -p -i -e "s|ABSOLUTE_PATH_REPLACEMENT_TOKEN|${DRIVERS_TOOLS}|g" $filename
done
"init test-results":
- command: shell.exec
params:
script: |
${PREPARE_SHELL}
echo '{"results": [{ "status": "FAIL", "test_file": "Build", "log_raw": "No test-results.json found was created" } ]}' > ${PROJECT_DIRECTORY}/test-results.json
"install dependencies":
- command: shell.exec
params:
working_dir: "src"
script: |
${PREPARE_SHELL}
file="${DRIVERS_TOOLS}/.evergreen/install-dependencies.sh"
# Don't use ${file} syntax here because evergreen treats it as an empty expansion.
[ -f "$file" ] && bash $file || echo "$file not available, skipping"
"start load balancer":
- command: shell.exec
params:
script: |
MONGODB_URI="${MONGODB_URI}" \
bash ${DRIVERS_TOOLS}/.evergreen/run-load-balancer.sh start
- command: expansions.update
params:
file: lb-expansion.yml
"stop load balancer":
- command: shell.exec
params:
script: |
# Only run if a load balancer was started
if [ -n "${SINGLE_MONGOS_LB_URI}" ]; then
bash ${DRIVERS_TOOLS}/.evergreen/run-load-balancer.sh stop
fi