Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions .evergreen/connect.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/bin/bash
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The motivation for moving this into a separate script file is to make it easier to run locally. I build in a directory named cmake-build and can run this locally as follows:

MONGOC_INSTALL_PREFIX=/Users/kevin.albertson/install/mongo-c-driver-1.18.0 \
MONGOCXX_INSTALL_PREFIX=/Users/kevin.albertson/install/mongo-cxx-driver-dev \
LIB_DIR="lib" \
BUILD_TYPE="Debug" \
BUILD_DIR=$(pwd)/cmake-build \
URI="mongodb://localhost:27017/?" \
    ./.evergreen/connect.sh

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a place (even as an extended comment at the beginning of the script, but perhaps as a help screen?) where you can put a scrubbed version of this example? Sounds very useful!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, done!


set -o errexit
set -o pipefail

LIB_DIR=${LIB_DIR:-"lib"}
BUILD_TYPE=${BUILD_TYPE:-"Debug"}

print_usage_and_exit () {
echo "Error: $1"
cat << EOF
connect.sh runs the connect example with a MongoDB URI.

Example usage:
MONGOC_INSTALL_PREFIX=/Users/kevin.albertson/install/mongo-c-driver-1.18.0 \\
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Up to you if you want to leave your name in here, or if it should be scrubbed. I am fine with it as-is.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leaving as-is.

MONGOCXX_INSTALL_PREFIX=/Users/kevin.albertson/install/mongo-cxx-driver-dev \\
LIB_DIR="lib" \\
BUILD_TYPE="Debug" \\
BUILD_DIR=$(pwd)/cmake-build \\
URI="mongodb://localhost:27017/?" \\
./.evergreen/connect.sh
EOF
exit 1;
}

if [ -z "$URI" ]; then
print_usage_and_exit "URI is a required environment variable."
fi
if [ -z "$MONGOC_INSTALL_PREFIX" ]; then
print_usage_and_exit "MONGOC_INSTALL_PREFIX is a required environment variable."
fi
if [ -z "$MONGOCXX_INSTALL_PREFIX" ]; then
print_usage_and_exit "MONGOCXX_INSTALL_PREFIX is a required environment variable."
fi
if [ -z "$BUILD_DIR" ]; then
print_usage_and_exit "BUILD_DIR is a required environment variable."
fi

# Use PATH / LD_LIBRARY_PATH / DYLD_LIBRARY_PATH to inform the tests where to find
# mongoc library dependencies on Windows / Linux / Mac OS, respectively.
export PATH=$PATH:$MONGOC_INSTALL_PREFIX/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$MONGOC_INSTALL_PREFIX/$LIB_DIR/
export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:$MONGOC_INSTALL_PREFIX/$LIB_DIR/

# Windows also needs to be informed where to find mongocxx library dependencies.
export PATH=$PATH:$BUILD_DIR/src/bsoncxx/$BUILD_TYPE
export PATH=$PATH:$BUILD_DIR/src/mongocxx/$BUILD_TYPE
export PATH=$PATH:$MONGOCXX_INSTALL_PREFIX/bin

if [ "Windows_NT" == "$OS" ]; then
$BUILD_DIR/examples/mongocxx/$BUILD_TYPE/connect.exe "$URI"
else
$BUILD_DIR/examples/mongocxx/connect "$URI"
fi
50 changes: 27 additions & 23 deletions .mci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -471,32 +471,35 @@ functions:
shell: bash
working_dir: "mongo-cxx-driver"
script: |
set -o errexit
set -o pipefail
export PATH="${extra_path}:$PATH"
cd build
export PREFIX=$(pwd)/../../mongoc
set -o xtrace

# Use PATH / LD_LIBRARY_PATH / DYLD_LIBRARY_PATH to inform the tests where to find
# mongoc library dependencies on Windows / Linux / Mac OS, respectively.
# Additionally, on Windows, we also need to inform the tests where to find
# mongocxx library dependencies.
if [ -n "${lib_dir}" ]; then
export LD_LIBRARY_PATH=.:$PREFIX/${lib_dir}/
export DYLD_LIBRARY_PATH=.:$PREFIX/${lib_dir}/
else
export LD_LIBRARY_PATH=.:$PREFIX/lib/
export DYLD_LIBRARY_PATH=.:$PREFIX/lib/
fi
export PATH=$(pwd)/src/bsoncxx/${build_type}:$(pwd)/src/mongocxx/${build_type}:$PREFIX/bin:$(pwd)/install/bin:$PATH
export MONGOC_INSTALL_PREFIX=$(pwd)/../mongoc
export MONGOCXX_INSTALL_PREFIX=$(pwd)/build/install
export LIB_DIR=${lib_dir}
export BUILD_TYPE=${build_type}
export BUILD_DIR=$(pwd)/build
export URI="mongodb://bob:pwd123@localhost"
./.evergreen/connect.sh

"test atlas connectivity":
- command: shell.exec
params:
shell: bash
working_dir: "mongo-cxx-driver"
silent: true
script: |
set -o xtrace

URI="mongodb://bob:pwd123@localhost"
export MONGOC_INSTALL_PREFIX=$(pwd)/../mongoc
export MONGOCXX_INSTALL_PREFIX=$(pwd)/build/install
export LIB_DIR=${lib_dir}
export BUILD_TYPE=${build_type}
export BUILD_DIR=$(pwd)/build

if [ "Windows_NT" == "$OS" ]; then
./examples/mongocxx/${build_type}/connect.exe "$URI"
else
./examples/mongocxx/connect "$URI"
fi
# The atlas_serverless_uri expansion is set in the Evergreen project settings.
export URI="${atlas_serverless_uri}"

./.evergreen/connect.sh

"backtrace":
- command: shell.exec
Expand Down Expand Up @@ -626,6 +629,7 @@ tasks:
- func: "install_c_driver"
- func: "compile"
- func: "test auth"
- func: "test atlas connectivity"

- name: compile_and_test_with_static_libs
commands:
Expand Down