Skip to content

Commit 4aae728

Browse files
committed
test: add WSL testing workflow for Windows
1 parent 0457bfe commit 4aae728

File tree

1 file changed

+146
-0
lines changed

1 file changed

+146
-0
lines changed

.github/workflows/test-windows.yml

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
name: Test Windows
2+
3+
on:
4+
pull_request:
5+
paths-ignore:
6+
- .mailmap
7+
- README.md
8+
- vcbuild.bat
9+
- test/internet/**
10+
- '**.nix'
11+
- .github/**
12+
- '!.github/workflows/test-windows.yml'
13+
types: [opened, synchronize, reopened, ready_for_review]
14+
push:
15+
branches:
16+
- main
17+
- canary
18+
- v[0-9]+.x-staging
19+
- v[0-9]+.x
20+
paths-ignore:
21+
- .mailmap
22+
- README.md
23+
- vcbuild.bat
24+
- test/internet/**
25+
- '**.nix'
26+
- .github/**
27+
- '!.github/workflows/test-windows.yml'
28+
29+
concurrency:
30+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
31+
cancel-in-progress: true
32+
33+
env:
34+
PYTHON_VERSION: '3.14'
35+
FLAKY_TESTS: keep_retrying
36+
CLANG_VERSION: '19'
37+
RUSTC_VERSION: '1.82'
38+
39+
permissions:
40+
contents: read
41+
42+
jobs:
43+
test-wsl:
44+
if: github.event.pull_request.draft == false
45+
strategy:
46+
fail-fast: false
47+
runs-on: windows-latest
48+
steps:
49+
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3
50+
with:
51+
persist-credentials: false
52+
path: node
53+
54+
- name: Download Ubuntu rootfs tarball
55+
shell: powershell
56+
run: |
57+
Write-Host "=== Downloading Ubuntu rootfs tarball ==="
58+
$url = "https://cloud-images.ubuntu.com/wsl/jammy/current/ubuntu-jammy-wsl-amd64-ubuntu22.04lts.rootfs.tar.gz"
59+
$output = "$env:TEMP\ubuntu-22.04.tar.gz"
60+
Invoke-WebRequest -Uri $url -OutFile $output
61+
Write-Host "Download complete: $output"
62+
63+
- name: Import WSL Distribution
64+
shell: powershell
65+
run: |
66+
Write-Host "=== Importing distribution to WSL ==="
67+
$tarFile = "$env:TEMP\ubuntu-22.04.tar.gz"
68+
$installDir = "$env:LOCALAPPDATA\WSL\Ubuntu-22.04"
69+
$distroName = "Ubuntu-22.04"
70+
New-Item -ItemType Directory -Force -Path $installDir | Out-Null
71+
wsl --import $distroName $installDir $tarFile --version 2
72+
Start-Sleep -Seconds 10
73+
Write-Host "`n=== Installation check ==="
74+
wsl --list --verbose
75+
Add-Content -Path $env:GITHUB_ENV -Value "DISTRO_NAME=$distroName"
76+
77+
- name: Initial Setup in WSL
78+
shell: powershell
79+
run: |
80+
$distroName = $env:DISTRO_NAME
81+
wsl -d $distroName -u root bash -c "export DEBIAN_FRONTEND=noninteractive && apt update && apt install -y python3 python3-pip git curl sudo build-essential"
82+
wsl -d $distroName -u root bash -c "apt install -y clang-${{ env.CLANG_VERSION }}"
83+
wsl -d $distroName -u root bash -c "update-alternatives --install /usr/bin/clang clang /usr/bin/clang-${{ env.CLANG_VERSION }} 100"
84+
wsl -d $distroName -u root bash -c "update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-${{ env.CLANG_VERSION }} 100"
85+
wsl -d $distroName -u root bash -c "clang --version"
86+
wsl -d $distroName -u root bash -c "curl --proto =https --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain ${{ env.RUSTC_VERSION }}"
87+
wsl -d $distroName -u root bash -c "export PATH=\`$HOME/.cargo/bin:\`$PATH && rustup override set ${{ env.RUSTC_VERSION }}"
88+
wsl -d $distroName -u root bash -c "export PATH=\`$HOME/.cargo/bin:\`$PATH && rustup --version"
89+
wsl -d $distroName -u root bash -c "curl -sL https://github.com/mozilla/sccache/releases/download/v0.3.0/sccache-v0.3.0-x86_64-unknown-linux-gnu.tar.gz | tar xz"
90+
wsl -d $distroName -u root bash -c "mkdir -p ~/.cargo/bin && mv sccache-v0.3.0-x86_64-unknown-linux-gnu/sccache ~/.cargo/bin/"
91+
wsl -d $distroName -u root bash -c "echo 'export PATH=\`"`$HOME/.cargo/bin:\`$PATH\`"' >> \`$HOME/.bashrc"
92+
wsl -d $distroName -u root bash -c "echo 'export CC=\`"sccache clang\`"' >> \`$HOME/.bashrc"
93+
wsl -d $distroName -u root bash -c "echo 'export CXX=\`"sccache clang++\`"' >> \`$HOME/.bashrc"
94+
wsl -d $distroName -u root bash -c "echo 'export SCCACHE_GHA_ENABLED=\`"true\`"' >> \`$HOME/.bashrc"
95+
wsl -d $distroName -u root bash -c "export PATH=\`$HOME/.cargo/bin:\`$PATH && rustc --version"
96+
wsl -d $distroName -u root bash -c "export PATH=\`$HOME/.cargo/bin:\`$PATH && sccache --version"
97+
98+
- name: Environment Information
99+
shell: powershell
100+
run: |
101+
$distroName = $env:DISTRO_NAME
102+
$wslCheckoutRoot = ($env:GITHUB_WORKSPACE -replace '\\', '/').ToLower() -replace '^([a-z]):', '/mnt/$1'
103+
$wslNodePath = "$wslCheckoutRoot/node"
104+
wsl -d $distroName bash -c "source ~/.bashrc && cd '$wslNodePath' && npx envinfo"
105+
106+
- name: tools/doc/node_modules workaround
107+
shell: powershell
108+
run: |
109+
$distroName = $env:DISTRO_NAME
110+
$wslCheckoutRoot = ($env:GITHUB_WORKSPACE -replace '\\', '/').ToLower() -replace '^([a-z]):', '/mnt/$1'
111+
$wslNodePath = "$wslCheckoutRoot/node"
112+
wsl -d $distroName bash -c "source ~/.bashrc && cd '$wslNodePath' && make tools/doc/node_modules"
113+
114+
- name: Build Node.js in WSL
115+
shell: powershell
116+
run: |
117+
$distroName = $env:DISTRO_NAME
118+
$wslCheckoutRoot = ($env:GITHUB_WORKSPACE -replace '\\', '/').ToLower() -replace '^([a-z]):', '/mnt/$1'
119+
$wslNodePath = "$wslCheckoutRoot/node"
120+
wsl -d $distroName bash -c "source ~/.bashrc && cd '$wslNodePath' && make build-ci -j`$(nproc) V=1 CONFIG_FLAGS='--error-on-warn --v8-enable-temporal-support'"
121+
122+
- name: Test Node.js in WSL
123+
shell: powershell
124+
run: |
125+
$distroName = $env:DISTRO_NAME
126+
$wslCheckoutRoot = ($env:GITHUB_WORKSPACE -replace '\\', '/').ToLower() -replace '^([a-z]):', '/mnt/$1'
127+
$wslNodePath = "$wslCheckoutRoot/node"
128+
wsl -d $distroName bash -c "source ~/.bashrc && cd '$wslNodePath' && make test-ci -j1 V=1 TEST_CI_ARGS='-p actions --measure-flakiness 9'"
129+
130+
- name: Re-run test in a folder whose name contains unusual chars
131+
shell: powershell
132+
run: |
133+
$distroName = $env:DISTRO_NAME
134+
$wslCheckoutRoot = ($env:GITHUB_WORKSPACE -replace '\\', '/').ToLower() -replace '^([a-z]):', '/mnt/$1'
135+
$unusualDirName = 'dir%20with $unusual"chars?''åß∂ƒ©∆¬…'
136+
wsl -d $distroName bash -c "cd '$wslCheckoutRoot' && mv node '$unusualDirName' && cd '$unusualDirName' && ./tools/test.py --flaky-tests keep_retrying -p actions -j 4"
137+
138+
- name: Cleanup
139+
if: always()
140+
shell: powershell
141+
run: |
142+
$distroName = $env:DISTRO_NAME
143+
if ($distroName) {
144+
Write-Host "Unregistering distro: $distroName"
145+
wsl --unregister $distroName
146+
}

0 commit comments

Comments
 (0)