Skip to content

Commit f1b484d

Browse files
Revert "ci(NODE-5098): download node to local directory (#3583)"
This reverts commit 84fab70.
1 parent b5f1a53 commit f1b484d

File tree

7 files changed

+119
-95
lines changed

7 files changed

+119
-95
lines changed

.evergreen/config.in.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ functions:
191191
MONGODB_URI="${MONGODB_URI}" \
192192
AUTH=${AUTH} SSL=${SSL} TEST_CSFLE=true \
193193
MONGODB_API_VERSION="${MONGODB_API_VERSION}" \
194-
SKIP_DEPS=${SKIP_DEPS|1} \
194+
NODE_VERSION=${NODE_VERSION} SKIP_DEPS=${SKIP_DEPS|1} \
195195
bash ${PROJECT_DIRECTORY}/.evergreen/run-tests.sh
196196
197197
"run serverless tests":
@@ -291,6 +291,7 @@ functions:
291291
AUTH=${AUTH} \
292292
SSL=${SSL} \
293293
MONGODB_API_VERSION="${MONGODB_API_VERSION}" \
294+
NODE_VERSION=${NODE_VERSION} \
294295
SINGLE_MONGOS_LB_URI="${SINGLE_MONGOS_LB_URI}" \
295296
MULTI_MONGOS_LB_URI="${MULTI_MONGOS_LB_URI}" \
296297
TOPOLOGY="${TOPOLOGY}" \
@@ -311,6 +312,7 @@ functions:
311312
AUTH=${AUTH} \
312313
SSL=${SSL} \
313314
MONGODB_API_VERSION="${MONGODB_API_VERSION}" \
315+
NODE_VERSION=${NODE_VERSION} \
314316
TOPOLOGY="${TOPOLOGY}" \
315317
COMPRESSOR="${COMPRESSOR}" \
316318
SKIP_DEPS=${SKIP_DEPS|1} \
@@ -455,6 +457,9 @@ functions:
455457
${PREPARE_SHELL}
456458
NODE_LTS_NAME=${NODE_LTS_NAME} NPM_OPTIONS=${NPM_OPTIONS}\
457459
bash ${PROJECT_DIRECTORY}/.evergreen/install-dependencies.sh
460+
- command: expansions.update
461+
params:
462+
file: src/deps-expansion.yml
458463

459464
"install aws-credential-providers":
460465
- command: shell.exec

.evergreen/config.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ functions:
161161
MONGODB_URI="${MONGODB_URI}" \
162162
AUTH=${AUTH} SSL=${SSL} TEST_CSFLE=true \
163163
MONGODB_API_VERSION="${MONGODB_API_VERSION}" \
164-
SKIP_DEPS=${SKIP_DEPS|1} \
164+
NODE_VERSION=${NODE_VERSION} SKIP_DEPS=${SKIP_DEPS|1} \
165165
bash ${PROJECT_DIRECTORY}/.evergreen/run-tests.sh
166166
run serverless tests:
167167
- command: timeout.update
@@ -257,6 +257,7 @@ functions:
257257
AUTH=${AUTH} \
258258
SSL=${SSL} \
259259
MONGODB_API_VERSION="${MONGODB_API_VERSION}" \
260+
NODE_VERSION=${NODE_VERSION} \
260261
SINGLE_MONGOS_LB_URI="${SINGLE_MONGOS_LB_URI}" \
261262
MULTI_MONGOS_LB_URI="${MULTI_MONGOS_LB_URI}" \
262263
TOPOLOGY="${TOPOLOGY}" \
@@ -276,6 +277,7 @@ functions:
276277
AUTH=${AUTH} \
277278
SSL=${SSL} \
278279
MONGODB_API_VERSION="${MONGODB_API_VERSION}" \
280+
NODE_VERSION=${NODE_VERSION} \
279281
TOPOLOGY="${TOPOLOGY}" \
280282
COMPRESSOR="${COMPRESSOR}" \
281283
SKIP_DEPS=${SKIP_DEPS|1} \
@@ -405,6 +407,9 @@ functions:
405407
${PREPARE_SHELL}
406408
NODE_LTS_NAME=${NODE_LTS_NAME} NPM_OPTIONS=${NPM_OPTIONS}\
407409
bash ${PROJECT_DIRECTORY}/.evergreen/install-dependencies.sh
410+
- command: expansions.update
411+
params:
412+
file: src/deps-expansion.yml
408413
install aws-credential-providers:
409414
- command: shell.exec
410415
type: setup

.evergreen/init-nvm.sh

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
11
#! /usr/bin/env bash
22

33
export PATH="/opt/mongodbtoolchain/v2/bin:$PATH"
4-
54
NODE_ARTIFACTS_PATH="${PROJECT_DIRECTORY}/node-artifacts"
5+
export NVM_DIR="${NODE_ARTIFACTS_PATH}/nvm"
6+
67
if [[ "$OS" == "Windows_NT" ]]; then
7-
NODE_ARTIFACTS_PATH=$(cygpath --unix "$NODE_ARTIFACTS_PATH")
8+
NVM_HOME=$(cygpath -w "$NVM_DIR")
9+
export NVM_HOME
10+
NVM_SYMLINK=$(cygpath -w "$NODE_ARTIFACTS_PATH/bin")
11+
export NVM_SYMLINK
12+
NVM_ARTIFACTS_PATH=$(cygpath -w "$NODE_ARTIFACTS_PATH/bin")
13+
export NVM_ARTIFACTS_PATH
14+
PATH=$(cygpath $NVM_SYMLINK):$(cygpath $NVM_HOME):$PATH
15+
export PATH
16+
echo "updated path on windows PATH=$PATH"
17+
else
18+
[ -s "$NVM_DIR/nvm.sh" ] && source "$NVM_DIR/nvm.sh"
819
fi
920

10-
export PATH="$NODE_ARTIFACTS_PATH/npm_global/bin:$NODE_ARTIFACTS_PATH/nodejs/bin:$PATH"
11-
hash -r
12-
1321
export NODE_OPTIONS="--trace-deprecation --trace-warnings"

.evergreen/install-dependencies.sh

Lines changed: 92 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,95 +1,105 @@
1-
#!/usr/bin/env bash
1+
#!/bin/bash
22
set -o errexit # Exit the script with error if any of the commands fail
33

4-
NODE_LTS_NAME=${NODE_LTS_NAME:-fermium}
5-
NODE_ARTIFACTS_PATH="${PROJECT_DIRECTORY:-$(pwd)}/node-artifacts"
6-
if [[ "$OS" = "Windows_NT" ]]; then NODE_ARTIFACTS_PATH=$(cygpath --unix "$NODE_ARTIFACTS_PATH"); fi
7-
8-
mkdir -p "$NODE_ARTIFACTS_PATH/npm_global"
9-
10-
# Comparisons are all case insensitive
11-
shopt -s nocasematch
12-
13-
# index.tab is a sorted tab separated values file with the following headers
14-
# 0 1 2 3 4 5 6 7 8 9 10
15-
# version date files npm v8 uv zlib openssl modules lts security
16-
curl --retry 8 -sS "https://nodejs.org/dist/index.tab" --max-time 300 --output node_index.tab
17-
18-
while IFS=$'\t' read -r -a row; do
19-
node_index_version="${row[0]}"
20-
node_index_date="${row[1]}"
21-
node_index_lts="${row[9]}"
22-
[[ "$node_index_version" = "version" ]] && continue # skip tsv header
23-
[[ "$NODE_LTS_NAME" = "latest" ]] && break # first line is latest
24-
[[ "$NODE_LTS_NAME" = "$node_index_lts" ]] && break # case insensitive compare
25-
done < node_index.tab
26-
27-
if [[ "$OS" = "Windows_NT" ]]; then
28-
operating_system="win"
29-
elif [[ $(uname) = "darwin" ]]; then
30-
operating_system="darwin"
31-
elif [[ $(uname) = "linux" ]]; then
32-
operating_system="linux"
33-
else
34-
echo "Unable to determine operating system: $operating_system"
35-
exit 1
36-
fi
37-
38-
architecture=$(uname -m)
39-
if [[ $architecture = "x86_64" ]]; then
40-
architecture="x64"
41-
elif [[ $architecture = "arm64" ]]; then
42-
architecture="arm64"
43-
elif [[ $architecture == s390* ]]; then
44-
architecture="s390x"
45-
elif [[ $architecture == ppc* ]]; then
46-
architecture="ppc64le"
47-
else
48-
echo "Unable to determine operating system: $architecture"
49-
exit 1
50-
fi
51-
52-
file_extension="tar.gz"
53-
if [[ "$OS" = "Windows_NT" ]]; then file_extension="zip"; fi
4+
NVM_WINDOWS_URL="https://github.com/coreybutler/nvm-windows/releases/download/1.1.9/nvm-noinstall.zip"
5+
NVM_URL="https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh"
546

55-
node_directory="node-${node_index_version}-${operating_system}-${architecture}"
56-
node_archive="${node_directory}.${file_extension}"
57-
node_archive_path="$NODE_ARTIFACTS_PATH/${node_archive}"
58-
node_download_url="https://nodejs.org/dist/${node_index_version}/${node_archive}"
7+
NODE_LTS_NAME=${NODE_LTS_NAME:-fermium}
8+
NODE_ARTIFACTS_PATH="${PROJECT_DIRECTORY}/node-artifacts"
9+
10+
# this needs to be explicitly exported for the nvm install below
11+
export NVM_DIR="${NODE_ARTIFACTS_PATH}/nvm"
12+
export XDG_CONFIG_HOME=${NODE_ARTIFACTS_PATH}
13+
14+
# create node artifacts path if needed
15+
mkdir -p "${NODE_ARTIFACTS_PATH}"
16+
17+
function node_lts_to_version() {
18+
case $1 in
19+
"fermium")
20+
echo 14
21+
;;
22+
"gallium")
23+
echo 16
24+
;;
25+
"hydrogen")
26+
echo 18
27+
;;
28+
"iron")
29+
echo 20
30+
;;
31+
"latest")
32+
echo 'latest'
33+
;;
34+
*)
35+
echo "Unsupported Node LTS version $1"
36+
;;
37+
esac
38+
}
39+
40+
function latest_version_for_node_major() {
41+
local __NODE_MAJOR_VERSION=$1
42+
local NODE_DOWNLOAD_URI="https://nodejs.org/download/release/latest-v${__NODE_MAJOR_VERSION}.x/SHASUMS256.txt"
43+
44+
if [ $__NODE_MAJOR_VERSION == 'latest' ]
45+
then
46+
NODE_DOWNLOAD_URI="https://nodejs.org/download/release/latest/SHASUMS256.txt"
47+
fi
48+
49+
# check that the requested version does exist
50+
curl --silent --fail $NODE_DOWNLOAD_URI &> /dev/null
51+
52+
echo $(curl --retry 8 --retry-delay 5 --max-time 50 --silent -o- $NODE_DOWNLOAD_URI | head -n 1 | awk '{print $2};' | cut -d- -f2)
53+
}
54+
55+
NODE_MAJOR_VERSION=$(node_lts_to_version $NODE_LTS_NAME)
56+
NODE_VERSION=$(latest_version_for_node_major $NODE_MAJOR_VERSION)
57+
NODE_VERSION=${NODE_VERSION:1} # :1 gets rid of the leading 'v'
58+
59+
echo "set version to $NODE_VERSION"
60+
61+
# output node version to expansions file for use in subsequent scripts
62+
cat <<EOT > deps-expansion.yml
63+
NODE_VERSION: "$NODE_VERSION"
64+
EOT
5965

60-
echo "Node.js ${node_index_version} for ${operating_system}-${architecture} released on ${node_index_date}"
66+
# install Node.js on Windows
67+
if [[ "$OS" == "Windows_NT" ]]; then
68+
# Delete pre-existing node to avoid version conflicts
69+
rm -rf "/cygdrive/c/Program Files/nodejs"
6170

62-
set -o xtrace
6371

64-
curl --fail --retry 8 -sS "${node_download_url}" --max-time 300 --output "$node_archive_path"
72+
NVM_HOME=$(cygpath -w "$NVM_DIR")
73+
export NVM_HOME
74+
NVM_SYMLINK=$(cygpath -w "$NODE_ARTIFACTS_PATH/bin")
75+
export NVM_SYMLINK
76+
NVM_ARTIFACTS_PATH=$(cygpath -w "$NODE_ARTIFACTS_PATH/bin")
77+
export NVM_ARTIFACTS_PATH
78+
PATH=$(cygpath $NVM_SYMLINK):$(cygpath $NVM_HOME):$PATH
79+
export PATH
6580

66-
if [[ "$file_extension" = "zip" ]]; then
67-
unzip -q "$node_archive_path" -d "${NODE_ARTIFACTS_PATH}"
68-
mkdir -p "${NODE_ARTIFACTS_PATH}/nodejs"
69-
# Windows "bins" are at the top level
70-
mv "${NODE_ARTIFACTS_PATH}/${node_directory}" "${NODE_ARTIFACTS_PATH}/nodejs/bin"
71-
# Need to add executable flag ourselves
72-
chmod +x "${NODE_ARTIFACTS_PATH}/nodejs/bin/node.exe"
73-
chmod +x "${NODE_ARTIFACTS_PATH}/nodejs/bin/npm"
74-
else
75-
tar -xf "$node_archive_path" -C "${NODE_ARTIFACTS_PATH}"
76-
mv "${NODE_ARTIFACTS_PATH}/${node_directory}" "${NODE_ARTIFACTS_PATH}/nodejs"
77-
fi
81+
curl -L $NVM_WINDOWS_URL -o nvm.zip
82+
unzip -d "$NVM_DIR" nvm.zip
83+
rm nvm.zip
7884

79-
export PATH="$NODE_ARTIFACTS_PATH/npm_global/bin:$NODE_ARTIFACTS_PATH/nodejs/bin:$PATH"
80-
hash -r
85+
chmod 777 "$NVM_DIR"
86+
chmod -R a+rx "$NVM_DIR"
8187

82-
# Set npm -g prefix to our local artifacts directory
83-
cat <<EOT > .npmrc
84-
prefix=$NODE_ARTIFACTS_PATH/npm_global
88+
cat <<EOT > "$NVM_DIR/settings.txt"
89+
root: $NVM_HOME
90+
path: $NVM_SYMLINK
8591
EOT
92+
nvm install "$NODE_VERSION"
93+
nvm use "$NODE_VERSION"
94+
which node || echo "node not found, PATH=$PATH"
95+
which npm || echo "npm not found, PATH=$PATH"
96+
npm cache clear --force # Fixes: Cannot read properties of null (reading 'pickAlgorithm') error on windows
8697

87-
if [[ $operating_system != "win" ]]; then
88-
# Update npm to latest when we can
89-
npm install --global npm@latest
90-
hash -r
98+
# install Node.js on Linux/MacOS
99+
else
100+
curl -o- $NVM_URL | bash
101+
[ -s "${NVM_DIR}/nvm.sh" ] && source "${NVM_DIR}/nvm.sh"
102+
nvm install --no-progress "$NODE_VERSION"
91103
fi
92104

93-
echo "npm version: $(npm -v)"
94-
95-
npm install "${NPM_OPTIONS}"
105+
npm install ${NPM_OPTIONS}

.evergreen/run-benchmarks.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#! /bin/bash
22

3-
source "${PROJECT_DIRECTORY}/.evergreen/init-nvm.sh"
3+
[ -s "$PROJECT_DIRECTORY/node-artifacts/nvm/nvm.sh" ] && source "$PROJECT_DIRECTORY"/node-artifacts/nvm/nvm.sh
44

55
export MONGODB_URI=$MONGODB_URI
66

.evergreen/run-custom-csfle-tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export CSFLE_KMS_PROVIDERS=${CSFLE_KMS_PROVIDERS}
1212
export CRYPT_SHARED_LIB_PATH=${CRYPT_SHARED_LIB_PATH}
1313
echo "csfle CRYPT_SHARED_LIB_PATH: $CRYPT_SHARED_LIB_PATH"
1414

15-
source "${PROJECT_DIRECTORY}/.evergreen/init-nvm.sh"
15+
[ -s "$PROJECT_DIRECTORY/node-artifacts/nvm/nvm.sh" ] && source "$PROJECT_DIRECTORY"/node-artifacts/nvm/nvm.sh
1616

1717
set -o xtrace # Write all commands first to stderr
1818
set -o errexit # Exit the script with error if any of the commands fail

.gitignore

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,3 @@ etc/docs/build
8888
!docs/**/*.css
8989
!docs/**/*.js
9090
.nvmrc
91-
92-
node_index.tab
93-
node-artifacts
94-
.npmrc

0 commit comments

Comments
 (0)