Skip to content

Commit

Permalink
chore(ci): evergreen integration
Browse files Browse the repository at this point in the history
  • Loading branch information
emadum authored Jul 28, 2020
1 parent 55f529c commit 45bc86d
Show file tree
Hide file tree
Showing 5 changed files with 241 additions and 18 deletions.
149 changes: 149 additions & 0 deletions .evergreen/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
# Run previous commits to pinpoint a failure's origin.
stepback: true

# Mark failures other than test failures with a purple box.
command_type: system

# Limit maximum test running time.
exec_timeout_secs: 900 # 15 minutes

# What to do when evergreen hits the timeout
timeout:
- command: shell.exec
params:
script: |
ls -la
functions:
fetch source:
- command: git.get_project
params:
directory: src
- 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 PROJECT_DIRECTORY="$(pwd)"
if [ "Windows_NT" = "$OS" ]; then
export PROJECT_DIRECTORY=$(cygpath -m $PROJECT_DIRECTORY)
fi
# get the latest version of node for given major version
NODE_VERSION=$(curl -sL nodejs.org/download/release/latest-v${NODE_MAJOR_VERSION}.x/SHASUMS256.txt -o - | head -n 1 | tr -s ' ' | cut -d' ' -f2 | cut -d- -f2 | cut -dv -f2)
echo "LATEST NODE ${NODE_MAJOR_VERSION}.x = $NODE_VERSION"
cat <<EOT > expansion.yml
CURRENT_VERSION: "$CURRENT_VERSION"
PROJECT_DIRECTORY: "$PROJECT_DIRECTORY"
NODE_VERSION: "$NODE_VERSION"
PREPARE_SHELL: |
set -o errexit
set -o xtrace
export PROJECT_DIRECTORY="$PROJECT_DIRECTORY"
export NODE_VERSION="$NODE_VERSION"
EOT
# See what we've done
cat expansion.yml
- command: expansions.update
params:
file: src/expansion.yml
install dependencies:
- command: shell.exec
type: setup
params:
working_dir: src
script: |
${PREPARE_SHELL}
echo "NODE_VERSION=${NODE_VERSION}"
NODE_VERSION=${NODE_VERSION} ${PROJECT_DIRECTORY}/.evergreen/install-dependencies.sh
run tests:
- command: shell.exec
type: test
params:
working_dir: src
script: |
${PREPARE_SHELL}
echo "NODE_VERSION=${NODE_VERSION} TEST_TARGET=${TEST_TARGET}"
NODE_VERSION=${NODE_VERSION} ${PROJECT_DIRECTORY}/.evergreen/run-tests.sh ${TEST_TARGET}
tasks:
- name: node-tests-v6
tags: ["node"]
commands:
- func: fetch source
vars:
NODE_MAJOR_VERSION: 6
- func: install dependencies
- func: run tests
vars:
TEST_TARGET: node
- name: node-tests-v8
tags: ["node"]
commands:
- func: fetch source
vars:
NODE_MAJOR_VERSION: 8
- func: install dependencies
- func: run tests
vars:
TEST_TARGET: node
- name: node-tests-v10
tags: ["node"]
commands:
- func: fetch source
vars:
NODE_MAJOR_VERSION: 10
- func: install dependencies
- func: run tests
vars:
TEST_TARGET: node
- name: node-tests-v12
tags: ["node"]
commands:
- func: fetch source
vars:
NODE_MAJOR_VERSION: 12
- func: install dependencies
- func: run tests
vars:
TEST_TARGET: node
- name: node-tests-v14
tags: ["node"]
commands:
- func: fetch source
vars:
NODE_MAJOR_VERSION: 14
- func: install dependencies
- func: run tests
vars:
TEST_TARGET: node
- name: browser-tests
tags: ["browser"]
commands:
- func: fetch source
vars:
NODE_MAJOR_VERSION: 10
- func: install dependencies
- func: run tests
vars:
TEST_TARGET: browser

buildvariants:
- name: linux
display_name: Ubuntu 18.04
run_on: ubuntu1804-test
tasks: [".node", ".browser"]
- name: mac
display_name: MacOS 10.14
run_on: macos-1014
tasks: [".node"]
- name: windows
display_name: Windows 64
run_on: windows-64-vsMulti-small
tasks: [".node"]
62 changes: 62 additions & 0 deletions .evergreen/install-dependencies.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/bin/bash
if [ -z "$NODE_VERSION" ]; then
echo "NODE_VERSION environment variable must be specified"
exit 1
fi

NODE_ARTIFACTS_PATH="${PROJECT_DIRECTORY}/node-artifacts"
NPM_CACHE_DIR="${NODE_ARTIFACTS_PATH}/npm"
NPM_TMP_DIR="${NODE_ARTIFACTS_PATH}/tmp"

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"

# this needs to be explicitly exported for the nvm install below
export NVM_DIR="${NODE_ARTIFACTS_PATH}/nvm"
export XDG_CONFIG_HOME=${NODE_ARTIFACTS_PATH}

# create node artifacts path if needed
mkdir -p ${NVM_DIR}
mkdir -p ${NPM_CACHE_DIR}
mkdir -p "${NPM_TMP_DIR}"

# install Node.js
echo "--- Installing Node ${NODE_VERSION} --- "
if [ "$OS" == "Windows_NT" ]; then
export NVM_HOME=`cygpath -w "$NVM_DIR"`
export NVM_SYMLINK=`cygpath -w "$NODE_ARTIFACTS_PATH/bin"`
export PATH=`cygpath $NVM_SYMLINK`:`cygpath $NVM_HOME`:$PATH

# download and install nvm
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

cat <<EOT > $NVM_DIR/settings.txt
root: $NVM_HOME
path: $NVM_SYMLINK
EOT

nvm install ${NODE_VERSION}
else
curl -o- $NVM_URL | bash
[ -s "${NVM_DIR}/nvm.sh" ] && \. "${NVM_DIR}/nvm.sh"

nvm install --no-progress ${NODE_VERSION}
fi
nvm use ${NODE_VERSION}

# 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

# install node dependencies
npm install
29 changes: 29 additions & 0 deletions .evergreen/run-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash
if [ -z "$NODE_VERSION" ]; then
echo "NODE_VERSION environment variable must be specified"
exit 1
fi

NODE_ARTIFACTS_PATH="${PROJECT_DIRECTORY}/node-artifacts"

if [ "$OS" == "Windows_NT" ]; then
export NVM_HOME=`cygpath -w "$NODE_ARTIFACTS_PATH/nvm"`
export NVM_SYMLINK=`cygpath -w "$NODE_ARTIFACTS_PATH/bin"`
export PATH=`cygpath $NVM_SYMLINK`:`cygpath $NVM_HOME`:$PATH
else
export PATH="/opt/mongodbtoolchain/v2/bin:$PATH"
export NVM_DIR="${NODE_ARTIFACTS_PATH}/nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
fi

case $1 in
"node")
npm run lint && npm run test-node
;;
"browser")
npm run lint && npm run test-browser
;;
*)
npm test
;;
esac
17 changes: 0 additions & 17 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"scripts": {
"docs": "jsdoc2md --heading-depth 3 --template tools/README.hbs --plugin dmd-clear --files lib/bson.js lib/extended_json.js > README.md",
"test": "npm run-script lint && npm run-script test-node && npm run-script test-browser",
"test-node": "node --throw-deprecation node_modules/.bin/_mocha ./test/node",
"test-node": "node --throw-deprecation node_modules/mocha/bin/_mocha ./test/node",
"test-browser": "npm run-script build && node --throw-deprecation node_modules/.bin/karma start",
"build": "rollup -c",
"lint": "eslint lib test",
Expand Down

0 comments on commit 45bc86d

Please sign in to comment.