Skip to content

Commit 2a4e3db

Browse files
authored
Clean up fetch-source Evergreen function (#856)
1 parent 79bdb6d commit 2a4e3db

File tree

1 file changed

+36
-23
lines changed

1 file changed

+36
-23
lines changed

.evergreen/config.yml

Lines changed: 36 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -34,44 +34,57 @@ functions:
3434
params:
3535
working_dir: src/go.mongodb.org/mongo-driver
3636
script: |
37-
if [ "Windows_NT" = "$OS" ]; then
38-
export GOPATH=$(cygpath -w $(dirname $(dirname $(dirname `pwd`))))
39-
else
40-
export GOPATH=$(dirname $(dirname $(dirname `pwd`)))
41-
fi;
42-
43-
# Get the current unique version of this checkout
37+
# Get the current unique version of this checkout.
4438
if [ "${is_patch}" = "true" ]; then
4539
CURRENT_VERSION=$(git describe)-patch-${version_id}
4640
else
4741
CURRENT_VERSION=latest
4842
fi
4943
50-
export DRIVERS_TOOLS="$(pwd)/../drivers-tools"
51-
export PROJECT_DIRECTORY="$(pwd)"
44+
# Set Golang environment vars. GOROOT is wherever current Go distribution is; GOPATH is always 3
45+
# directories up from pwd; GOCACHE is under .cache in the pwd.
46+
export GOROOT="${GO_DIST}"
47+
export GOPATH="$(dirname $(dirname $(dirname `pwd`)))"
5248
export GOCACHE="$(pwd)/.cache"
5349
54-
# Python has cygwin path problems on Windows. Detect prospective mongo-orchestration home directory
55-
if [ "Windows_NT" = "$OS" ]; then # Magic variable in cygwin
56-
export DRIVERS_TOOLS=$(cygpath -m $DRIVERS_TOOLS)
57-
export PROJECT_DIRECTORY=$(cygpath -m $PROJECT_DIRECTORY)
58-
export GOCACHE=$(cygpath -m $GOCACHE)
59-
fi
60-
50+
# Set other relevant variables for Evergreen processes.
51+
export DRIVERS_TOOLS="$(pwd)/../drivers-tools"
52+
export PROJECT_DIRECTORY="$(pwd)"
6153
export MONGO_ORCHESTRATION_HOME="$DRIVERS_TOOLS/.evergreen/orchestration"
6254
export MONGODB_BINARIES="$DRIVERS_TOOLS/mongodb/bin"
6355
export UPLOAD_BUCKET="${project}"
64-
export PATH="${GO_DIST}/bin:${GCC_PATH}:$GOPATH/bin:$MONGODB_BINARIES:$PATH"
6556
export PROJECT="${project}"
6657
58+
# If on Windows, convert paths with cygpath. GOROOT should not be converted as Windows expects it
59+
# to be separated with '\'.
6760
if [ "Windows_NT" = "$OS" ]; then
61+
export GOPATH=$(cygpath -m $GOPATH)
62+
export GOCACHE=$(cygpath -m $GOCACHE)
63+
export DRIVERS_TOOLS=$(cygpath -m $DRIVERS_TOOLS)
64+
export PROJECT_DIRECTORY=$(cygpath -m $PROJECT_DIRECTORY)
65+
export MONGO_ORCHESTRATION_HOME=$(cygpath -m $MONGO_ORCHESTRATION_HOME)
66+
export MONGODB_BINARIES=$(cygpath -m $MONGODB_BINARIES)
67+
export UPLOAD_BUCKET=$(cygpath -m $UPLOAD_BUCKET)
68+
export PROJECT=$(cygpath -m $PROJECT)
69+
70+
# Set home variables for Windows, too.
6871
export USERPROFILE=$(cygpath -w $(dirname $(dirname $(dirname `pwd`))))
69-
export HOME=$(cygpath -w $(dirname $(dirname $(dirname `pwd`))))
72+
export HOME=$USERPROFILE
73+
fi
74+
75+
# Set actual PATH. PATH should contain binaries from GOROOT, GOPATH, GCC_PATH and mongodb.
76+
# Adding GOROOT's bin to PATH on Windows requires a cygpath conversion.
77+
export GOROOTBIN="$GOROOT/bin"
78+
if [ "Windows_NT" = "$OS" ]; then
79+
export GOROOTBIN=$(cygpath -m $GOROOTBIN)
7080
fi
81+
export PATH="$GOROOTBIN:$GOPATH/bin:${GCC_PATH}:$MONGODB_BINARIES:$PATH"
7182
83+
# Check Go installation.
7284
go version
7385
go env
7486
87+
# Install libmongocrypt based on OS.
7588
if [ "Windows_NT" = "$OS" ]; then
7689
mkdir -p c:/libmongocrypt/include
7790
mkdir -p c:/libmongocrypt/bin
@@ -94,21 +107,21 @@ functions:
94107
PROJECT_DIRECTORY: "$PROJECT_DIRECTORY"
95108
PREPARE_SHELL: |
96109
set -o errexit
110+
export GOROOT="$GOROOT"
97111
export GOPATH="$GOPATH"
98-
export GOROOT="${GO_DIST}"
99112
export GOCACHE="$GOCACHE"
100113
export DRIVERS_TOOLS="$DRIVERS_TOOLS"
114+
export PROJECT_DIRECTORY="$PROJECT_DIRECTORY"
101115
export MONGO_ORCHESTRATION_HOME="$MONGO_ORCHESTRATION_HOME"
102116
export MONGODB_BINARIES="$MONGODB_BINARIES"
103117
export UPLOAD_BUCKET="$UPLOAD_BUCKET"
104-
export PROJECT_DIRECTORY="$PROJECT_DIRECTORY"
105-
export TMPDIR="$MONGO_ORCHESTRATION_HOME/db"
106-
export PATH="$PATH"
107118
export PROJECT="$PROJECT"
119+
export TMPDIR="$MONGO_ORCHESTRATION_HOME/db"
108120
export PKG_CONFIG_PATH=$(pwd)/install/libmongocrypt/lib/pkgconfig:$(pwd)/install/mongo-c-driver/lib/pkgconfig
109121
export LD_LIBRARY_PATH=$(pwd)/install/libmongocrypt/lib
122+
export PATH="$PATH"
110123
EOT
111-
# See what we've done
124+
# See what we variables we've set.
112125
cat expansion.yml
113126
# Load the expansion file to make an evergreen variable with the current unique version
114127
- command: expansions.update

0 commit comments

Comments
 (0)