Skip to content
Myr

windows-nvm.yml

This file

Path

.github/workflows/windows-nvm.yml

309 lines · 11.4 KiB · YAML

Last changed by

[actions] never let an apt install wait on a promptJordan Harbandbefore adoption077156e

History of this file

Take it

[actions] rename `windows-npm` workflow to `windows-nvm`, since it tests `nvm install`Jordan Harbandbefore adoption3bfc2b4

lines 1–147why, one step back
1name: 'Tests on Windows: `nvm install`'
23on: [pull_request, push]45permissions:6 contents: read78env:9 NVM_INSTALL_GITHUB_REPO: ${{ github.repository }}10 NVM_INSTALL_VERSION: ${{ github.sha }}1112jobs:13 msys_fail_install:14 # Default installation does not work due to npm_config_prefix set to C:\npm\prefix15 permissions:16 contents: none17 name: 'MSYS fail prefix nvm install'18 runs-on: windows-latest19 steps:20 - name: Retrieve nvm21 shell: bash22 run: |23 curl -fsSLo- "https://raw.githubusercontent.com/${NVM_INSTALL_GITHUB_REPO}/${NVM_INSTALL_VERSION}/install.sh" | METHOD=script bash24 . "$HOME/.nvm/nvm.sh"25 ! nvm install --lts2627 msys_matrix:28 permissions:29 contents: none30 name: 'MSYS nvm install'31 runs-on: windows-latest32 strategy:33 fail-fast: false34 matrix:35 npm-node-version:36 - '--lts'37 - '--default 12'38 - '--no-progress 10'39 steps:40 - name: Retrieve nvm41 shell: bash42 run: |43 unset npm_config_prefix44 if [ "${{ matrix.npm-node-version }}" = "--lts" ]; then45 curl -fsSLo- "https://raw.githubusercontent.com/${NVM_INSTALL_GITHUB_REPO}/${NVM_INSTALL_VERSION}/install.sh" | bash46 else47 curl -fsSLo- "https://raw.githubusercontent.com/${NVM_INSTALL_GITHUB_REPO}/${NVM_INSTALL_VERSION}/install.sh" | METHOD=script bash48 fi49 . "$HOME/.nvm/nvm.sh"50 nvm install ${{ matrix.npm-node-version }}5152 cygwin_matrix:53 continue-on-error: true54 permissions:55 contents: none56 name: 'Cygwin nvm install'57 runs-on: windows-latest58 steps:59 - name: Install Cygwin60 shell: bash61 run: |62 export SITE='https://mirror.clarkson.edu/cygwin/' # see https://archlinux.org/mirrors/clarkson.edu/1603/ for uptime status63 export SITE='https://mirrors.kernel.org/sourceware/cygwin/'64 export LOCALDIR="$(pwd)"65 export ROOTDIR="$USERPROFILE\\cygwin"66 export PACKAGES='bash,git,curl'6768 curl -fsSLo setup-x86_64.exe 'https://cygwin.com/setup-x86_64.exe'69 ./setup-x86_64.exe --disable-buggy-antivirus -q -s "$SITE" -l "$LOCALDIR" -R "$ROOTDIR" -P "$PACKAGES"7071 cat >~/setup.sh <<EOM72 unset npm_config_prefix73 export NVM_INSTALL_GITHUB_REPO="$NVM_INSTALL_GITHUB_REPO"74 export NVM_INSTALL_VERSION="$NVM_INSTALL_VERSION"75 export HOME="$(cygpath -u "$USERPROFILE")"7677 echo "HOME is $HOME"78 curl -fsSLo- "https://raw.githubusercontent.com/${NVM_INSTALL_GITHUB_REPO}/${NVM_INSTALL_VERSION}/install.sh" | bash79 ls -l $HOME/.nvm80 . "$HOME/.nvm/nvm.sh"81 nvm install --lts8283 nvm deactivate84 rm -rf "$HOME/.nvm/nvm.sh"8586 curl -fsSLo- "https://raw.githubusercontent.com/${NVM_INSTALL_GITHUB_REPO}/${NVM_INSTALL_VERSION}/install.sh" | METHOD=script bash87 . "$HOME/.nvm/nvm.sh"88 nvm install 989 EOM90 - name: Retrieve nvm91 shell: cmd92 run: |93 cd %USERPROFILE%\cygwin\bin94 bash.exe "%USERPROFILE%\setup.sh"9596 wsl_matrix:97 permissions:98 contents: none99 continue-on-error: true100 name: 'WSL nvm install'101 defaults:102 run:103 shell: wsl-bash {0}104 runs-on: windows-latest105 env:106 WSLENV: NVM_INSTALL_GITHUB_REPO:NVM_INSTALL_VERSION:/p107 strategy:108 fail-fast: false109 matrix:110 # each line gets a pin, plus the newest setup-wsl offers for it; the111 # newest only moves when the action's major does, so bumping the `uses:`112 # ref below is what keeps this current113 wsl-distrib:114 - Debian-12115 - Debian-13116 # - Alpine-3.17 # fails117 - Ubuntu-20.04118 - Ubuntu-24.04119 - Ubuntu-18.04120 npm-node-version:121 - '--lts'122 - '21'123 - '18'124 - '16'125 - '14'126 - '12'127 - '10'128 exclude:129 - wsl-distrib: Ubuntu-18.04130 npm-node-version: '--lts'131 - wsl-distrib: Ubuntu-18.04132 npm-node-version: '21'133 - wsl-distrib: Ubuntu-18.04134 npm-node-version: '18'135 # node v24+ doesn't work on WSL1 (exec format error)136 - wsl-distrib: Debian-12137 npm-node-version: '--lts'138 - wsl-distrib: Debian-13139 npm-node-version: '--lts'140 - wsl-distrib: Ubuntu-20.04141 npm-node-version: '--lts'142 - wsl-distrib: Ubuntu-24.04143 npm-node-version: '--lts'144 method:145 - ''146 - 'script'147 steps:

[actions] retry apt package installs through Ubuntu mirror outagesJordan Harbandbefore adoption50e73c4

line 148why, one step back
148 # For Ubuntu: `additional-packages` can't retry, so install in a separate step

[actions] rename `windows-npm` workflow to `windows-nvm`, since it tests `nvm install`Jordan Harbandbefore adoption3bfc2b4

lines 149–152why, one step back
149 - if: ${{ !startsWith(matrix.wsl-distrib, 'Debian') }}
150 uses: Vampire/setup-wsl@v7151 with:152 distribution: ${{ matrix.wsl-distrib }}

[actions] retry apt package installs through Ubuntu mirror outagesJordan Harbandbefore adoption50e73c4

lines 153–159why, one step back
153 # mirror outages can outlast apt's own retries, so retry update+install with
154 # backoff for about 10 minutes (as .github/scripts/apt-install.sh does; this155 # job has no checkout)156 - if: ${{ !startsWith(matrix.wsl-distrib, 'Debian') }}157 name: 'Install packages with retries'158 shell: 'wsl-bash {0}'159 run: |

[actions] never let an apt install wait on a promptJordan Harbandbefore adoption077156e

lines 160–161why, one step back
160 # never prompt: an upgrade (e.g. libssl asking to restart services) would wait forever
161 export DEBIAN_FRONTEND=noninteractive

[actions] retry apt package installs through Ubuntu mirror outagesJordan Harbandbefore adoption50e73c4

lines 162–164why, one step back
162 attempt=1
163 delay=15164 while true; do

[actions] never let an apt install wait on a promptJordan Harbandbefore adoption077156e

lines 165–166why, one step back
165 apt-get -o Acquire::Retries=5 update < /dev/null || true
166 if apt-get -o Acquire::Retries=5 -o Dpkg::Options::=--force-confdef -o Dpkg::Options::=--force-confold install --yes bash git curl ca-certificates wget < /dev/null; then

[actions] retry apt package installs through Ubuntu mirror outagesJordan Harbandbefore adoption50e73c4

lines 167–178why, one step back
167 break
168 fi169 if [ "${attempt}" -ge 8 ]; then170 echo "apt-get install failed after ${attempt} attempts" >&2171 exit 1172 fi173 echo "apt-get install failed (attempt ${attempt}/8); retrying in ${delay}s" >&2174 sleep "${delay}"175 attempt=$((attempt + 1))176 delay=$((delay * 2))177 if [ "${delay}" -gt 120 ]; then delay=120; fi178 done

[actions] rename `windows-npm` workflow to `windows-nvm`, since it tests `nvm install`Jordan Harbandbefore adoption3bfc2b4

lines 179–231why, one step back
179
180 # For Debian, install without packages: `additional-packages` would run181 # `apt-get update` before we get to fix up sources.list182 # see https://github.com/Vampire/setup-wsl/issues/76183 - if: ${{ startsWith(matrix.wsl-distrib, 'Debian') }}184 uses: Vampire/setup-wsl@v7185 with:186 distribution: ${{ matrix.wsl-distrib }}187 # Debian's mirror layout shifts as a release ages out of LTS: main moves to188 # archive.debian.org, and the security suite is both renamed and moved, on189 # its own schedule. Offer every layout and let `apt-get update` discard the190 # ones that 404, so this needs no edits as the image's release ages.191 - if: ${{ startsWith(matrix.wsl-distrib, 'Debian') }}192 name: 'Point apt at whichever mirrors still carry this release'193 shell: 'wsl-bash {0}'194 run: |195 codename="$(. /etc/os-release && printf '%s' "${VERSION_CODENAME-}")"196 if [ -z "${codename}" ]; then197 echo 'no VERSION_CODENAME in /etc/os-release' >&2198 exit 1199 fi200 # Debian 13 moved to deb822; drop both formats so what we write is the201 # only thing apt reads, whichever release is pinned202 rm -f /etc/apt/sources.list.d/*.list /etc/apt/sources.list.d/*.sources203 {204 echo "deb http://deb.debian.org/debian ${codename} main"205 echo "deb http://archive.debian.org/debian ${codename} main"206 echo "deb http://security.debian.org/debian-security ${codename}-security main"207 echo "deb http://archive.debian.org/debian-security ${codename}-security main"208 echo "deb http://archive.debian.org/debian-security ${codename}/updates main"209 } >/etc/apt/sources.list210 cat /etc/apt/sources.list211 - if: ${{ startsWith(matrix.wsl-distrib, 'Debian') }}212 name: 'Install packages with retries'213 shell: 'wsl-bash {0}'214 run: |215 retry() {216 local n=0217 local max=3218 local delay=5219 while true; do220 "$@" && break || {221 n=$((n+1))222 if [ $n -lt $max ]; then223 echo "Command failed. Attempt $n/$max. Retrying in $delay seconds..."224 sleep $delay225 else226 echo "Command failed after $max attempts."227 return 1228 fi229 }230 done231 }

[actions] never let an apt install wait on a promptJordan Harbandbefore adoption077156e

lines 232–233why, one step back
232 # never prompt: an upgrade (e.g. libssl asking to restart services) would wait forever
233 export DEBIAN_FRONTEND=noninteractive

[actions] rename `windows-npm` workflow to `windows-nvm`, since it tests `nvm install`Jordan Harbandbefore adoption3bfc2b4

line 234why, one step back
234 packages=(bash git curl ca-certificates wget)

[actions] never let an apt install wait on a promptJordan Harbandbefore adoption077156e

lines 235–237why, one step back
235 install_options=(-o Dpkg::Options::=--force-confdef -o Dpkg::Options::=--force-confold install --yes)
236 retry apt-get update < /dev/null || true237 if ! retry apt-get "${install_options[@]}" "${packages[@]}" < /dev/null; then

[actions] rename `windows-npm` workflow to `windows-nvm`, since it tests `nvm install`Jordan Harbandbefore adoption3bfc2b4

lines 238–240why, one step back
238 # a security index can outlive the pool objects it advertises, which
239 # no retry resolves; main is complete once a release is archived240 sed -i '/debian-security/d' /etc/apt/sources.list

[actions] never let an apt install wait on a promptJordan Harbandbefore adoption077156e

lines 241–242why, one step back
241 retry apt-get update < /dev/null || true
242 retry apt-get "${install_options[@]}" "${packages[@]}" < /dev/null

[actions] rename `windows-npm` workflow to `windows-nvm`, since it tests `nvm install`Jordan Harbandbefore adoption3bfc2b4

lines 243–309why, one step back
243 fi
244245 - name: Retrieve nvm on WSL246 run: |247 if [ -z "${{ matrix.method }}" ]; then248 curl -fsSLo- "https://raw.githubusercontent.com/${NVM_INSTALL_GITHUB_REPO}/${NVM_INSTALL_VERSION}/install.sh" | bash249 else250 curl -fsSLo- "https://raw.githubusercontent.com/${NVM_INSTALL_GITHUB_REPO}/${NVM_INSTALL_VERSION}/install.sh" | METHOD="${{matrix.method}}" bash251 fi252 . "$HOME/.nvm/nvm.sh"253 nvm install ${{ matrix.npm-node-version }}254 node -v255256 wsl_matrix_unofficial:257 permissions:258 contents: none259 continue-on-error: true260 name: 'WSL nvm install'261 defaults:262 run:263 shell: wsl-bash {0}264 runs-on: windows-latest265 env:266 WSLENV: NVM_INSTALL_GITHUB_REPO:NVM_INSTALL_VERSION:/p267 NVM_NODEJS_ORG_MIRROR: https://unofficial-builds.nodejs.org/download/release268 strategy:269 fail-fast: false270 matrix:271 wsl-distrib:272 - Alpine-3.17273 - Alpine-3.23274 npm-node-version:275 - '--lts'276 - '21'277 - '18'278 - '16'279 - '14'280 - '12'281 - '11'282 - '10'283 method:284 - ''285 - 'script'286 steps:287 - uses: Vampire/setup-wsl@v7288 with:289 distribution: ${{ matrix.wsl-distrib }}290 additional-packages: bash git curl ca-certificates wget291292 - name: Retrieve nvm on WSL293 run: |294 if [ -z "${{ matrix.method }}" ]; then295 curl -fsSLo- "https://raw.githubusercontent.com/${NVM_INSTALL_GITHUB_REPO}/${NVM_INSTALL_VERSION}/install.sh" | bash296 else297 curl -fsSLo- "https://raw.githubusercontent.com/${NVM_INSTALL_GITHUB_REPO}/${NVM_INSTALL_VERSION}/install.sh" | METHOD="${{matrix.method}}" bash298 fi299 . "$HOME/.nvm/nvm.sh"300 NVM_NODEJS_ORG_MIRROR=${{ env.NVM_NODEJS_ORG_MIRROR }} nvm install ${{ matrix.npm-node-version }}301302 nvm_windows:303 name: 'tests, on windows'304 permissions:305 contents: none306 needs: [wsl_matrix, wsl_matrix_unofficial, cygwin_matrix, msys_matrix, msys_fail_install]307 runs-on: ubuntu-latest308 steps:309 - run: true