Skip to content

Commit 148d6e0

Browse files
authored
chore(ci): fix npm cache path for windows; remove the whole cache fol… (#6660)
* chore(ci): fix npm cache path for windows; remove the whole cache folder when installing * chore(ci): move the ls check inside the install script so that it can re-run on windows
1 parent 1a45ecb commit 148d6e0

File tree

3 files changed

+18
-19
lines changed

3 files changed

+18
-19
lines changed

.evergreen/functions.yml

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,6 @@ functions:
152152
153153
# Make all the dirs
154154
mkdir -p $ARTIFACTS_PATH
155-
mkdir -p $NPM_CACHE_DIR
156-
mkdir -p $NPM_TMP_DIR
157155
158156
- command: shell.exec
159157
type: setup
@@ -195,18 +193,9 @@ functions:
195193
npm config ls -l
196194
echo "(if npm fails, debug.log will be uploaded to S3)"
197195
198-
# Install dependencies
196+
# Install and check dependencies
199197
bash ".evergreen/retry-with-backoff.sh" .evergreen/npm_ci.sh
200198
201-
# Will fail if versions of direct dependencies listed in package-lock
202-
# are not matching versions defined in package.json file of any of the
203-
# workspace packages
204-
# This command is very noisy when running from root with --all, store
205-
# the output in a file that will be uploaded with rest of the logs
206-
LS_ALL_STDOUT_FILE="$(npm config get cache)/_logs/$(date -u +"%Y-%m-%dT%H_%M_%SZ")-npm-ls-all.log"
207-
echo "Validating dependencies with \`npm ls --all\`..."
208-
(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)
209-
210199
bootstrap:
211200
- command: shell.exec
212201
type: setup

.evergreen/npm_ci.sh

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,20 @@
22

33
set -e
44

5-
npm cache clean -f
5+
# Remove the cache and any potential install leftovers before installing again.
6+
# We are running this script with a retry to deal with network issues, in some
7+
# rare cases npm leaves stuff behind messing up a new attempt
8+
rm -rf "$NPM_CACHE_DIR"
69
rm -rf node_modules
710
find configs -name 'node_modules' -type d -prune -exec rm -rf '{}' +
811
find packages -name 'node_modules' -type d -prune -exec rm -rf '{}' +
912
find scripts -name 'node_modules' -type d -prune -exec rm -rf '{}' +
10-
npm ci --unsafe-perm
13+
npm ci --unsafe-perm
14+
15+
# Will fail if versions of direct dependencies listed in package-lock are not
16+
# matching versions defined in package.json file of any of the workspace
17+
# packages. This command is very noisy when running from root with --all, store
18+
# the output in a file that will be uploaded with rest of the logs
19+
LS_ALL_STDOUT_FILE="$(npm config get cache)/_logs/$(date -u +"%Y-%m-%dT%H_%M_%SZ")-npm-ls-all.log"
20+
echo "Validating dependencies with \`npm ls --all\`..."
21+
(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)

.evergreen/print-compass-env.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#! /usr/bin/env node
22
'use strict';
3+
const path = require('path');
34

45
/*
56
This script writes a bash script that can be eval()'d in evergreen to modify the
@@ -79,18 +80,16 @@ function printCompassEnv() {
7980
PATH = maybePrependPaths(PATH, pathsToPrepend);
8081
printVar('PATH', PATH);
8182

82-
const npmCacheDir = `${newPWD}/.deps/.npm`;
83-
const npmTmpDir = `${newPWD}/.deps/tmp`;
83+
// not using `newPWD` here to avoid issues on windows where the value supposed
84+
// to be a non-cygwin path
85+
const npmCacheDir = path.resolve(__dirname, '..', '.deps', '.npm-cache');
8486

8587
printVar('ARTIFACTS_PATH', `${newPWD}/.deps`);
8688
printVar('NPM_CACHE_DIR', npmCacheDir);
87-
printVar('NPM_TMP_DIR', npmTmpDir);
8889

8990
// all npm var names need to be lowercase
9091
// see: https://docs.npmjs.com/cli/v7/using-npm/config#environment-variables
9192
printVar('npm_config_cache', npmCacheDir);
92-
// npm tmp is deprecated, but let's keep it around just in case
93-
printVar('npm_config_tmp', npmTmpDir);
9493
// Also set in our .npmrc but that does not get picked up in the preinstall script.
9594
printVar('npm_config_registry', 'https://registry.npmjs.org/');
9695

0 commit comments

Comments
 (0)