Skip to content

Commit

Permalink
ci(NODE-5334): install npm to node_artifacts directory in CI (#3709)
Browse files Browse the repository at this point in the history
  • Loading branch information
baileympearson committed Jun 8, 2023
1 parent e13038d commit 7f5b334
Show file tree
Hide file tree
Showing 24 changed files with 48 additions and 48 deletions.
21 changes: 21 additions & 0 deletions .evergreen/init-node-and-npm-env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#! /usr/bin/env bash
##
## This script add the location of `npm` and `node` to the path.
## This is necessary because evergreen uses separate bash scripts for
## different functions in a given CI run but doesn't persist the environment
## across them. So we manually invoke this script everywhere we need
## access to `npm`, `node`, or need to install something globally from
## npm.

NODE_ARTIFACTS_PATH="${PROJECT_DIRECTORY}/node-artifacts"
if [[ "$OS" == "Windows_NT" ]]; then
NODE_ARTIFACTS_PATH=$(cygpath --unix "$NODE_ARTIFACTS_PATH")
fi

export NODE_ARTIFACTS_PATH
# npm uses this environment variable to determine where to install global packages
export npm_global_prefix=$NODE_ARTIFACTS_PATH/npm_global
export PATH="$npm_global_prefix/bin:$NODE_ARTIFACTS_PATH/nodejs/bin:$PATH"
hash -r

export NODE_OPTIONS="--trace-deprecation --trace-warnings"
13 changes: 0 additions & 13 deletions .evergreen/init-nvm.sh

This file was deleted.

20 changes: 6 additions & 14 deletions .evergreen/install-dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@
set -o errexit # Exit the script with error if any of the commands fail

NODE_LTS_VERSION=${NODE_LTS_VERSION:-12}
NODE_ARTIFACTS_PATH="${PROJECT_DIRECTORY:-$(pwd)}/node-artifacts"
if [[ "$OS" = "Windows_NT" ]]; then NODE_ARTIFACTS_PATH=$(cygpath --unix "$NODE_ARTIFACTS_PATH"); fi

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

if [[ -z "${npm_global_prefix}" ]]; then echo "npm_global_prefix is unset" && exit 1; fi
if [[ -z "${NODE_ARTIFACTS_PATH}" ]]; then echo "NODE_ARTIFACTS_PATH is unset" && exit 1; fi

CURL_FLAGS=(
--fail # Exit code 1 if request fails
Expand Down Expand Up @@ -90,25 +93,14 @@ else
mv "${NODE_ARTIFACTS_PATH}/${node_directory}" "${NODE_ARTIFACTS_PATH}/nodejs"
fi

export PATH="$NODE_ARTIFACTS_PATH/npm_global/bin:$NODE_ARTIFACTS_PATH/nodejs/bin:$PATH"
hash -r

# Set npm -g prefix to our local artifacts directory
cat <<EOT > .npmrc
prefix=$NODE_ARTIFACTS_PATH/npm_global
EOT

# Cannot upgrade npm version for node 12
if [[ $operating_system != "win" ]] && [[ $NODE_LTS_VERSION != 12 ]]; then
# Update npm to latest when we can
npm install --global npm@latest
hash -r
elif [[ $NODE_LTS_VERSION == 12 ]]; then
# Node.js 12 can run up to npm v8
npm install --global npm@8
hash -r
fi

echo "npm location: $(which npm)"
echo "npm version: $(npm -v)"

npm install "${NPM_OPTIONS}"
2 changes: 1 addition & 1 deletion .evergreen/run-atlas-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

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

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

set -o xtrace

Expand Down
2 changes: 1 addition & 1 deletion .evergreen/run-benchmarks.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#! /bin/bash

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

export MONGODB_URI=$MONGODB_URI

Expand Down
2 changes: 1 addition & 1 deletion .evergreen/run-bson-ext-test.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

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

set -o xtrace # Write all commands first to stderr
set -o errexit # Exit the script with error if any of the commands fail
Expand Down
2 changes: 1 addition & 1 deletion .evergreen/run-custom-csfle-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export CSFLE_KMS_PROVIDERS=${CSFLE_KMS_PROVIDERS}
export CRYPT_SHARED_LIB_PATH=${CRYPT_SHARED_LIB_PATH}
echo "csfle CRYPT_SHARED_LIB_PATH: $CRYPT_SHARED_LIB_PATH"

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

set -o xtrace # Write all commands first to stderr
set -o errexit # Exit the script with error if any of the commands fail
Expand Down
2 changes: 1 addition & 1 deletion .evergreen/run-data-lake-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

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

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

echo "$MONGODB_URI"
npm run check:adl
2 changes: 1 addition & 1 deletion .evergreen/run-kerberos-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

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

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

# set up keytab
mkdir -p "$(pwd)/.evergreen"
Expand Down
2 changes: 1 addition & 1 deletion .evergreen/run-lambda-aws-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ MONGODB_URI=${MONGODB_URI:-}
set +x

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

# the default connection string, may be overridden by the environment script
export MONGODB_URI="mongodb://localhost:27017/aws"
Expand Down
2 changes: 1 addition & 1 deletion .evergreen/run-lambda-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ MONGODB_URI=${MONGODB_URI:-}
set +x

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

npm run check:lambda
2 changes: 1 addition & 1 deletion .evergreen/run-ldap-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

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

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

npm run check:ldap
2 changes: 1 addition & 1 deletion .evergreen/run-lint-checks.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
set -o errexit # Exit the script with error if any of the commands fail

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

# Attempt to update our EVG config
# if it changes, crash so that any gen script changes are forced to be run before pushing
Expand Down
2 changes: 1 addition & 1 deletion .evergreen/run-mongodb-aws-ecs-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ tar -xzf src.tgz .

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

# run the tests
Expand Down
2 changes: 1 addition & 1 deletion .evergreen/run-mongodb-aws-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ MONGODB_URI=${MONGODB_URI:-}
set +x

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

# the default connection string, may be overridden by the environment script
export MONGODB_URI="mongodb://localhost:27017/aws?authMechanism=MONGODB-AWS"
Expand Down
2 changes: 1 addition & 1 deletion .evergreen/run-mongosh-integration-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ if [ -z ${TASK_ID+omitted} ]; then echo "TASK_ID is unset" && exit 1; fi

MONGOSH_RUN_ONLY_IN_PACKAGE=${MONGOSH_RUN_ONLY_IN_PACKAGE:-""}

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

npm cache clear --force || true
npm i -g npm@8.x || true
Expand Down
2 changes: 1 addition & 1 deletion .evergreen/run-mongosh-scope-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

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

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

MONGOSH_DIRECTORY="/tmp/$TASK_ID"
git clone --depth=10 https://github.com/mongodb-js/mongosh.git $MONGOSH_DIRECTORY
Expand Down
2 changes: 1 addition & 1 deletion .evergreen/run-ocsp-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ set -o xtrace
set -o errexit

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

# $PYTHON_BINARY -m virtualenv --never-download --no-wheel ocsptest
# . ocsptest/bin/activate
Expand Down
2 changes: 1 addition & 1 deletion .evergreen/run-snappy-version-test.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#! /usr/bin/env bash

source "${PROJECT_DIRECTORY}/.evergreen/init-nvm.sh"
source "${PROJECT_DIRECTORY}/.evergreen/init-node-and-npm-env.sh"
export MONGODB_URI="${MONGODB_URI}"

npm i --no-save snappy@6
Expand Down
2 changes: 1 addition & 1 deletion .evergreen/run-socks5-tests.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

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

set -o errexit # Exit the script with error if any of the commands fail
set -o xtrace # For debuggability, no external credentials are used here
Expand Down
2 changes: 1 addition & 1 deletion .evergreen/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ echo "Running $AUTH tests over $SSL, connecting to $MONGODB_URI"
if [[ -z "${SKIP_DEPS}" ]]; then
source "${PROJECT_DIRECTORY}/.evergreen/install-dependencies.sh"
else
source "${PROJECT_DIRECTORY}/.evergreen/init-nvm.sh"
source "${PROJECT_DIRECTORY}/.evergreen/init-node-and-npm-env.sh"
fi

if [ "$COMPRESSOR" != "" ]; then
Expand Down
2 changes: 1 addition & 1 deletion .evergreen/run-tls-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

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

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

export SSL_KEY_FILE="$DRIVERS_TOOLS/.evergreen/x509gen/client.pem"
export SSL_CA_FILE="$DRIVERS_TOOLS/.evergreen/x509gen/ca.pem"
Expand Down
2 changes: 1 addition & 1 deletion .evergreen/run-typescript.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
set -o errexit # Exit the script with error if any of the commands fail

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

set -o xtrace

Expand Down
2 changes: 1 addition & 1 deletion .evergreen/run-unit-tests.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
set -o errexit # Exit the script with error if any of the commands fail

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

npx nyc npm run check:unit

0 comments on commit 7f5b334

Please sign in to comment.