build: in CI, use npm clean-install instead of npm install

Packages can be added to package-lock.json that will fail to
install on certain systems. For example, the `fsevents` NPM
package, which only works on macOS, was listed as a requirement
in the file.

`npm install` will happily skip over such packages.
`npm clean-install`, however, will exit with a fatal error.

Throughout several doc pages, we have recently been encouraging
folks to use `clean-install` instead of `install`, because its
strictness makes it more reproducible. To ensure that `clean-install`
is working reliably at any given time, we should use `clean-install`
in our CI pipeline.
This commit is contained in:
Kyle McCormick
2022-08-22 15:07:07 -04:00
committed by Kyle McCormick
parent 1673b1d3b9
commit bacce909f6

View File

@@ -139,7 +139,7 @@ def node_prereqs_installation():
else:
npm_log_file_path = f'{Env.GEN_LOG_DIR}/npm-install.log'
npm_log_file = open(npm_log_file_path, 'wb') # lint-amnesty, pylint: disable=consider-using-with
npm_command = 'npm install --verbose'.split()
npm_command = 'npm clean-install --verbose'.split()
# The implementation of Paver's `sh` function returns before the forked
# actually returns. Using a Popen object so that we can ensure that
@@ -150,12 +150,12 @@ def node_prereqs_installation():
# Error handling around a race condition that produces "cb() never called" error. This
# evinces itself as `cb_error_text` and it ought to disappear when we upgrade
# npm to 3 or higher. TODO: clean this up when we do that.
print("npm install error detected. Retrying...")
print("npm clean-install error detected. Retrying...")
proc = subprocess.Popen(npm_command, stderr=npm_log_file) # lint-amnesty, pylint: disable=consider-using-with
retcode = proc.wait()
if retcode == 1:
raise Exception(f"npm install failed: See {npm_log_file_path}")
print("Successfully installed NPM packages. Log found at {}".format(
print("Successfully clean-installed NPM packages. Log found at {}".format(
npm_log_file_path
))