mirror of
https://github.com/nvm-sh/nvm.git
synced 2026-02-04 08:52:48 +08:00
[actions] fix WSL tests: properly handle Debian apt sources issue
The Debian WSL image has stale apt sources pointing to ftp.debian.org which no longer hosts bullseye-backports. The previous fix ran sed after the first setup-wsl call, but that call already failed because additional-packages triggers apt-get update internally. For wsl_matrix (Debian, Ubuntu): - Ubuntu: install with additional-packages directly (no apt issue) - Debian: install without packages first, fix sources.list with sed, then run apt-get update/upgrade/install manually with retries - Exclude Debian and Ubuntu-20.04 --lts since node v24+ has exec format errors on WSL1 For wsl_matrix_unofficial (Alpine): - Remove the Debian-specific fix entirely (Alpine uses apk, not apt) See https://github.com/Vampire/setup-wsl/issues/76
This commit is contained in:
55
.github/workflows/windows-npm.yml
vendored
55
.github/workflows/windows-npm.yml
vendored
@@ -125,23 +125,55 @@ jobs:
|
|||||||
npm-node-version: '21'
|
npm-node-version: '21'
|
||||||
- wsl-distrib: Ubuntu-18.04
|
- wsl-distrib: Ubuntu-18.04
|
||||||
npm-node-version: '18'
|
npm-node-version: '18'
|
||||||
|
# node v24+ doesn't work on WSL1 (exec format error)
|
||||||
|
- wsl-distrib: Debian
|
||||||
|
npm-node-version: '--lts'
|
||||||
|
- wsl-distrib: Ubuntu-20.04
|
||||||
|
npm-node-version: '--lts'
|
||||||
method:
|
method:
|
||||||
- ''
|
- ''
|
||||||
- 'script'
|
- 'script'
|
||||||
steps:
|
steps:
|
||||||
- uses: Vampire/setup-wsl@v3
|
# For Ubuntu: install with packages directly
|
||||||
|
- if: matrix.wsl-distrib != 'Debian'
|
||||||
|
uses: Vampire/setup-wsl@v3
|
||||||
with:
|
with:
|
||||||
distribution: ${{ matrix.wsl-distrib }}
|
distribution: ${{ matrix.wsl-distrib }}
|
||||||
additional-packages: bash git curl ca-certificates wget
|
additional-packages: bash git curl ca-certificates wget
|
||||||
|
|
||||||
# see https://github.com/Vampire/setup-wsl/issues/76#issuecomment-3258201135
|
# For Debian: install without packages first (apt-get update fails due to stale sources.list)
|
||||||
- shell: 'wsl-bash {0}'
|
# see https://github.com/Vampire/setup-wsl/issues/76
|
||||||
run: 'sed -i s/ftp.debian.org/archive.debian.org/ /etc/apt/sources.list'
|
- if: matrix.wsl-distrib == 'Debian'
|
||||||
- uses: Vampire/setup-wsl@v3
|
uses: Vampire/setup-wsl@v3
|
||||||
with:
|
with:
|
||||||
distribution: ${{ matrix.wsl-distrib }}
|
distribution: ${{ matrix.wsl-distrib }}
|
||||||
additional-packages: bash git curl ca-certificates wget
|
- if: matrix.wsl-distrib == 'Debian'
|
||||||
update: 'true'
|
shell: 'wsl-bash {0}'
|
||||||
|
run: 'sed -i s/ftp.debian.org/archive.debian.org/ /etc/apt/sources.list'
|
||||||
|
- if: matrix.wsl-distrib == 'Debian'
|
||||||
|
name: 'Install packages with retries'
|
||||||
|
shell: 'wsl-bash {0}'
|
||||||
|
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
|
||||||
|
}
|
||||||
|
retry apt-get update
|
||||||
|
retry apt-get upgrade --yes
|
||||||
|
retry apt-get install --yes bash git curl ca-certificates wget
|
||||||
|
|
||||||
- name: Retrieve nvm on WSL
|
- name: Retrieve nvm on WSL
|
||||||
run: |
|
run: |
|
||||||
@@ -187,15 +219,6 @@ jobs:
|
|||||||
distribution: ${{ matrix.wsl-distrib }}
|
distribution: ${{ matrix.wsl-distrib }}
|
||||||
additional-packages: bash git curl ca-certificates wget
|
additional-packages: bash git curl ca-certificates wget
|
||||||
|
|
||||||
# see https://github.com/Vampire/setup-wsl/issues/76#issuecomment-3258201135
|
|
||||||
- shell: 'wsl-bash {0}'
|
|
||||||
run: 'sed -i s/ftp.debian.org/archive.debian.org/ /etc/apt/sources.list'
|
|
||||||
- uses: Vampire/setup-wsl@v3
|
|
||||||
with:
|
|
||||||
distribution: ${{ matrix.wsl-distrib }}
|
|
||||||
additional-packages: bash git curl ca-certificates wget
|
|
||||||
update: 'true'
|
|
||||||
|
|
||||||
- name: Retrieve nvm on WSL
|
- name: Retrieve nvm on WSL
|
||||||
run: |
|
run: |
|
||||||
if [ -z "${{ matrix.method }}" ]; then
|
if [ -z "${{ matrix.method }}" ]; then
|
||||||
|
|||||||
Reference in New Issue
Block a user