From f4f0d2a2ddd9fc9b6246786ee7aed653106b9a06 Mon Sep 17 00:00:00 2001 From: "Alex Lam S.L" Date: Sun, 30 May 2021 10:19:29 +0100 Subject: workaround transient `npm` failures (#4989) --- test/jetstream.js | 23 +++++++++++++++-------- test/release/acorn.sh | 9 ++++++++- test/release/bootstrap.sh | 9 ++++++++- test/release/buble.sh | 9 ++++++++- test/release/butternut.sh | 9 ++++++++- test/release/install.sh | 8 ++++++-- test/release/mathjs.sh | 9 ++++++++- test/release/rollup-es.sh | 9 ++++++++- test/release/rollup-ts.sh | 11 +++++++++-- test/release/sucrase.sh | 11 +++++++++-- test/release/web-tooling-benchmark.sh | 9 ++++++++- 11 files changed, 95 insertions(+), 21 deletions(-) diff --git a/test/jetstream.js b/test/jetstream.js index 25cf1290..9ee89291 100644 --- a/test/jetstream.js +++ b/test/jetstream.js @@ -58,22 +58,29 @@ if (typeof phantom == "undefined") { }).listen(); server.on("listening", function() { var port = server.address().port; - if (debug) { - console.log("http://localhost:" + port + "/"); - } else (function install() { - child_process.spawn(process.platform == "win32" ? "npm.cmd" : "npm", [ + if (debug) return console.log("http://localhost:" + port + "/"); + var cmd = process.platform == "win32" ? "npm.cmd" : "npm"; + + function npm(args, done) { + child_process.spawn(cmd, args, { stdio: [ "ignore", 1, 2 ] }).on("exit", done); + } + + (function install() { + npm([ "install", "phantomjs-prebuilt@2.1.14", "--no-audit", "--no-optional", "--no-save", "--no-update-notifier", - ], { - stdio: [ "ignore", 1, 2 ] - }).on("exit", function(code) { + ], function(code) { if (code) { console.log("npm install failed with code", code); - return install(); + return npm([ + "cache", + "clean", + "--force", + ], install); } var program = require("phantomjs-prebuilt").exec(process.argv[1], port); program.stdout.pipe(process.stdout); diff --git a/test/release/acorn.sh b/test/release/acorn.sh index f6fdb6a7..2cfe6f70 100755 --- a/test/release/acorn.sh +++ b/test/release/acorn.sh @@ -14,6 +14,13 @@ minify_in_situ() { uglify-js $ARGS } +npm_install() { + PKG="$1" + while !(npm install $PKG); do + while !(npm cache clean --force); do echo "'npm cache clean' failed - retrying..."; done + done +} + rm -rf tmp/acorn \ && git clone https://github.com/acornjs/acorn.git tmp/acorn \ && cd tmp/acorn \ @@ -89,7 +96,7 @@ minify_in_situ "acorn/src" \ && minify_in_situ "acorn-loose/src" \ && minify_in_situ "acorn-walk/src" \ && rm -rf node_modules \ -&& npm install \ +&& npm_install \ && rm -rf acorn/dist acorn-loose/dist acorn-walk/dist \ && npm run build \ && minify_in_situ "acorn/dist" \ diff --git a/test/release/bootstrap.sh b/test/release/bootstrap.sh index 32c77f46..66714675 100755 --- a/test/release/bootstrap.sh +++ b/test/release/bootstrap.sh @@ -14,6 +14,13 @@ minify_in_situ() { uglify-js $ARGS } +npm_install() { + PKG="$1" + while !(npm install $PKG); do + while !(npm cache clean --force); do echo "'npm cache clean' failed - retrying..."; done + done +} + rm -rf tmp/bootstrap \ && git clone --depth 1 --branch v5.0.0-beta2 https://github.com/twbs/bootstrap.git tmp/bootstrap \ && cd tmp/bootstrap \ @@ -171,7 +178,7 @@ rm -rf tmp/bootstrap \ EOF ERR=$?; if [ "$ERR" != "0" ]; then echo "Error: $ERR"; exit $ERR; fi rm -rf node_modules \ -&& npm ci \ +&& npm_install \ && minify_in_situ "node_modules/@popperjs/core" \ && rm -rf dist/js/* \ && minify_in_situ "build" \ diff --git a/test/release/buble.sh b/test/release/buble.sh index d997b0f1..56599e3d 100755 --- a/test/release/buble.sh +++ b/test/release/buble.sh @@ -14,6 +14,13 @@ minify_in_situ() { uglify-js $ARGS } +npm_install() { + PKG="$1" + while !(npm install $PKG); do + while !(npm cache clean --force); do echo "'npm cache clean' failed - retrying..."; done + done +} + rm -rf tmp/buble \ && git clone https://github.com/bublejs/buble.git tmp/buble \ && cd tmp/buble \ @@ -38,7 +45,7 @@ EOF ERR=$?; if [ "$ERR" != "0" ]; then echo "Error: $ERR"; exit $ERR; fi minify_in_situ "src" \ && rm -rf node_modules \ -&& npm ci \ +&& npm_install \ && rm -rf dist \ && npm run build \ && minify_in_situ "dist" \ diff --git a/test/release/butternut.sh b/test/release/butternut.sh index bb79a299..c005dc71 100755 --- a/test/release/butternut.sh +++ b/test/release/butternut.sh @@ -14,6 +14,13 @@ minify_in_situ() { uglify-js $ARGS } +npm_install() { + PKG="$1" + while !(npm install $PKG); do + while !(npm cache clean --force); do echo "'npm cache clean' failed - retrying..."; done + done +} + rm -rf tmp/butternut \ && git clone https://github.com/Rich-Harris/butternut.git tmp/butternut \ && cd tmp/butternut \ @@ -38,7 +45,7 @@ EOF ERR=$?; if [ "$ERR" != "0" ]; then echo "Error: $ERR"; exit $ERR; fi minify_in_situ "src" \ && rm -rf node_modules \ -&& npm install \ +&& npm_install \ && rm -rf dist \ && npm run build \ && minify_in_situ "dist" \ diff --git a/test/release/install.sh b/test/release/install.sh index 2c4d81b8..2a650e25 100755 --- a/test/release/install.sh +++ b/test/release/install.sh @@ -36,7 +36,9 @@ EOF } if [ $NATIVE ]; then unset -f timeout; fi -git clone --branch v1.6.0 --depth 1 https://github.com/jasongin/nvs.git ~/.nvs +while !(git clone --branch v1.6.0 --depth 1 https://github.com/jasongin/nvs.git ~/.nvs); do + rm -rf ~/.nvs +done while ! timeout 60 bash -c ". ~/.nvs/nvs.sh add $NODE && nvs use $NODE"; do cd ~/.nvs while !(git clean -xdf); do echo "'git clean' failed - retrying..."; done @@ -51,4 +53,6 @@ npm config set save false npm config set strict-ssl false npm config set update-notifier false npm --version -while !(npm install); do echo "'npm install' failed - retrying..."; done +while !(npm install); do + while !(npm cache clean --force); do echo "'npm cache clean' failed - retrying..."; done +done diff --git a/test/release/mathjs.sh b/test/release/mathjs.sh index 5779ad26..03a41b1a 100755 --- a/test/release/mathjs.sh +++ b/test/release/mathjs.sh @@ -18,6 +18,13 @@ minify_in_situ() { uglify-js $ARGS } +npm_install() { + PKG="$1" + while !(npm install $PKG); do + while !(npm cache clean --force); do echo "'npm cache clean' failed - retrying..."; done + done +} + rm -rf tmp/mathjs \ && git clone --depth 1 --branch v9.2.0 https://github.com/josdejong/mathjs.git tmp/mathjs \ && cd tmp/mathjs \ @@ -191,7 +198,7 @@ minify_in_situ "bin" \ && minify_in_situ "test" \ && minify_in_situ "tools" \ && rm -rf node_modules \ -&& npm ci \ +&& npm_install \ && rm -rf lib \ && npm run build \ && minify_in_situ "lib" \ diff --git a/test/release/rollup-es.sh b/test/release/rollup-es.sh index b38661bf..8f3a243c 100755 --- a/test/release/rollup-es.sh +++ b/test/release/rollup-es.sh @@ -14,6 +14,13 @@ minify_in_situ() { uglify-js $ARGS } +npm_install() { + PKG="$1" + while !(npm install $PKG); do + while !(npm cache clean --force); do echo "'npm cache clean' failed - retrying..."; done + done +} + rm -rf tmp/rollup \ && git clone https://github.com/rollup/rollup.git tmp/rollup \ && cd tmp/rollup \ @@ -77,7 +84,7 @@ minify_in_situ "bin" \ && minify_in_situ "browser" \ && minify_in_situ "src" \ && rm -rf node_modules \ -&& npm ci \ +&& npm_install \ && rm -rf dist \ && npm run build \ && minify_in_situ "dist" \ diff --git a/test/release/rollup-ts.sh b/test/release/rollup-ts.sh index a70adb19..503aeadf 100755 --- a/test/release/rollup-ts.sh +++ b/test/release/rollup-ts.sh @@ -24,6 +24,13 @@ EOF uglify-js $ARGS } +npm_install() { + PKG="$1" + while !(npm install $PKG); do + while !(npm cache clean --force); do echo "'npm cache clean' failed - retrying..."; done + done +} + rm -rf tmp/rollup \ && git clone --depth 1 --branch v2.39.1 https://github.com/rollup/rollup.git tmp/rollup \ && cd tmp/rollup \ @@ -44,11 +51,11 @@ rm -rf tmp/rollup \ +sander.rimrafSync(__dirname, 'samples', 'watch', 'watch-config-initial-error'); EOF ERR=$?; if [ "$ERR" != "0" ]; then echo "Error: $ERR"; exit $ERR; fi -npm install esbuild-wasm@0.8.56 \ +npm_install esbuild-wasm@0.8.56 \ && minify_in_situ "cli" \ && minify_in_situ "src" \ && rm -rf node_modules \ -&& npm ci \ +&& npm_install \ && rm -rf dist \ && npm run build \ && minify_in_situ "dist" \ diff --git a/test/release/sucrase.sh b/test/release/sucrase.sh index 7c36dd95..07b0aa80 100755 --- a/test/release/sucrase.sh +++ b/test/release/sucrase.sh @@ -28,6 +28,13 @@ EOF uglify-js $ARGS } +npm_install() { + PKG="$1" + while !(npm install $PKG); do + while !(npm cache clean --force); do echo "'npm cache clean' failed - retrying..."; done + done +} + rm -rf tmp/sucrase \ && git clone https://github.com/alangpierce/sucrase.git tmp/sucrase \ && cd tmp/sucrase \ @@ -83,10 +90,10 @@ rm -rf tmp/sucrase \ +export { getJSXPragmaInfo as HACK }; EOF ERR=$?; if [ "$ERR" != "0" ]; then echo "Error: $ERR"; exit $ERR; fi -npm install esbuild-wasm@0.8.56 \ +npm_install esbuild-wasm@0.8.56 \ && minify_in_situ "src" \ && rm -rf node_modules \ -&& npm install \ +&& npm_install \ && npm run clean \ && npm run build \ && minify_in_situ "dist" \ diff --git a/test/release/web-tooling-benchmark.sh b/test/release/web-tooling-benchmark.sh index 42566137..bf00a2f5 100755 --- a/test/release/web-tooling-benchmark.sh +++ b/test/release/web-tooling-benchmark.sh @@ -14,6 +14,13 @@ minify_in_situ() { uglify-js $ARGS } +npm_install() { + PKG="$1" + while !(npm install $PKG); do + while !(npm cache clean --force); do echo "'npm cache clean' failed - retrying..."; done + done +} + rm -rf tmp/web-tooling-benchmark \ && git clone --depth 1 --branch v0.5.3 https://github.com/v8/web-tooling-benchmark.git tmp/web-tooling-benchmark \ && cd tmp/web-tooling-benchmark \ @@ -47,7 +54,7 @@ ERR=$?; if [ "$ERR" != "0" ]; then echo "Error: $ERR"; exit $ERR; fi minify_in_situ "src" \ && minify_in_situ "third_party" \ && rm -rf node_modules \ -&& npm ci \ +&& npm_install \ && rm -rf build/* \ && npm run build:terser-bundled \ && npm run build:uglify-js-bundled \ -- cgit v1.2.3