Skip to content

Commit 397e734

Browse files
committed
chore: pull prepare shell out to script to make spawn hosts easier
1 parent 64b3ee9 commit 397e734

File tree

4 files changed

+97
-134
lines changed

4 files changed

+97
-134
lines changed

.evergreen/config.in.yml

Lines changed: 23 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -28,81 +28,40 @@ functions:
2828
params:
2929
directory: "src"
3030
shallow_clone: true # speed things up by limiting clone depth to 100
31+
3132
# Make an evergreen expansion file with dynamic values
32-
- command: shell.exec
33+
- command: subprocess.exec
3334
params:
3435
working_dir: "src"
35-
script: |
36-
# Get the current unique version of this checkout
37-
if [ "${is_patch}" = "true" ]; then
38-
CURRENT_VERSION=$(git describe)-patch-${version_id}
39-
else
40-
CURRENT_VERSION=latest
41-
fi
42-
43-
export DRIVERS_TOOLS="$(pwd)/../drivers-tools"
44-
45-
export PROJECT_DIRECTORY="$(pwd)"
46-
export MONGO_ORCHESTRATION_HOME="$DRIVERS_TOOLS/.evergreen/orchestration"
47-
export MONGODB_BINARIES="$DRIVERS_TOOLS/mongodb/bin"
48-
export UPLOAD_BUCKET="${project}"
49-
50-
# fix paths on windows
51-
if [ "Windows_NT" = "$OS" ]; then
52-
export DRIVERS_TOOLS=$(cygpath -m -a $DRIVERS_TOOLS)
53-
export MONGO_ORCHESTRATION_HOME=$(cygpath -m -a $MONGO_ORCHESTRATION_HOME)
54-
export MONGODB_BINARIES=$(cygpath -m -a $MONGODB_BINARIES)
55-
export PROJECT_DIRECTORY=$(cygpath -m -a $PROJECT_DIRECTORY)
56-
fi
57-
58-
cat <<EOT > expansion.yml
59-
CURRENT_VERSION: "$CURRENT_VERSION"
60-
DRIVERS_TOOLS: "$DRIVERS_TOOLS"
61-
MONGO_ORCHESTRATION_HOME: "$MONGO_ORCHESTRATION_HOME"
62-
MONGODB_BINARIES: "$MONGODB_BINARIES"
63-
UPLOAD_BUCKET: "$UPLOAD_BUCKET"
64-
PROJECT_DIRECTORY: "$PROJECT_DIRECTORY"
65-
PREPARE_SHELL: |
66-
set -o errexit
67-
set -o xtrace
68-
export DRIVERS_TOOLS="$DRIVERS_TOOLS"
69-
export MONGO_ORCHESTRATION_HOME="$MONGO_ORCHESTRATION_HOME"
70-
export MONGODB_BINARIES="$MONGODB_BINARIES"
71-
export UPLOAD_BUCKET="$UPLOAD_BUCKET"
72-
export PROJECT_DIRECTORY="$PROJECT_DIRECTORY"
73-
74-
export TMPDIR="$MONGO_ORCHESTRATION_HOME/db"
75-
export PATH="$MONGODB_BINARIES:$PATH"
76-
export PROJECT="${project}"
77-
EOT
78-
# See what we've done
79-
cat expansion.yml
36+
binary: bash
37+
env:
38+
is_patch: ${is_patch}
39+
project: ${project}
40+
args:
41+
- .evergreen/prepare-shell.sh
8042

8143
# Load the expansion file to make an evergreen variable with the current unique version
8244
- command: expansions.update
8345
params:
8446
file: src/expansion.yml
8547

86-
"prepare resources":
87-
- command: shell.exec
88-
params:
89-
script: |
90-
${PREPARE_SHELL}
91-
git clone --depth 1 https://github.com/mongodb-labs/drivers-evergreen-tools.git $DRIVERS_TOOLS
92-
echo "{ \"releases\": { \"default\": \"$MONGODB_BINARIES\" }}" > $MONGO_ORCHESTRATION_HOME/orchestration.config
93-
9448
"bootstrap mongo-orchestration":
95-
- command: shell.exec
49+
- command: subprocess.exec
9650
params:
97-
script: |
98-
${PREPARE_SHELL}
99-
MONGODB_VERSION=${VERSION} TOPOLOGY=${TOPOLOGY} \
100-
AUTH=${AUTH} SSL=${SSL} \
101-
ORCHESTRATION_FILE=${ORCHESTRATION_FILE} \
102-
REQUIRE_API_VERSION=${REQUIRE_API_VERSION} \
103-
LOAD_BALANCER=${LOAD_BALANCER} \
104-
COMPRESSOR=${COMPRESSOR} \
105-
bash ${DRIVERS_TOOLS}/.evergreen/run-orchestration.sh
51+
binary: bash
52+
add_expansions_to_env: true
53+
env:
54+
MONGODB_VERSION: ${VERSION}
55+
TOPOLOGY: ${TOPOLOGY}
56+
AUTH: ${AUTH}
57+
SSL: ${SSL}
58+
ORCHESTRATION_FILE: ${ORCHESTRATION_FILE}
59+
REQUIRE_API_VERSION: ${REQUIRE_API_VERSION}
60+
LOAD_BALANCER: ${LOAD_BALANCER}
61+
COMPRESSOR: ${COMPRESSOR}
62+
args:
63+
- ${DRIVERS_TOOLS}/.evergreen/run-orchestration.sh
64+
10665
# run-orchestration generates expansion file with the MONGODB_URI for the cluster
10766
- command: expansions.update
10867
params:
@@ -959,7 +918,6 @@ task_groups:
959918
setup_group_timeout_secs: 1800 # 30 minutes
960919
setup_group:
961920
- func: "fetch source"
962-
- func: "prepare resources"
963921
- command: shell.exec
964922
params:
965923
shell: "bash"
@@ -991,7 +949,6 @@ task_groups:
991949

992950
pre:
993951
- func: "fetch source"
994-
- func: "prepare resources"
995952
- func: "windows fix"
996953
- func: "fix absolute paths"
997954
- func: "make files executable"

.evergreen/config.yml

Lines changed: 21 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -13,79 +13,34 @@ functions:
1313
params:
1414
directory: src
1515
shallow_clone: true
16-
- command: shell.exec
16+
- command: subprocess.exec
1717
params:
1818
working_dir: src
19-
script: |
20-
# Get the current unique version of this checkout
21-
if [ "${is_patch}" = "true" ]; then
22-
CURRENT_VERSION=$(git describe)-patch-${version_id}
23-
else
24-
CURRENT_VERSION=latest
25-
fi
26-
27-
export DRIVERS_TOOLS="$(pwd)/../drivers-tools"
28-
29-
export PROJECT_DIRECTORY="$(pwd)"
30-
export MONGO_ORCHESTRATION_HOME="$DRIVERS_TOOLS/.evergreen/orchestration"
31-
export MONGODB_BINARIES="$DRIVERS_TOOLS/mongodb/bin"
32-
export UPLOAD_BUCKET="${project}"
33-
34-
# fix paths on windows
35-
if [ "Windows_NT" = "$OS" ]; then
36-
export DRIVERS_TOOLS=$(cygpath -m -a $DRIVERS_TOOLS)
37-
export MONGO_ORCHESTRATION_HOME=$(cygpath -m -a $MONGO_ORCHESTRATION_HOME)
38-
export MONGODB_BINARIES=$(cygpath -m -a $MONGODB_BINARIES)
39-
export PROJECT_DIRECTORY=$(cygpath -m -a $PROJECT_DIRECTORY)
40-
fi
41-
42-
cat <<EOT > expansion.yml
43-
CURRENT_VERSION: "$CURRENT_VERSION"
44-
DRIVERS_TOOLS: "$DRIVERS_TOOLS"
45-
MONGO_ORCHESTRATION_HOME: "$MONGO_ORCHESTRATION_HOME"
46-
MONGODB_BINARIES: "$MONGODB_BINARIES"
47-
UPLOAD_BUCKET: "$UPLOAD_BUCKET"
48-
PROJECT_DIRECTORY: "$PROJECT_DIRECTORY"
49-
PREPARE_SHELL: |
50-
set -o errexit
51-
set -o xtrace
52-
export DRIVERS_TOOLS="$DRIVERS_TOOLS"
53-
export MONGO_ORCHESTRATION_HOME="$MONGO_ORCHESTRATION_HOME"
54-
export MONGODB_BINARIES="$MONGODB_BINARIES"
55-
export UPLOAD_BUCKET="$UPLOAD_BUCKET"
56-
export PROJECT_DIRECTORY="$PROJECT_DIRECTORY"
57-
58-
export TMPDIR="$MONGO_ORCHESTRATION_HOME/db"
59-
export PATH="$MONGODB_BINARIES:$PATH"
60-
export PROJECT="${project}"
61-
EOT
62-
# See what we've done
63-
cat expansion.yml
19+
binary: bash
20+
env:
21+
is_patch: ${is_patch}
22+
project: ${project}
23+
args:
24+
- .evergreen/prepare-shell.sh
6425
- command: expansions.update
6526
params:
6627
file: src/expansion.yml
67-
prepare resources:
68-
- command: shell.exec
69-
params:
70-
script: >
71-
${PREPARE_SHELL}
72-
73-
git clone --depth 1 https://github.com/mongodb-labs/drivers-evergreen-tools.git $DRIVERS_TOOLS
74-
75-
echo "{ \"releases\": { \"default\": \"$MONGODB_BINARIES\" }}" >
76-
$MONGO_ORCHESTRATION_HOME/orchestration.config
7728
bootstrap mongo-orchestration:
78-
- command: shell.exec
29+
- command: subprocess.exec
7930
params:
80-
script: |
81-
${PREPARE_SHELL}
82-
MONGODB_VERSION=${VERSION} TOPOLOGY=${TOPOLOGY} \
83-
AUTH=${AUTH} SSL=${SSL} \
84-
ORCHESTRATION_FILE=${ORCHESTRATION_FILE} \
85-
REQUIRE_API_VERSION=${REQUIRE_API_VERSION} \
86-
LOAD_BALANCER=${LOAD_BALANCER} \
87-
COMPRESSOR=${COMPRESSOR} \
88-
bash ${DRIVERS_TOOLS}/.evergreen/run-orchestration.sh
31+
binary: bash
32+
add_expansions_to_env: true
33+
env:
34+
MONGODB_VERSION: ${VERSION}
35+
TOPOLOGY: ${TOPOLOGY}
36+
AUTH: ${AUTH}
37+
SSL: ${SSL}
38+
ORCHESTRATION_FILE: ${ORCHESTRATION_FILE}
39+
REQUIRE_API_VERSION: ${REQUIRE_API_VERSION}
40+
LOAD_BALANCER: ${LOAD_BALANCER}
41+
COMPRESSOR: ${COMPRESSOR}
42+
args:
43+
- ${DRIVERS_TOOLS}/.evergreen/run-orchestration.sh
8944
- command: expansions.update
9045
params:
9146
file: mo-expansion.yml
@@ -2253,7 +2208,6 @@ task_groups:
22532208
setup_group_timeout_secs: 1800
22542209
setup_group:
22552210
- func: fetch source
2256-
- func: prepare resources
22572211
- command: shell.exec
22582212
params:
22592213
shell: bash
@@ -2284,7 +2238,6 @@ task_groups:
22842238
- .serverless
22852239
pre:
22862240
- func: fetch source
2287-
- func: prepare resources
22882241
- func: windows fix
22892242
- func: fix absolute paths
22902243
- func: make files executable

.evergreen/prepare-shell.sh

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#! /usr/bin/env bash
2+
3+
set -o xtrace
4+
set -o errexit
5+
6+
PROJECT_DIRECTORY="$(pwd)"
7+
DRIVERS_TOOLS=$(cd .. && echo "$(pwd)/drivers-tools")
8+
MONGO_ORCHESTRATION_HOME="$DRIVERS_TOOLS/.evergreen/orchestration"
9+
MONGODB_BINARIES="$DRIVERS_TOOLS/mongodb/bin"
10+
UPLOAD_BUCKET="$project"
11+
12+
# fix paths on windows
13+
if [ "Windows_NT" = "${OS:-notWindows}" ]; then
14+
DRIVERS_TOOLS=$(cygpath -m -a "$DRIVERS_TOOLS")
15+
MONGO_ORCHESTRATION_HOME=$(cygpath -m -a "$MONGO_ORCHESTRATION_HOME")
16+
MONGODB_BINARIES=$(cygpath -m -a "$MONGODB_BINARIES")
17+
PROJECT_DIRECTORY=$(cygpath -m -a "$PROJECT_DIRECTORY")
18+
fi
19+
20+
export PROJECT_DIRECTORY
21+
export DRIVERS_TOOLS
22+
export MONGO_ORCHESTRATION_HOME
23+
export MONGODB_BINARIES
24+
25+
if [ ! -d "$DRIVERS_TOOLS" ]; then
26+
# Only clone driver tools if it does not exist
27+
git clone --depth=1 "https://github.com/mongodb-labs/drivers-evergreen-tools.git" "${DRIVERS_TOOLS}"
28+
fi
29+
30+
echo "{ \"releases\": { \"default\": \"$MONGODB_BINARIES\" }}" > "$MONGO_ORCHESTRATION_HOME/orchestration.config"
31+
32+
cat <<EOT > expansion.yml
33+
DRIVERS_TOOLS: "$DRIVERS_TOOLS"
34+
MONGO_ORCHESTRATION_HOME: "$MONGO_ORCHESTRATION_HOME"
35+
MONGODB_BINARIES: "$MONGODB_BINARIES"
36+
UPLOAD_BUCKET: "$UPLOAD_BUCKET"
37+
PROJECT_DIRECTORY: "$PROJECT_DIRECTORY"
38+
PREPARE_SHELL: |
39+
set -o errexit
40+
set -o xtrace
41+
export DRIVERS_TOOLS="$DRIVERS_TOOLS"
42+
export MONGO_ORCHESTRATION_HOME="$MONGO_ORCHESTRATION_HOME"
43+
export MONGODB_BINARIES="$MONGODB_BINARIES"
44+
export UPLOAD_BUCKET="$UPLOAD_BUCKET"
45+
export PROJECT_DIRECTORY="$PROJECT_DIRECTORY"
46+
47+
export TMPDIR="$MONGO_ORCHESTRATION_HOME/db"
48+
export PATH="$MONGODB_BINARIES:$PATH"
49+
export PROJECT="${project}"
50+
EOT
51+
# See what we've done
52+
cat expansion.yml

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ output
6969
serverless-expansion.yml
7070
serverless.env
7171

72+
expansion.yml
7273
lb-expansion.yml
7374
lb.env
7475

0 commit comments

Comments
 (0)