From 1cbfc43f6005822d994007879538024e55cbce51 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Tue, 1 Mar 2022 12:13:19 +0100 Subject: [PATCH 1/4] fix(ci): add hacky workaround for node-gyp bug See the comments in the script itself. This is not ideal but at this point anything that gets CI up any running is good. :) --- .evergreen/node-gyp-bug-workaround.sh | 49 +++++++++++++++++++ .evergreen/preinstall.sh | 5 +- .../authors-and-third-party-notices.yaml | 6 ++- .github/workflows/build.yaml | 5 +- .github/workflows/check-test.yaml | 5 +- .github/workflows/connectivity-tests.yaml | 5 +- 6 files changed, 70 insertions(+), 5 deletions(-) create mode 100755 .evergreen/node-gyp-bug-workaround.sh diff --git a/.evergreen/node-gyp-bug-workaround.sh b/.evergreen/node-gyp-bug-workaround.sh new file mode 100755 index 00000000000..579c4897d03 --- /dev/null +++ b/.evergreen/node-gyp-bug-workaround.sh @@ -0,0 +1,49 @@ +#!/usr/bin/env bash + +# This is a workaround for a node-gyp bug that has not fully been investigated +# due to problems reproducing it outside of CI environments (even though it +# occurs both in evergreen and github actions). +# Something seems to go wrong when node-gyp extracts the Node.js header tarball, +# on Windows specifically (this is most likely because node-tar treats +# the overwriting of existing files differently on Windows than on other OS -- +# for good reasons, but still). +# The most likely cause of this issue is that node-gyp somehow extracts the +# same headers tarball twice, in parallel, in the same location, with race +# conditions in the tar extraction code leading to issues. +# The extraction result ends up in %LOCALAPPDATA%\node-gyp\Cache. +# Manually extracting the tarballs will solve this issue, so we're doing that +# here. +# For actually resolving the bug, we would probably need somebody with a local +# reproduction. However, it seems likely that other people will also encounter +# this issue, so there's also a good chance that this workaround will just +# not be needed with a future node-gyp version. + +if [ x"$NODE_JS_VERSION" = x"" ]; then + if node -v; then + export NODE_JS_VERSION=$(node -p 'process.version.slice(1)') + else + echo "Need NODE_JS_VERSION to be set or Node.js to be installed for node-gyp bug workaround script" + exit 1 + fi +fi + +if [ x"$LOCALAPPDATA" = x"" ]; then + echo "No LOCALAPPDATA set, ignoring node-gyp bug workaround script" + exit +fi + +set -x +CACHEDIR="$LOCALAPPDATA/node-gyp/Cache" +rm -rvf "$CACHEDIR" +mkdir -p "$CACHEDIR/$NODE_JS_VERSION" +cd "$CACHEDIR/$NODE_JS_VERSION" +curl -sSfLO "https://nodejs.org/download/release/$NODE_JS_VERSION/node-$NODE_JS_VERSION-headers.tar.gz" +tar --strip-components=1 -xvzf "node-$NODE_JS_VERSION-headers.tar.gz" +for arch in x64 x86 arm64; do + mkdir $arch + cd $arch && \ + curl -sSfLO "https://nodejs.org/download/release/$NODE_JS_VERSION/win-$ARCH/node.lib" || echo "no $ARCH $NODE_JS_VERSION .lib file" +done + +# Finally, store the right installVersion value for current node-gyp versions +echo 9 > installVersion diff --git a/.evergreen/preinstall.sh b/.evergreen/preinstall.sh index 3420b30ebf4..aceab808468 100755 --- a/.evergreen/preinstall.sh +++ b/.evergreen/preinstall.sh @@ -35,6 +35,9 @@ if [ -n "$IS_WINDOWS" ]; then ./node.exe node_modules/npm2/bin/npm-cli.js i -g npm@$NPM_VERSION rm -rf node_modules/npm2/ chmod +x npm.cmd npm + + cd .. + .evergreen/node-gyp-bug-workaround.sh else echo "Installing nodejs v${NODE_JS_VERSION} for ${PLATFORM}..." curl -fs \ @@ -53,4 +56,4 @@ else ./bin/node lib/node_modules/npm2/bin/npm-cli.js i -g npm@$NPM_VERSION rm -rf lib/node_modules/npm2/ -fi \ No newline at end of file +fi diff --git a/.github/workflows/authors-and-third-party-notices.yaml b/.github/workflows/authors-and-third-party-notices.yaml index a7af27cc833..e23ec4af87b 100644 --- a/.github/workflows/authors-and-third-party-notices.yaml +++ b/.github/workflows/authors-and-third-party-notices.yaml @@ -25,7 +25,11 @@ jobs: - name: Install npm@8.3.1 run: | npm install -g npm@8.3.1 - npx --yes rimraf $LOCALAPPDATA/node-gyp/Cache || true + + - name: Run node-gyp bug workaround script + run: | + NODE_JS_VERSION=$(node -p 'process.version.slice(1)') \ + .evergreen/node-gyp-bug-workaround.sh - name: Install Dependencies run: | diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 2f633ca75cc..9dc101cd125 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -52,7 +52,10 @@ jobs: - name: Install npm@8.3.1 run: | npm install -g npm@8.3.1 - npx --yes rimraf $LOCALAPPDATA/node-gyp/Cache || true + + - name: Run node-gyp bug workaround script + run: | + .evergreen/node-gyp-bug-workaround.sh - name: Install Dependencies run: | diff --git a/.github/workflows/check-test.yaml b/.github/workflows/check-test.yaml index d41dc286a27..0b16ff66d33 100644 --- a/.github/workflows/check-test.yaml +++ b/.github/workflows/check-test.yaml @@ -49,7 +49,10 @@ jobs: - name: Install npm@8.3.1 run: | npm install -g npm@8.3.1 - npx --yes rimraf $LOCALAPPDATA/node-gyp/Cache || true + + - name: Run node-gyp bug workaround script + run: | + .evergreen/node-gyp-bug-workaround.sh - name: Install Dependencies run: | diff --git a/.github/workflows/connectivity-tests.yaml b/.github/workflows/connectivity-tests.yaml index 7ebea2f3ff0..993bc31a558 100644 --- a/.github/workflows/connectivity-tests.yaml +++ b/.github/workflows/connectivity-tests.yaml @@ -79,7 +79,10 @@ jobs: - name: Install npm@8.3.1 run: | npm install -g npm@8.3.1 - npx --yes rimraf $LOCALAPPDATA/node-gyp/Cache || true + + - name: Run node-gyp bug workaround script + run: | + .evergreen/node-gyp-bug-workaround.sh - name: Install Dependencies run: | From cd9ac795a2c1b9bf3357effc616b10c87a699a63 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Tue, 1 Mar 2022 12:37:37 +0100 Subject: [PATCH 2/4] fixup: use bash in github actions explicitly --- .github/workflows/authors-and-third-party-notices.yaml | 3 +-- .github/workflows/build.yaml | 2 +- .github/workflows/check-test.yaml | 2 +- .github/workflows/connectivity-tests.yaml | 2 +- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/authors-and-third-party-notices.yaml b/.github/workflows/authors-and-third-party-notices.yaml index e23ec4af87b..92c552b7c50 100644 --- a/.github/workflows/authors-and-third-party-notices.yaml +++ b/.github/workflows/authors-and-third-party-notices.yaml @@ -28,8 +28,7 @@ jobs: - name: Run node-gyp bug workaround script run: | - NODE_JS_VERSION=$(node -p 'process.version.slice(1)') \ - .evergreen/node-gyp-bug-workaround.sh + bash .evergreen/node-gyp-bug-workaround.sh - name: Install Dependencies run: | diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 9dc101cd125..4083ab4b815 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -55,7 +55,7 @@ jobs: - name: Run node-gyp bug workaround script run: | - .evergreen/node-gyp-bug-workaround.sh + bash .evergreen/node-gyp-bug-workaround.sh - name: Install Dependencies run: | diff --git a/.github/workflows/check-test.yaml b/.github/workflows/check-test.yaml index 0b16ff66d33..240b6bb85d0 100644 --- a/.github/workflows/check-test.yaml +++ b/.github/workflows/check-test.yaml @@ -52,7 +52,7 @@ jobs: - name: Run node-gyp bug workaround script run: | - .evergreen/node-gyp-bug-workaround.sh + bash .evergreen/node-gyp-bug-workaround.sh - name: Install Dependencies run: | diff --git a/.github/workflows/connectivity-tests.yaml b/.github/workflows/connectivity-tests.yaml index 993bc31a558..1d9c3acc756 100644 --- a/.github/workflows/connectivity-tests.yaml +++ b/.github/workflows/connectivity-tests.yaml @@ -82,7 +82,7 @@ jobs: - name: Run node-gyp bug workaround script run: | - .evergreen/node-gyp-bug-workaround.sh + bash .evergreen/node-gyp-bug-workaround.sh - name: Install Dependencies run: | From 4e34274ee425533b36194e0ced68589f00570dac Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Tue, 1 Mar 2022 12:39:23 +0100 Subject: [PATCH 3/4] fixup: properly v-prefix versions --- .evergreen/node-gyp-bug-workaround.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.evergreen/node-gyp-bug-workaround.sh b/.evergreen/node-gyp-bug-workaround.sh index 579c4897d03..73c75149d86 100755 --- a/.evergreen/node-gyp-bug-workaround.sh +++ b/.evergreen/node-gyp-bug-workaround.sh @@ -37,12 +37,12 @@ CACHEDIR="$LOCALAPPDATA/node-gyp/Cache" rm -rvf "$CACHEDIR" mkdir -p "$CACHEDIR/$NODE_JS_VERSION" cd "$CACHEDIR/$NODE_JS_VERSION" -curl -sSfLO "https://nodejs.org/download/release/$NODE_JS_VERSION/node-$NODE_JS_VERSION-headers.tar.gz" -tar --strip-components=1 -xvzf "node-$NODE_JS_VERSION-headers.tar.gz" +curl -sSfLO "https://nodejs.org/download/release/v$NODE_JS_VERSION/node-v$NODE_JS_VERSION-headers.tar.gz" +tar --strip-components=1 -xvzf "node-v$NODE_JS_VERSION-headers.tar.gz" for arch in x64 x86 arm64; do mkdir $arch cd $arch && \ - curl -sSfLO "https://nodejs.org/download/release/$NODE_JS_VERSION/win-$ARCH/node.lib" || echo "no $ARCH $NODE_JS_VERSION .lib file" + curl -sSfLO "https://nodejs.org/download/release/v$NODE_JS_VERSION/win-$arch/node.lib" || echo "no $arch v$NODE_JS_VERSION .lib file" done # Finally, store the right installVersion value for current node-gyp versions From 91f3760a201e52d63f870311840d29c2890900ca Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Tue, 1 Mar 2022 12:49:03 +0100 Subject: [PATCH 4/4] fixup: pushd/popd instead of bad cd --- .evergreen/node-gyp-bug-workaround.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.evergreen/node-gyp-bug-workaround.sh b/.evergreen/node-gyp-bug-workaround.sh index 73c75149d86..128f3c646eb 100755 --- a/.evergreen/node-gyp-bug-workaround.sh +++ b/.evergreen/node-gyp-bug-workaround.sh @@ -41,8 +41,9 @@ curl -sSfLO "https://nodejs.org/download/release/v$NODE_JS_VERSION/node-v$NODE_J tar --strip-components=1 -xvzf "node-v$NODE_JS_VERSION-headers.tar.gz" for arch in x64 x86 arm64; do mkdir $arch - cd $arch && \ - curl -sSfLO "https://nodejs.org/download/release/v$NODE_JS_VERSION/win-$arch/node.lib" || echo "no $arch v$NODE_JS_VERSION .lib file" + pushd $arch + curl -sSfLO "https://nodejs.org/download/release/v$NODE_JS_VERSION/win-$arch/node.lib" || echo "no $arch v$NODE_JS_VERSION .lib file" + popd done # Finally, store the right installVersion value for current node-gyp versions