Skip to content

Commit b020026

Browse files
ci(NODE-5333): download npm to local directory instead of globally (#3700)
1 parent c2abd89 commit b020026

30 files changed

+53
-49
lines changed

.evergreen/config.in.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ functions:
526526
working_dir: "src"
527527
script: |
528528
${PREPARE_SHELL}
529-
source "${PROJECT_DIRECTORY}/.evergreen/init-nvm.sh"
529+
source "${PROJECT_DIRECTORY}/.evergreen/init-node-and-npm-env.sh"
530530
npm install @aws-sdk/credential-providers
531531
532532
"run atlas tests":

.evergreen/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ functions:
471471
working_dir: src
472472
script: |
473473
${PREPARE_SHELL}
474-
source "${PROJECT_DIRECTORY}/.evergreen/init-nvm.sh"
474+
source "${PROJECT_DIRECTORY}/.evergreen/init-node-and-npm-env.sh"
475475
npm install @aws-sdk/credential-providers
476476
run atlas tests:
477477
- command: shell.exec

.evergreen/copy-driver-to-azure.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ if [ -z ${AZUREKMS_RESOURCEGROUP+omitted} ]; then echo "AZUREKMS_RESOURCEGROUP i
66
if [ -z ${AZUREKMS_VMNAME+omitted} ]; then echo "AZUREKMS_VMNAME is unset" && exit 1; fi
77
if [ -z ${AZUREKMS_PRIVATEKEYPATH+omitted} ]; then echo "AZUREKMS_PRIVATEKEYPATH is unset" && exit 1; fi
88

9-
source "${PROJECT_DIRECTORY}/.evergreen/init-nvm.sh"
9+
source "${PROJECT_DIRECTORY}/.evergreen/init-node-and-npm-env.sh"
1010

1111
echo "compressing node driver source ... begin"
1212
tar -czf node-driver-source.tgz src

.evergreen/init-node-and-npm-env.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#! /usr/bin/env bash
2+
##
3+
## This script add the location of `npm` and `node` to the path.
4+
## This is necessary because evergreen uses separate bash scripts for
5+
## different functions in a given CI run but doesn't persist the environment
6+
## across them. So we manually invoke this script everywhere we need
7+
## access to `npm`, `node`, or need to install something globally from
8+
## npm.
9+
10+
NODE_ARTIFACTS_PATH="${PROJECT_DIRECTORY}/node-artifacts"
11+
if [[ "$OS" == "Windows_NT" ]]; then
12+
NODE_ARTIFACTS_PATH=$(cygpath --unix "$NODE_ARTIFACTS_PATH")
13+
fi
14+
15+
export NODE_ARTIFACTS_PATH
16+
# npm uses this environment variable to determine where to install global packages
17+
export npm_global_prefix=$NODE_ARTIFACTS_PATH/npm_global
18+
export PATH="$npm_global_prefix/bin:$NODE_ARTIFACTS_PATH/nodejs/bin:$PATH"
19+
hash -r
20+
21+
export NODE_OPTIONS="--trace-deprecation --trace-warnings"

.evergreen/init-nvm.sh

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

.evergreen/install-dependencies.sh

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
set -o errexit # Exit the script with error if any of the commands fail
33

44
NODE_LTS_VERSION=${NODE_LTS_VERSION:-14}
5-
NODE_ARTIFACTS_PATH="${PROJECT_DIRECTORY:-$(pwd)}/node-artifacts"
6-
if [[ "$OS" = "Windows_NT" ]]; then NODE_ARTIFACTS_PATH=$(cygpath --unix "$NODE_ARTIFACTS_PATH"); fi
5+
6+
source "${PROJECT_DIRECTORY}/.evergreen/init-node-and-npm-env.sh"
77

88
CURL_FLAGS=(
99
--fail # Exit code 1 if request fails
@@ -93,17 +93,13 @@ fi
9393
export PATH="$NODE_ARTIFACTS_PATH/npm_global/bin:$NODE_ARTIFACTS_PATH/nodejs/bin:$PATH"
9494
hash -r
9595

96-
# Set npm -g prefix to our local artifacts directory
97-
cat <<EOT > .npmrc
98-
prefix=$NODE_ARTIFACTS_PATH/npm_global
99-
EOT
100-
10196
if [[ $operating_system != "win" ]]; then
10297
# Update npm to latest when we can
10398
npm install --global npm@latest
10499
hash -r
105100
fi
106101

102+
echo "npm location: $(which npm)"
107103
echo "npm version: $(npm -v)"
108104

109105
npm install "${NPM_OPTIONS}"

.evergreen/run-atlas-tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
set -o errexit # Exit the script with error if any of the commands fail
44

5-
source "${PROJECT_DIRECTORY}/.evergreen/init-nvm.sh"
5+
source "${PROJECT_DIRECTORY}/.evergreen/init-node-and-npm-env.sh"
66

77
set -o xtrace
88

.evergreen/run-azure-kms-tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ set -o errexit
55
pushd "src"
66
PROJECT_DIRECTORY="$(pwd)"
77
export PROJECT_DIRECTORY
8-
source ".evergreen/init-nvm.sh"
8+
source ".evergreen/init-node-and-npm-env.sh"
99

1010
set -o xtrace
1111

.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+
source "${PROJECT_DIRECTORY}/.evergreen/init-node-and-npm-env.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+
source "${PROJECT_DIRECTORY}/.evergreen/init-node-and-npm-env.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

.evergreen/run-data-lake-tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
set -o errexit # Exit the script with error if any of the commands fail
44

5-
source "${PROJECT_DIRECTORY}/.evergreen/init-nvm.sh"
5+
source "${PROJECT_DIRECTORY}/.evergreen/init-node-and-npm-env.sh"
66

77
echo "$MONGODB_URI"
88
npm run check:adl

.evergreen/run-gcp-kms-tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ set -o errexit
55
pushd "src"
66
PROJECT_DIRECTORY="$(pwd)"
77
export PROJECT_DIRECTORY
8-
source ".evergreen/init-nvm.sh"
8+
source ".evergreen/init-node-and-npm-env.sh"
99

1010
set -o xtrace
1111

.evergreen/run-kerberos-tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
set -o errexit # Exit the script with error if any of the commands fail
44

5-
source "${PROJECT_DIRECTORY}/.evergreen/init-nvm.sh"
5+
source "${PROJECT_DIRECTORY}/.evergreen/init-node-and-npm-env.sh"
66

77
# set up keytab
88
mkdir -p "$(pwd)/.evergreen"

.evergreen/run-lambda-aws-tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ MONGODB_URI=${MONGODB_URI:-}
88
set +x
99

1010
# load node.js environment
11-
source "${PROJECT_DIRECTORY}/.evergreen/init-nvm.sh"
11+
source "${PROJECT_DIRECTORY}/.evergreen/init-node-and-npm-env.sh"
1212

1313
# the default connection string, may be overridden by the environment script
1414
export MONGODB_URI="mongodb://localhost:27017/aws"

.evergreen/run-lambda-tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ MONGODB_URI=${MONGODB_URI:-}
88
set +x
99

1010
# load node.js environment
11-
source "${PROJECT_DIRECTORY}/.evergreen/init-nvm.sh"
11+
source "${PROJECT_DIRECTORY}/.evergreen/init-node-and-npm-env.sh"
1212

1313
npm run check:lambda

.evergreen/run-ldap-tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
set -o errexit # Exit the script with error if any of the commands fail
44

5-
source "${PROJECT_DIRECTORY}/.evergreen/init-nvm.sh"
5+
source "${PROJECT_DIRECTORY}/.evergreen/init-node-and-npm-env.sh"
66

77
npm run check:ldap

.evergreen/run-lint-checks.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22
set -o errexit # Exit the script with error if any of the commands fail
33

4-
source "${PROJECT_DIRECTORY}/.evergreen/init-nvm.sh"
4+
source "${PROJECT_DIRECTORY}/.evergreen/init-node-and-npm-env.sh"
55

66
# Attempt to update our EVG config
77
# if it changes, crash so that any gen script changes are forced to be run before pushing

.evergreen/run-mongodb-aws-ecs-test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ tar -xzf src.tgz .
1111

1212
# load node.js
1313
set +x
14-
source "${PROJECT_DIRECTORY}/.evergreen/init-nvm.sh"
14+
source "${PROJECT_DIRECTORY}/.evergreen/init-node-and-npm-env.sh"
1515
set -x
1616

1717
# run the tests

.evergreen/run-mongodb-aws-test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ MONGODB_URI=${MONGODB_URI:-}
88
set +x
99

1010
# load node.js environment
11-
source "${PROJECT_DIRECTORY}/.evergreen/init-nvm.sh"
11+
source "${PROJECT_DIRECTORY}/.evergreen/init-node-and-npm-env.sh"
1212

1313
# the default connection string, may be overridden by the environment script
1414
export MONGODB_URI="mongodb://localhost:27017/aws?authMechanism=MONGODB-AWS"

.evergreen/run-mongosh-integration-tests.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ if [ -z ${TASK_ID+omitted} ]; then echo "TASK_ID is unset" && exit 1; fi
1616

1717
MONGOSH_RUN_ONLY_IN_PACKAGE=${MONGOSH_RUN_ONLY_IN_PACKAGE:-""}
1818

19-
source "${PROJECT_DIRECTORY}/.evergreen/init-nvm.sh"
19+
source "${PROJECT_DIRECTORY}/.evergreen/init-node-and-npm-env.sh"
2020

2121
npm cache clear --force || true
22-
npm i -g [email protected] || true
22+
npm install --global [email protected] || true
2323

2424
npm pack | tee npm-pack.log
2525

2626
npm cache clear --force || true
27-
npm i -g [email protected] || true
27+
npm install --global [email protected] || true
2828

2929
TARBALL_FILENAME="$(tail -n1 npm-pack.log)"
3030

.evergreen/run-mongosh-scope-test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
if [ -z ${TASK_ID+omitted} ]; then echo "TASK_ID is unset" && exit 1; fi
44

5-
source "${PROJECT_DIRECTORY}/.evergreen/init-nvm.sh"
5+
source "${PROJECT_DIRECTORY}/.evergreen/init-node-and-npm-env.sh"
66

77
MONGOSH_DIRECTORY="/tmp/$TASK_ID"
88
git clone --depth=10 https://github.com/mongodb-js/mongosh.git $MONGOSH_DIRECTORY

.evergreen/run-ocsp-tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ set -o xtrace
33
set -o errexit
44

55
# load node.js environment
6-
source "${PROJECT_DIRECTORY}/.evergreen/init-nvm.sh"
6+
source "${PROJECT_DIRECTORY}/.evergreen/init-node-and-npm-env.sh"
77

88
# $PYTHON_BINARY -m virtualenv --never-download --no-wheel ocsptest
99
# . ocsptest/bin/activate

.evergreen/run-oidc-tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
set -o errexit # Exit the script with error if any of the commands fail
33
set -o xtrace # Write all commands first to stderr
44

5-
source "${PROJECT_DIRECTORY}/.evergreen/init-nvm.sh"
5+
source "${PROJECT_DIRECTORY}/.evergreen/init-node-and-npm-env.sh"
66

77
MONGODB_URI=${MONGODB_URI:-"mongodb://127.0.0.1:27017"}
88
MONGODB_URI_SINGLE="${MONGODB_URI}/?authMechanism=MONGODB-OIDC&authMechanismProperties=DEVICE_NAME:aws"

.evergreen/run-serverless-tests.sh

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

3-
source "${PROJECT_DIRECTORY}/.evergreen/init-nvm.sh"
3+
source "${PROJECT_DIRECTORY}/.evergreen/init-node-and-npm-env.sh"
44

55
if [ -z ${SERVERLESS+omitted} ]; then echo "SERVERLESS is unset" && exit 1; fi
66
if [ -z ${SERVERLESS_URI+omitted} ]; then echo "SERVERLESS_URI is unset" && exit 1; fi

.evergreen/run-socks5-tests.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+
source "${PROJECT_DIRECTORY}/.evergreen/init-node-and-npm-env.sh"
44

55
set -o errexit # Exit the script with error if any of the commands fail
66
set -o xtrace # For debuggability, no external credentials are used here

.evergreen/run-tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ echo "Running $AUTH tests over $SSL, connecting to $MONGODB_URI"
2929
if [[ -z "${SKIP_DEPS}" ]]; then
3030
source "${PROJECT_DIRECTORY}/.evergreen/install-dependencies.sh"
3131
else
32-
source "${PROJECT_DIRECTORY}/.evergreen/init-nvm.sh"
32+
source "${PROJECT_DIRECTORY}/.evergreen/init-node-and-npm-env.sh"
3333
fi
3434

3535
if [ "$COMPRESSOR" != "" ]; then

.evergreen/run-tls-tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
set -o errexit # Exit the script with error if any of the commands fail
44

5-
source "${PROJECT_DIRECTORY}/.evergreen/init-nvm.sh"
5+
source "${PROJECT_DIRECTORY}/.evergreen/init-node-and-npm-env.sh"
66

77
export SSL_KEY_FILE="$DRIVERS_TOOLS/.evergreen/x509gen/client.pem"
88
export SSL_CA_FILE="$DRIVERS_TOOLS/.evergreen/x509gen/ca.pem"

.evergreen/run-typescript.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22
set -o errexit # Exit the script with error if any of the commands fail
33

4-
source "${PROJECT_DIRECTORY}/.evergreen/init-nvm.sh"
4+
source "${PROJECT_DIRECTORY}/.evergreen/init-node-and-npm-env.sh"
55

66
set -o xtrace
77

.evergreen/run-unit-tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22
set -o errexit # Exit the script with error if any of the commands fail
33

4-
source "${PROJECT_DIRECTORY}/.evergreen/init-nvm.sh"
4+
source "${PROJECT_DIRECTORY}/.evergreen/init-node-and-npm-env.sh"
55
set -o xtrace
66

77
npx nyc npm run check:unit

.evergreen/setup-gcp-testing.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ if [ -z ${GCPKMS_INSTANCENAME+omitted} ]; then echo "GCPKMS_INSTANCENAME is unse
88

99
set -o errexit
1010

11-
source "${PROJECT_DIRECTORY}/.evergreen/init-nvm.sh"
11+
source "${PROJECT_DIRECTORY}/.evergreen/init-node-and-npm-env.sh"
1212

1313
export GCPKMS_SRC=node-driver-source.tgz
1414
export GCPKMS_DST=$GCPKMS_INSTANCENAME:

0 commit comments

Comments
 (0)