From 58562e7c21269c54c4f6986e2586ca5eef1213ac Mon Sep 17 00:00:00 2001 From: Sergey Petushkov Date: Fri, 24 Jan 2025 18:01:40 +0100 Subject: [PATCH 1/2] chore(ci): fix npm cache path for windows; remove the whole cache folder when installing --- .evergreen/functions.yml | 2 -- .evergreen/npm_ci.sh | 7 +++++-- .evergreen/print-compass-env.js | 9 ++++----- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.evergreen/functions.yml b/.evergreen/functions.yml index b403bd68159..04dc04af0cd 100644 --- a/.evergreen/functions.yml +++ b/.evergreen/functions.yml @@ -152,8 +152,6 @@ functions: # Make all the dirs mkdir -p $ARTIFACTS_PATH - mkdir -p $NPM_CACHE_DIR - mkdir -p $NPM_TMP_DIR - command: shell.exec type: setup diff --git a/.evergreen/npm_ci.sh b/.evergreen/npm_ci.sh index 45c79a90afd..21957c3e52e 100755 --- a/.evergreen/npm_ci.sh +++ b/.evergreen/npm_ci.sh @@ -2,9 +2,12 @@ set -e -npm cache clean -f +# Remove the cache and any potential install leftovers before installing again. +# We are running this script with a retry to deal with network issues, in some +# rare cases npm leaves stuff behind messing up a new attempt +rm -rf "$NPM_CACHE_DIR" rm -rf node_modules find configs -name 'node_modules' -type d -prune -exec rm -rf '{}' + find packages -name 'node_modules' -type d -prune -exec rm -rf '{}' + find scripts -name 'node_modules' -type d -prune -exec rm -rf '{}' + -npm ci --unsafe-perm \ No newline at end of file +npm ci --unsafe-perm diff --git a/.evergreen/print-compass-env.js b/.evergreen/print-compass-env.js index 7c0b8ebd664..c396e3eaa75 100755 --- a/.evergreen/print-compass-env.js +++ b/.evergreen/print-compass-env.js @@ -1,5 +1,6 @@ #! /usr/bin/env node 'use strict'; +const path = require('path'); /* This script writes a bash script that can be eval()'d in evergreen to modify the @@ -79,18 +80,16 @@ function printCompassEnv() { PATH = maybePrependPaths(PATH, pathsToPrepend); printVar('PATH', PATH); - const npmCacheDir = `${newPWD}/.deps/.npm`; - const npmTmpDir = `${newPWD}/.deps/tmp`; + // not using `newPWD` here to avoid issues on windows where the value supposed + // to be a non-cygwin path + const npmCacheDir = path.resolve(__dirname, '..', '.deps', '.npm-cache'); printVar('ARTIFACTS_PATH', `${newPWD}/.deps`); printVar('NPM_CACHE_DIR', npmCacheDir); - printVar('NPM_TMP_DIR', npmTmpDir); // all npm var names need to be lowercase // see: https://docs.npmjs.com/cli/v7/using-npm/config#environment-variables printVar('npm_config_cache', npmCacheDir); - // npm tmp is deprecated, but let's keep it around just in case - printVar('npm_config_tmp', npmTmpDir); // Also set in our .npmrc but that does not get picked up in the preinstall script. printVar('npm_config_registry', 'https://registry.npmjs.org/'); From 7eab4fd671ac3e72d25501e73af2cc5d84665816 Mon Sep 17 00:00:00 2001 From: Sergey Petushkov Date: Mon, 27 Jan 2025 10:12:24 +0100 Subject: [PATCH 2/2] chore(ci): move the ls check inside the install script so that it can re-run on windows --- .evergreen/functions.yml | 11 +---------- .evergreen/npm_ci.sh | 8 ++++++++ 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/.evergreen/functions.yml b/.evergreen/functions.yml index 04dc04af0cd..20c9fafddf1 100644 --- a/.evergreen/functions.yml +++ b/.evergreen/functions.yml @@ -193,18 +193,9 @@ functions: npm config ls -l echo "(if npm fails, debug.log will be uploaded to S3)" - # Install dependencies + # Install and check dependencies bash ".evergreen/retry-with-backoff.sh" .evergreen/npm_ci.sh - # Will fail if versions of direct dependencies listed in package-lock - # are not matching versions defined in package.json file of any of the - # workspace packages - # This command is very noisy when running from root with --all, store - # the output in a file that will be uploaded with rest of the logs - LS_ALL_STDOUT_FILE="$(npm config get cache)/_logs/$(date -u +"%Y-%m-%dT%H_%M_%SZ")-npm-ls-all.log" - echo "Validating dependencies with \`npm ls --all\`..." - (npm ls --all > $LS_ALL_STDOUT_FILE && echo "No mismatched dependency versions") || (echo "\nThe \`npm ls\` command failed with mismatched dependencies error. This usually means that the dependency versions listed in package.json are not matching dependencies resolved and recorded in package-lock.json. If you updated package.json files in your PR, inspect the error output and try to re-install offending dependncies to fix the package-lock file." && exit 1) - bootstrap: - command: shell.exec type: setup diff --git a/.evergreen/npm_ci.sh b/.evergreen/npm_ci.sh index 21957c3e52e..742adbe9d97 100755 --- a/.evergreen/npm_ci.sh +++ b/.evergreen/npm_ci.sh @@ -11,3 +11,11 @@ find configs -name 'node_modules' -type d -prune -exec rm -rf '{}' + find packages -name 'node_modules' -type d -prune -exec rm -rf '{}' + find scripts -name 'node_modules' -type d -prune -exec rm -rf '{}' + npm ci --unsafe-perm + +# Will fail if versions of direct dependencies listed in package-lock are not +# matching versions defined in package.json file of any of the workspace +# packages. This command is very noisy when running from root with --all, store +# the output in a file that will be uploaded with rest of the logs +LS_ALL_STDOUT_FILE="$(npm config get cache)/_logs/$(date -u +"%Y-%m-%dT%H_%M_%SZ")-npm-ls-all.log" +echo "Validating dependencies with \`npm ls --all\`..." +(npm ls --all >$LS_ALL_STDOUT_FILE && echo "No mismatched dependency versions") || (echo ""; echo "The \`npm ls\` command failed with mismatched dependencies error. This usually means that the dependency versions listed in package.json are not matching dependencies resolved and recorded in package-lock.json. If you updated package.json files in your PR, inspect the error output and try to re-install offending dependncies to fix the package-lock file." && exit 1)