Skip to content

Commit 45bc86d

Browse files
authored
chore(ci): evergreen integration
NODE-886
1 parent 55f529c commit 45bc86d

File tree

5 files changed

+241
-18
lines changed

5 files changed

+241
-18
lines changed

.evergreen/config.yml

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
# Run previous commits to pinpoint a failure's origin.
2+
stepback: true
3+
4+
# Mark failures other than test failures with a purple box.
5+
command_type: system
6+
7+
# Limit maximum test running time.
8+
exec_timeout_secs: 900 # 15 minutes
9+
10+
# What to do when evergreen hits the timeout
11+
timeout:
12+
- command: shell.exec
13+
params:
14+
script: |
15+
ls -la
16+
17+
functions:
18+
fetch source:
19+
- command: git.get_project
20+
params:
21+
directory: src
22+
- command: shell.exec
23+
params:
24+
working_dir: src
25+
script: |
26+
# Get the current unique version of this checkout
27+
if [ "${is_patch}" = "true" ]; then
28+
CURRENT_VERSION=$(git describe)-patch-${version_id}
29+
else
30+
CURRENT_VERSION=latest
31+
fi
32+
export PROJECT_DIRECTORY="$(pwd)"
33+
if [ "Windows_NT" = "$OS" ]; then
34+
export PROJECT_DIRECTORY=$(cygpath -m $PROJECT_DIRECTORY)
35+
fi
36+
37+
# get the latest version of node for given major version
38+
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)
39+
echo "LATEST NODE ${NODE_MAJOR_VERSION}.x = $NODE_VERSION"
40+
41+
cat <<EOT > expansion.yml
42+
CURRENT_VERSION: "$CURRENT_VERSION"
43+
PROJECT_DIRECTORY: "$PROJECT_DIRECTORY"
44+
NODE_VERSION: "$NODE_VERSION"
45+
PREPARE_SHELL: |
46+
set -o errexit
47+
set -o xtrace
48+
export PROJECT_DIRECTORY="$PROJECT_DIRECTORY"
49+
export NODE_VERSION="$NODE_VERSION"
50+
EOT
51+
# See what we've done
52+
cat expansion.yml
53+
- command: expansions.update
54+
params:
55+
file: src/expansion.yml
56+
install dependencies:
57+
- command: shell.exec
58+
type: setup
59+
params:
60+
working_dir: src
61+
script: |
62+
${PREPARE_SHELL}
63+
echo "NODE_VERSION=${NODE_VERSION}"
64+
NODE_VERSION=${NODE_VERSION} ${PROJECT_DIRECTORY}/.evergreen/install-dependencies.sh
65+
run tests:
66+
- command: shell.exec
67+
type: test
68+
params:
69+
working_dir: src
70+
script: |
71+
${PREPARE_SHELL}
72+
echo "NODE_VERSION=${NODE_VERSION} TEST_TARGET=${TEST_TARGET}"
73+
NODE_VERSION=${NODE_VERSION} ${PROJECT_DIRECTORY}/.evergreen/run-tests.sh ${TEST_TARGET}
74+
75+
tasks:
76+
- name: node-tests-v6
77+
tags: ["node"]
78+
commands:
79+
- func: fetch source
80+
vars:
81+
NODE_MAJOR_VERSION: 6
82+
- func: install dependencies
83+
- func: run tests
84+
vars:
85+
TEST_TARGET: node
86+
- name: node-tests-v8
87+
tags: ["node"]
88+
commands:
89+
- func: fetch source
90+
vars:
91+
NODE_MAJOR_VERSION: 8
92+
- func: install dependencies
93+
- func: run tests
94+
vars:
95+
TEST_TARGET: node
96+
- name: node-tests-v10
97+
tags: ["node"]
98+
commands:
99+
- func: fetch source
100+
vars:
101+
NODE_MAJOR_VERSION: 10
102+
- func: install dependencies
103+
- func: run tests
104+
vars:
105+
TEST_TARGET: node
106+
- name: node-tests-v12
107+
tags: ["node"]
108+
commands:
109+
- func: fetch source
110+
vars:
111+
NODE_MAJOR_VERSION: 12
112+
- func: install dependencies
113+
- func: run tests
114+
vars:
115+
TEST_TARGET: node
116+
- name: node-tests-v14
117+
tags: ["node"]
118+
commands:
119+
- func: fetch source
120+
vars:
121+
NODE_MAJOR_VERSION: 14
122+
- func: install dependencies
123+
- func: run tests
124+
vars:
125+
TEST_TARGET: node
126+
- name: browser-tests
127+
tags: ["browser"]
128+
commands:
129+
- func: fetch source
130+
vars:
131+
NODE_MAJOR_VERSION: 10
132+
- func: install dependencies
133+
- func: run tests
134+
vars:
135+
TEST_TARGET: browser
136+
137+
buildvariants:
138+
- name: linux
139+
display_name: Ubuntu 18.04
140+
run_on: ubuntu1804-test
141+
tasks: [".node", ".browser"]
142+
- name: mac
143+
display_name: MacOS 10.14
144+
run_on: macos-1014
145+
tasks: [".node"]
146+
- name: windows
147+
display_name: Windows 64
148+
run_on: windows-64-vsMulti-small
149+
tasks: [".node"]

.evergreen/install-dependencies.sh

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/bin/bash
2+
if [ -z "$NODE_VERSION" ]; then
3+
echo "NODE_VERSION environment variable must be specified"
4+
exit 1
5+
fi
6+
7+
NODE_ARTIFACTS_PATH="${PROJECT_DIRECTORY}/node-artifacts"
8+
NPM_CACHE_DIR="${NODE_ARTIFACTS_PATH}/npm"
9+
NPM_TMP_DIR="${NODE_ARTIFACTS_PATH}/tmp"
10+
11+
NVM_WINDOWS_URL="https://github.com/coreybutler/nvm-windows/releases/download/1.1.7/nvm-noinstall.zip"
12+
NVM_URL="https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh"
13+
14+
# this needs to be explicitly exported for the nvm install below
15+
export NVM_DIR="${NODE_ARTIFACTS_PATH}/nvm"
16+
export XDG_CONFIG_HOME=${NODE_ARTIFACTS_PATH}
17+
18+
# create node artifacts path if needed
19+
mkdir -p ${NVM_DIR}
20+
mkdir -p ${NPM_CACHE_DIR}
21+
mkdir -p "${NPM_TMP_DIR}"
22+
23+
# install Node.js
24+
echo "--- Installing Node ${NODE_VERSION} --- "
25+
if [ "$OS" == "Windows_NT" ]; then
26+
export NVM_HOME=`cygpath -w "$NVM_DIR"`
27+
export NVM_SYMLINK=`cygpath -w "$NODE_ARTIFACTS_PATH/bin"`
28+
export PATH=`cygpath $NVM_SYMLINK`:`cygpath $NVM_HOME`:$PATH
29+
30+
# download and install nvm
31+
curl -L $NVM_WINDOWS_URL -o nvm.zip
32+
unzip -d $NVM_DIR nvm.zip
33+
rm nvm.zip
34+
35+
chmod 777 $NVM_DIR
36+
chmod -R a+rx $NVM_DIR
37+
38+
cat <<EOT > $NVM_DIR/settings.txt
39+
root: $NVM_HOME
40+
path: $NVM_SYMLINK
41+
EOT
42+
43+
nvm install ${NODE_VERSION}
44+
else
45+
curl -o- $NVM_URL | bash
46+
[ -s "${NVM_DIR}/nvm.sh" ] && \. "${NVM_DIR}/nvm.sh"
47+
48+
nvm install --no-progress ${NODE_VERSION}
49+
fi
50+
nvm use ${NODE_VERSION}
51+
52+
# setup npm cache in a local directory
53+
cat <<EOT > .npmrc
54+
devdir=${NPM_CACHE_DIR}/.node-gyp
55+
init-module=${NPM_CACHE_DIR}/.npm-init.js
56+
cache=${NPM_CACHE_DIR}
57+
tmp=${NPM_TMP_DIR}
58+
registry=https://registry.npmjs.org
59+
EOT
60+
61+
# install node dependencies
62+
npm install

.evergreen/run-tests.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/bash
2+
if [ -z "$NODE_VERSION" ]; then
3+
echo "NODE_VERSION environment variable must be specified"
4+
exit 1
5+
fi
6+
7+
NODE_ARTIFACTS_PATH="${PROJECT_DIRECTORY}/node-artifacts"
8+
9+
if [ "$OS" == "Windows_NT" ]; then
10+
export NVM_HOME=`cygpath -w "$NODE_ARTIFACTS_PATH/nvm"`
11+
export NVM_SYMLINK=`cygpath -w "$NODE_ARTIFACTS_PATH/bin"`
12+
export PATH=`cygpath $NVM_SYMLINK`:`cygpath $NVM_HOME`:$PATH
13+
else
14+
export PATH="/opt/mongodbtoolchain/v2/bin:$PATH"
15+
export NVM_DIR="${NODE_ARTIFACTS_PATH}/nvm"
16+
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
17+
fi
18+
19+
case $1 in
20+
"node")
21+
npm run lint && npm run test-node
22+
;;
23+
"browser")
24+
npm run lint && npm run test-browser
25+
;;
26+
*)
27+
npm test
28+
;;
29+
esac

.travis.yml

Lines changed: 0 additions & 17 deletions
This file was deleted.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
"scripts": {
6262
"docs": "jsdoc2md --heading-depth 3 --template tools/README.hbs --plugin dmd-clear --files lib/bson.js lib/extended_json.js > README.md",
6363
"test": "npm run-script lint && npm run-script test-node && npm run-script test-browser",
64-
"test-node": "node --throw-deprecation node_modules/.bin/_mocha ./test/node",
64+
"test-node": "node --throw-deprecation node_modules/mocha/bin/_mocha ./test/node",
6565
"test-browser": "npm run-script build && node --throw-deprecation node_modules/.bin/karma start",
6666
"build": "rollup -c",
6767
"lint": "eslint lib test",

0 commit comments

Comments
 (0)