Files
Jordan Harband 0a6e489837 [actions] WSL: cap jobs at 10 minutes, since a frozen runner otherwise holds one for 45; don't wait on Ubuntu's mirror
About 1.4% of WSL jobs freeze the runner while setup-wsl starts WSL2
(actions/runner-images#14938):
no step ever finishes, no step timeout fires,
and GitHub drops the job as "lost communication" after 45 minutes,
holding up nearly every run.
A job-level `timeout-minutes` is enforced by the server, so it still applies.

Ubuntu's images already ship bash, git, curl, wget and ca-certificates,
so its apt step only upgrades them,
and a slow `archive.ubuntu.com` has stretched that to 30 minutes.
When they are present, give the upgrade a minute and carry on without it;
otherwise retry 3 times with short delays instead of 8 over 10 minutes.
2026-11-23 14:47:07 -08:00

336 lines
13 KiB
YAML

name: 'Tests on Windows: `nvm install`'
on: [pull_request, push]
permissions:
contents: read
env:
NVM_INSTALL_GITHUB_REPO: ${{ github.repository }}
NVM_INSTALL_VERSION: ${{ github.sha }}
jobs:
msys_fail_install:
# Default installation does not work due to npm_config_prefix set to C:\npm\prefix
permissions:
contents: none
name: 'MSYS fail prefix nvm install'
runs-on: windows-latest
steps:
- name: Retrieve nvm
shell: bash
run: |
curl -fsSLo- "https://raw.githubusercontent.com/${NVM_INSTALL_GITHUB_REPO}/${NVM_INSTALL_VERSION}/install.sh" | METHOD=script bash
. "$HOME/.nvm/nvm.sh"
! nvm install --lts
msys_matrix:
permissions:
contents: none
name: 'MSYS nvm install'
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
npm-node-version:
- '--lts'
- '--default 12'
- '--no-progress 10'
steps:
- name: Retrieve nvm
shell: bash
run: |
unset npm_config_prefix
if [ "${{ matrix.npm-node-version }}" = "--lts" ]; then
curl -fsSLo- "https://raw.githubusercontent.com/${NVM_INSTALL_GITHUB_REPO}/${NVM_INSTALL_VERSION}/install.sh" | bash
else
curl -fsSLo- "https://raw.githubusercontent.com/${NVM_INSTALL_GITHUB_REPO}/${NVM_INSTALL_VERSION}/install.sh" | METHOD=script bash
fi
. "$HOME/.nvm/nvm.sh"
nvm install ${{ matrix.npm-node-version }}
cygwin_matrix:
continue-on-error: true
permissions:
contents: none
name: 'Cygwin nvm install'
runs-on: windows-latest
steps:
- name: Install Cygwin
shell: bash
run: |
export SITE='https://mirror.clarkson.edu/cygwin/' # see https://archlinux.org/mirrors/clarkson.edu/1603/ for uptime status
export SITE='https://mirrors.kernel.org/sourceware/cygwin/'
export LOCALDIR="$(pwd)"
export ROOTDIR="$USERPROFILE\\cygwin"
export PACKAGES='bash,git,curl'
curl -fsSLo setup-x86_64.exe 'https://cygwin.com/setup-x86_64.exe'
./setup-x86_64.exe --disable-buggy-antivirus -q -s "$SITE" -l "$LOCALDIR" -R "$ROOTDIR" -P "$PACKAGES"
cat >~/setup.sh <<EOM
unset npm_config_prefix
export NVM_INSTALL_GITHUB_REPO="$NVM_INSTALL_GITHUB_REPO"
export NVM_INSTALL_VERSION="$NVM_INSTALL_VERSION"
export HOME="$(cygpath -u "$USERPROFILE")"
echo "HOME is $HOME"
curl -fsSLo- "https://raw.githubusercontent.com/${NVM_INSTALL_GITHUB_REPO}/${NVM_INSTALL_VERSION}/install.sh" | bash
ls -l $HOME/.nvm
. "$HOME/.nvm/nvm.sh"
nvm install --lts
nvm deactivate
rm -rf "$HOME/.nvm/nvm.sh"
curl -fsSLo- "https://raw.githubusercontent.com/${NVM_INSTALL_GITHUB_REPO}/${NVM_INSTALL_VERSION}/install.sh" | METHOD=script bash
. "$HOME/.nvm/nvm.sh"
nvm install 9
EOM
- name: Retrieve nvm
shell: cmd
run: |
cd %USERPROFILE%\cygwin\bin
bash.exe "%USERPROFILE%\setup.sh"
wsl_matrix:
permissions:
contents: none
continue-on-error: true
name: 'WSL nvm install'
defaults:
run:
shell: wsl-bash {0}
runs-on: windows-latest
# a passing run takes about 2 minutes. The runner sometimes freezes while
# starting WSL2 (actions/runner-images#14938); no step timeout can fire then,
# and GitHub would only give up on it after 45 minutes
timeout-minutes: 10
env:
WSLENV: NVM_INSTALL_GITHUB_REPO:NVM_INSTALL_VERSION:/p
strategy:
fail-fast: false
matrix:
# each line gets a pin, plus the newest setup-wsl offers for it; the
# newest only moves when the action's major does, so bumping the `uses:`
# ref below is what keeps this current
wsl-distrib:
- Debian-12
- Debian-13
# - Alpine-3.17 # fails
- Ubuntu-20.04
- Ubuntu-24.04
- Ubuntu-18.04
npm-node-version:
- '--lts'
- '21'
- '18'
- '16'
- '14'
- '12'
- '10'
exclude:
- wsl-distrib: Ubuntu-18.04
npm-node-version: '--lts'
- wsl-distrib: Ubuntu-18.04
npm-node-version: '21'
- wsl-distrib: Ubuntu-18.04
npm-node-version: '18'
# node v24+ doesn't work on WSL1 (exec format error)
- wsl-distrib: Debian-12
npm-node-version: '--lts'
- wsl-distrib: Debian-13
npm-node-version: '--lts'
- wsl-distrib: Ubuntu-20.04
npm-node-version: '--lts'
- wsl-distrib: Ubuntu-24.04
npm-node-version: '--lts'
method:
- ''
- 'script'
steps:
# For Ubuntu: `additional-packages` can't retry, so install in a separate step
- if: ${{ !startsWith(matrix.wsl-distrib, 'Debian') }}
uses: Vampire/setup-wsl@v7
timeout-minutes: 3
with:
distribution: ${{ matrix.wsl-distrib }}
# Ubuntu's images already have these packages, so apt only upgrades them;
# a slow mirror (25 kB/s has been seen) must not hold the job for that
- if: ${{ !startsWith(matrix.wsl-distrib, 'Debian') }}
name: 'Install packages with retries'
shell: 'wsl-bash {0}'
timeout-minutes: 5
run: |
# never prompt: an upgrade (e.g. libssl asking to restart services) would wait forever
export DEBIAN_FRONTEND=noninteractive
apt_options=(-o Acquire::Retries=3 -o Acquire::http::Timeout=20 -o Acquire::Languages=none)
install_options=(-o Dpkg::Options::=--force-confdef -o Dpkg::Options::=--force-confold install --yes)
packages=(bash git curl ca-certificates wget)
have_all=1
for cmd in bash git curl wget; do
command -v "${cmd}" >/dev/null || have_all=0
done
[ -f /etc/ssl/certs/ca-certificates.crt ] || have_all=0
if [ "${have_all}" = 1 ]; then
if ! { timeout 60 apt-get "${apt_options[@]}" update && timeout 60 apt-get "${apt_options[@]}" "${install_options[@]}" "${packages[@]}"; } < /dev/null; then
echo '::warning::could not upgrade the preinstalled packages; continuing with the ones in the image'
fi
exit 0
fi
attempt=1
delay=5
while true; do
timeout 120 apt-get "${apt_options[@]}" update < /dev/null || true
if timeout 120 apt-get "${apt_options[@]}" "${install_options[@]}" "${packages[@]}" < /dev/null; then
break
fi
if [ "${attempt}" -ge 3 ]; then
echo "apt-get install failed after ${attempt} attempts" >&2
exit 1
fi
echo "apt-get install failed (attempt ${attempt}/3); retrying in ${delay}s" >&2
sleep "${delay}"
attempt=$((attempt + 1))
delay=$((delay * 2))
done
# For Debian, install without packages: `additional-packages` would run
# `apt-get update` before we get to fix up sources.list
# see https://github.com/Vampire/setup-wsl/issues/76
- if: ${{ startsWith(matrix.wsl-distrib, 'Debian') }}
uses: Vampire/setup-wsl@v7
timeout-minutes: 3
with:
distribution: ${{ matrix.wsl-distrib }}
# Debian's mirror layout shifts as a release ages out of LTS: main moves to
# archive.debian.org, and the security suite is both renamed and moved, on
# its own schedule. Offer every layout and let `apt-get update` discard the
# ones that 404, so this needs no edits as the image's release ages.
- if: ${{ startsWith(matrix.wsl-distrib, 'Debian') }}
name: 'Point apt at whichever mirrors still carry this release'
shell: 'wsl-bash {0}'
timeout-minutes: 1
run: |
codename="$(. /etc/os-release && printf '%s' "${VERSION_CODENAME-}")"
if [ -z "${codename}" ]; then
echo 'no VERSION_CODENAME in /etc/os-release' >&2
exit 1
fi
# Debian 13 moved to deb822; drop both formats so what we write is the
# only thing apt reads, whichever release is pinned
rm -f /etc/apt/sources.list.d/*.list /etc/apt/sources.list.d/*.sources
{
echo "deb http://deb.debian.org/debian ${codename} main"
echo "deb http://archive.debian.org/debian ${codename} main"
echo "deb http://security.debian.org/debian-security ${codename}-security main"
echo "deb http://archive.debian.org/debian-security ${codename}-security main"
echo "deb http://archive.debian.org/debian-security ${codename}/updates main"
} >/etc/apt/sources.list
cat /etc/apt/sources.list
- if: ${{ startsWith(matrix.wsl-distrib, 'Debian') }}
name: 'Install packages with retries'
shell: 'wsl-bash {0}'
timeout-minutes: 5
run: |
retry() {
local n=0
local max=3
local delay=5
while true; do
"$@" && break || {
n=$((n+1))
if [ $n -lt $max ]; then
echo "Command failed. Attempt $n/$max. Retrying in $delay seconds..."
sleep $delay
else
echo "Command failed after $max attempts."
return 1
fi
}
done
}
# never prompt: an upgrade (e.g. libssl asking to restart services) would wait forever
export DEBIAN_FRONTEND=noninteractive
packages=(bash git curl ca-certificates wget)
install_options=(-o Dpkg::Options::=--force-confdef -o Dpkg::Options::=--force-confold install --yes)
retry apt-get update < /dev/null || true
if ! retry apt-get "${install_options[@]}" "${packages[@]}" < /dev/null; then
# a security index can outlive the pool objects it advertises, which
# no retry resolves; main is complete once a release is archived
sed -i '/debian-security/d' /etc/apt/sources.list
retry apt-get update < /dev/null || true
retry apt-get "${install_options[@]}" "${packages[@]}" < /dev/null
fi
- name: Retrieve nvm on WSL
timeout-minutes: 5
run: |
if [ -z "${{ matrix.method }}" ]; then
curl -fsSLo- "https://raw.githubusercontent.com/${NVM_INSTALL_GITHUB_REPO}/${NVM_INSTALL_VERSION}/install.sh" | bash
else
curl -fsSLo- "https://raw.githubusercontent.com/${NVM_INSTALL_GITHUB_REPO}/${NVM_INSTALL_VERSION}/install.sh" | METHOD="${{matrix.method}}" bash
fi
. "$HOME/.nvm/nvm.sh"
nvm install ${{ matrix.npm-node-version }}
node -v
wsl_matrix_unofficial:
permissions:
contents: none
continue-on-error: true
name: 'WSL nvm install'
defaults:
run:
shell: wsl-bash {0}
runs-on: windows-latest
# see wsl_matrix
timeout-minutes: 10
env:
WSLENV: NVM_INSTALL_GITHUB_REPO:NVM_INSTALL_VERSION:/p
NVM_NODEJS_ORG_MIRROR: https://unofficial-builds.nodejs.org/download/release
strategy:
fail-fast: false
matrix:
wsl-distrib:
- Alpine-3.17
- Alpine-3.23
npm-node-version:
- '--lts'
- '21'
- '18'
- '16'
- '14'
- '12'
- '11'
- '10'
method:
- ''
- 'script'
steps:
- uses: Vampire/setup-wsl@v7
timeout-minutes: 3
with:
distribution: ${{ matrix.wsl-distrib }}
additional-packages: bash git curl ca-certificates wget
- name: Retrieve nvm on WSL
timeout-minutes: 5
run: |
if [ -z "${{ matrix.method }}" ]; then
curl -fsSLo- "https://raw.githubusercontent.com/${NVM_INSTALL_GITHUB_REPO}/${NVM_INSTALL_VERSION}/install.sh" | bash
else
curl -fsSLo- "https://raw.githubusercontent.com/${NVM_INSTALL_GITHUB_REPO}/${NVM_INSTALL_VERSION}/install.sh" | METHOD="${{matrix.method}}" bash
fi
. "$HOME/.nvm/nvm.sh"
NVM_NODEJS_ORG_MIRROR=${{ env.NVM_NODEJS_ORG_MIRROR }} nvm install ${{ matrix.npm-node-version }}
nvm_windows:
name: 'tests, on windows'
permissions:
contents: none
needs: [wsl_matrix, wsl_matrix_unofficial, cygwin_matrix, msys_matrix, msys_fail_install]
runs-on: ubuntu-latest
steps:
- run: true