Skip to content

Commit

Permalink
chore(ci): continuous matrix testing support (#2631)
Browse files Browse the repository at this point in the history
  • Loading branch information
emadum authored Nov 24, 2020
1 parent 7efbba0 commit 57bb3a0
Show file tree
Hide file tree
Showing 4 changed files with 158 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .evergreen/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@ functions:
fi
export DRIVERS_TOOLS="$(pwd)/../drivers-tools"
export PROJECT_DIRECTORY="$(pwd)"
if [ "Windows_NT" = "$OS" ]; then
export PROJECT_DIRECTORY=$(cygpath -m $PROJECT_DIRECTORY)
fi
export MONGO_ORCHESTRATION_HOME="$DRIVERS_TOOLS/.evergreen/orchestration"
export MONGODB_BINARIES="$DRIVERS_TOOLS/mongodb/bin"
export UPLOAD_BUCKET="${project}"
Expand Down
5 changes: 5 additions & 0 deletions .evergreen/config.yml.in
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,12 @@ functions:
fi

export DRIVERS_TOOLS="$(pwd)/../drivers-tools"

export PROJECT_DIRECTORY="$(pwd)"
if [ "Windows_NT" = "$OS" ]; then
export PROJECT_DIRECTORY=$(cygpath -m $PROJECT_DIRECTORY)
fi

export MONGO_ORCHESTRATION_HOME="$DRIVERS_TOOLS/.evergreen/orchestration"
export MONGODB_BINARIES="$DRIVERS_TOOLS/mongodb/bin"
export UPLOAD_BUCKET="${project}"
Expand Down
88 changes: 81 additions & 7 deletions .evergreen/install-dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
# set -o xtrace # Write all commands first to stderr
set -o errexit # Exit the script with error if any of the commands fail

echo "in .evergreen/install-dependencies.sh - SKIP_INSTALL=$SKIP_INSTALL"

NVM_WINDOWS_URL="https://github.com/coreybutler/nvm-windows/releases/download/1.1.7/nvm-noinstall.zip"
NVM_URL="https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh"

NODE_LTS_NAME=${NODE_LTS_NAME:-carbon}
NODE_ARTIFACTS_PATH="${PROJECT_DIRECTORY}/node-artifacts"
NPM_CACHE_DIR="${NODE_ARTIFACTS_PATH}/npm"
Expand All @@ -16,22 +21,91 @@ mkdir -p ${NODE_ARTIFACTS_PATH}
mkdir -p ${NPM_CACHE_DIR}
mkdir -p "${NPM_TMP_DIR}"

# install Node.js
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.35.3/install.sh | bash
[ -s "${NVM_DIR}/nvm.sh" ] && \. "${NVM_DIR}/nvm.sh"
nvm install --no-progress --lts=${NODE_LTS_NAME}
node_lts_version () {
case $1 in
"argon")
VERSION=4
;;
"boron")
VERSION=6
;;
"carbon")
VERSION=8
;;
"dubnium")
VERSION=10
;;
"erbium")
VERSION=12
;;
"fermium")
VERSION=14
;;
*)
echo "Unsupported Node LTS version $1"
exit 1
;;
esac
NODE_VERSION=$(curl -s -o- https://nodejs.org/download/release/latest-v${VERSION}.x/SHASUMS256.txt \
| head -n 1 | awk '{print $2};' | cut -d- -f2)
export NODE_VERSION=${NODE_VERSION:1}
}

# install Node.js on Windows
if [[ "$OS" == "Windows_NT" || "$PLATFORM" == "windows-64" ]]; then
echo "--- Installing nvm on Windows ---"
node_lts_version $NODE_LTS_NAME
echo "NODE_VERSION=$NODE_VERSION"

export NVM_HOME=`cygpath -w "$NVM_DIR"`
export NVM_SYMLINK=`cygpath -w "$NODE_ARTIFACTS_PATH/bin"`
export NVM_ARTIFACTS_PATH=`cygpath -w "$NODE_ARTIFACTS_PATH/bin"`
export PATH=`cygpath $NVM_SYMLINK`:`cygpath $NVM_HOME`:$PATH

curl -L $NVM_WINDOWS_URL -o nvm.zip
unzip -d $NVM_DIR nvm.zip
rm nvm.zip

chmod 777 $NVM_DIR
chmod -R a+rx $NVM_DIR

# setup npm cache in a local directory
cat <<EOT > .npmrc
cat <<EOT > $NVM_DIR/settings.txt
root: $NVM_HOME
path: $NVM_SYMLINK
EOT
nvm install $NODE_VERSION
nvm use $NODE_VERSION

npm config set msvs_version 2017
echo "Windows install done"

# install Node.js on Linux/MacOS
else
echo "--- Installing nvm on Linux/MacOS ---"
curl -o- $NVM_URL | bash
[ -s "${NVM_DIR}/nvm.sh" ] && \. "${NVM_DIR}/nvm.sh"
nvm install --no-progress --lts=${NODE_LTS_NAME}

# setup npm cache in a local directory
cat <<EOT > .npmrc
devdir=${NPM_CACHE_DIR}/.node-gyp
init-module=${NPM_CACHE_DIR}/.npm-init.js
cache=${NPM_CACHE_DIR}
tmp=${NPM_TMP_DIR}
registry=https://registry.npmjs.org
EOT

echo "Linux/MacOS install done"

fi

# NOTE: registry was overridden to not use artifactory, remove the `registry` line when
# BUILD-6774 is resolved.

# install node dependencies
npm install --unsafe-perm
if [[ "$SKIP_INSTALL" == "1" ]]; then
echo "Skipping npm install"
else
echo "Running npm install"
npm install --unsafe-perm
fi
67 changes: 67 additions & 0 deletions .evergreen/run-versioned-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/bin/bash
# set -o xtrace # Write all commands first to stderr
set -o errexit # Exit the script with error if any of the commands fail

DRIVER_VERSION=$1
echo "MONGODB_URI=$MONGODB_URI VERSION=$VERSION TOPOLOGY=$TOPOLOGY AUTH=$AUTH SSL=$SSL"
echo "PLATFORM=$PLATFORM DRIVER_VERSION=$DRIVER_VERSION"

ADDITIONAL_DEPS=:

case $DRIVER_VERSION in
'3.6')
VERSION_DESC="v3.6"
TEST_COMMAND='npm run test-nolint'
;;
'fix-srv-test-timeout')
VERSION_DESC="v3.6 (debug branch)"
TEST_COMMAND='npm run test-nolint'
;;
'3.3')
VERSION_DESC="v3.3"
TEST_COMMAND='npm run test-nolint'
;;
'3.1')
VERSION_DESC="v3.1"
if [[ $TOPOLOGY == "server" ]]; then
MONGODB_ENVIRONMENT='single'
else
MONGODB_ENVIRONMENT=$TOPOLOGY
fi
export MONGODB_ENVIRONMENT
export MONGODB_VERSION=$VERSION
ADDITIONAL_DEPS="npm install emadum/mongodb-test-runner#continuous-matrix-testing"
TEST_COMMAND="./node_modules/.bin/mongodb-test-runner -s -l test/unit test/functional"
;;
*)
echo "Unsupported driver version: $DRIVER_VERSION"
exit 1
;;
esac

echo "Testing NodeJS driver $VERSION_DESC"
echo "TEST_COMMAND=$TEST_COMMAND"

export PROJECT_DIRECTORY=$(cd $(dirname ${BASH_SOURCE[0]}) && cd .. && pwd)
export NODE_LTS_NAME=dubnium
export SKIP_INSTALL=1

if [[ $OS == "Windows_NT" || $PLATFORM == "windows-64" ]]; then
export PROJECT_DIRECTORY=`cygpath -w "$PROJECT_DIRECTORY"`
fi

echo "PROJECT_DIRECTORY=$PROJECT_DIRECTORY NODE_LTS_NAME=$NODE_LTS_NAME"

cd $PROJECT_DIRECTORY

echo "1. Installing driver depenencies"
bash .evergreen/install-dependencies.sh
echo "2. Driver dependencies installed, running test suite"

git checkout $DRIVER_VERSION
echo "3. Checked out version branch, running dependency installation"

npm install --unsafe-perm
echo "4. Library dependencies installed, running test suite"
$ADDITIONAL_DEPS
$TEST_COMMAND

0 comments on commit 57bb3a0

Please sign in to comment.