Skip to content

Commit 6c652b9

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

File tree

1 file changed

+193
-0
lines changed

1 file changed

+193
-0
lines changed

.github/workflows/test-windows.yml

Lines changed: 193 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
name: Test Windows
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened, ready_for_review]
6+
paths-ignore:
7+
- '**.md'
8+
- '**.nix'
9+
- eslint.config.mjs
10+
- '**/eslint.config_partial.mjs'
11+
- android-configure
12+
- android-configure.py
13+
- android-patches/**
14+
- benchmarks/**
15+
- codecov.yml
16+
- doc/**
17+
- pyproject.yml
18+
- tsconfig.json
19+
- test/internet/**
20+
- tools/**
21+
- .**
22+
- '!.github/workflows/test-windows.yml'
23+
push:
24+
branches:
25+
- main
26+
- canary
27+
- v[0-9]+.x-staging
28+
- v[0-9]+.x
29+
paths-ignore:
30+
- '**.md'
31+
- '**.nix'
32+
- eslint.config.mjs
33+
- '**/eslint.config_partial.mjs'
34+
- android-configure
35+
- android-configure.py
36+
- android-patches/**
37+
- benchmarks/**
38+
- codecov.yml
39+
- doc/**
40+
- pyproject.yml
41+
- tsconfig.json
42+
- test/internet/**
43+
- tools/**
44+
- .**
45+
- '!.github/workflows/test-windows.yml'
46+
47+
concurrency:
48+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
49+
cancel-in-progress: true
50+
51+
env:
52+
PYTHON_VERSION: '3.14'
53+
FLAKY_TESTS: keep_retrying
54+
CLANG_VERSION: '19'
55+
RUSTC_VERSION: '1.85'
56+
57+
permissions:
58+
contents: read
59+
60+
jobs:
61+
test-wsl:
62+
if: github.event.pull_request.draft == false
63+
runs-on: windows-latest
64+
env:
65+
DISTRO_NAME: Ubuntu-22.04
66+
CC: sccache clang
67+
CXX: sccache clang++
68+
SCCACHE_GHA_ENABLED: 'true'
69+
70+
steps:
71+
- name: Checkout code
72+
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
73+
with:
74+
persist-credentials: false
75+
path: node
76+
77+
- name: Download Ubuntu rootfs tarball
78+
shell: powershell
79+
run: |
80+
$url = "https://cloud-images.ubuntu.com/wsl/jammy/current/ubuntu-jammy-wsl-amd64-ubuntu22.04lts.rootfs.tar.gz"
81+
$output = "$env:TEMP\ubuntu-22.04.tar.gz"
82+
Write-Host "Downloading Ubuntu rootfs from $url to $output"
83+
Invoke-WebRequest -Uri $url -OutFile $output -UseBasicParsing
84+
Write-Host "Download complete. File size: $((Get-Item $output).Length) bytes"
85+
86+
- name: Import WSL Distribution
87+
shell: powershell
88+
run: |
89+
$distroName = "$env:DISTRO_NAME"
90+
$tarFile = "$env:TEMP\ubuntu-22.04.tar.gz"
91+
$installLocation = "$env:LOCALAPPDATA\WSL\$distroName"
92+
93+
Write-Host "Importing WSL distribution: $distroName"
94+
wsl --import $distroName $installLocation $tarFile --version 2
95+
96+
Write-Host "Verifying installation..."
97+
wsl --list --verbose
98+
99+
- name: Initial Setup in WSL
100+
shell: powershell
101+
run: |
102+
$distroName = "$env:DISTRO_NAME"
103+
104+
Write-Host "Installing basic packages..."
105+
wsl -d $distroName -u root bash -c "apt update && DEBIAN_FRONTEND=noninteractive apt install -y python3 python3-pip git curl sudo build-essential ca-certificates wget gnupg software-properties-common lsb-release"
106+
107+
Write-Host "Installing Clang ${{ env.CLANG_VERSION }}..."
108+
wsl -d $distroName -u root bash -c "wget -O /tmp/llvm.sh https://apt.llvm.org/llvm.sh && chmod +x /tmp/llvm.sh && /tmp/llvm.sh ${{ env.CLANG_VERSION }} && update-alternatives --install /usr/bin/clang clang /usr/bin/clang-${{ env.CLANG_VERSION }} 100 && update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-${{ env.CLANG_VERSION }} 100"
109+
110+
Write-Host "Installing Rust ${{ env.RUSTC_VERSION }}..."
111+
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 }} && echo 'export PATH=/root/.cargo/bin:`$PATH' >> /root/.bashrc"
112+
113+
Write-Host "Installing sccache v0.12.0..."
114+
wsl -d $distroName -u root bash -c "curl -L https://github.com/mozilla/sccache/releases/download/v0.12.0/sccache-v0.12.0-x86_64-unknown-linux-musl.tar.gz -o /tmp/sccache.tar.gz && tar -xzf /tmp/sccache.tar.gz -C /tmp && mv /tmp/sccache-v0.12.0-x86_64-unknown-linux-musl/sccache /usr/local/bin/ && chmod +x /usr/local/bin/sccache"
115+
116+
Write-Host "Setting environment variables..."
117+
wsl -d $distroName -u root bash -c "echo 'export CC=\"sccache clang\"' >> /root/.bashrc && echo 'export CXX=\"sccache clang++\"' >> /root/.bashrc && echo 'export SCCACHE_GHA_ENABLED=true' >> /root/.bashrc"
118+
119+
Write-Host "Verifying tools..."
120+
wsl -d $distroName bash -c "source /root/.bashrc && clang --version && rustc --version && sccache --version"
121+
122+
- name: Set up Python ${{ env.PYTHON_VERSION }}
123+
uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0
124+
with:
125+
python-version: ${{ env.PYTHON_VERSION }}
126+
allow-prereleases: true
127+
128+
- name: Set up sccache (for GitHub Actions cache)
129+
uses: Mozilla-Actions/sccache-action@7d986dd989559c6ecdb630a3fd2557667be217ad # v0.0.9
130+
with:
131+
version: v0.12.0
132+
133+
- name: Environment Information
134+
shell: powershell
135+
run: |
136+
$distroName = "$env:DISTRO_NAME"
137+
$checkoutRoot = "${{ github.workspace }}".Replace('\', '/')
138+
$wslCheckoutRoot = "/mnt/" + $checkoutRoot.Substring(0,1).ToLower() + $checkoutRoot.Substring(2).Replace(':', '')
139+
140+
Write-Host "Running envinfo in WSL..."
141+
wsl -d $distroName bash -c "source /root/.bashrc && cd '$wslCheckoutRoot/node' && npx envinfo"
142+
143+
- name: tools/doc/node_modules workaround
144+
shell: powershell
145+
run: |
146+
$distroName = "$env:DISTRO_NAME"
147+
$checkoutRoot = "${{ github.workspace }}".Replace('\', '/')
148+
$wslCheckoutRoot = "/mnt/" + $checkoutRoot.Substring(0,1).ToLower() + $checkoutRoot.Substring(2).Replace(':', '')
149+
150+
Write-Host "Building tools/doc/node_modules..."
151+
wsl -d $distroName bash -c "source /root/.bashrc && cd '$wslCheckoutRoot/node' && make tools/doc/node_modules"
152+
153+
- name: Build Node.js in WSL
154+
shell: powershell
155+
run: |
156+
$distroName = "$env:DISTRO_NAME"
157+
$checkoutRoot = "${{ github.workspace }}".Replace('\', '/')
158+
$wslCheckoutRoot = "/mnt/" + $checkoutRoot.Substring(0,1).ToLower() + $checkoutRoot.Substring(2).Replace(':', '')
159+
160+
$nproc = wsl -d $distroName bash -c "nproc"
161+
Write-Host "Building Node.js with $nproc cores..."
162+
wsl -d $distroName bash -c "source /root/.bashrc && cd '$wslCheckoutRoot/node' && make build-ci -j$nproc V=1 CONFIG_FLAGS='--error-on-warn'"
163+
164+
- name: Test Node.js in WSL
165+
shell: powershell
166+
run: |
167+
$distroName = "$env:DISTRO_NAME"
168+
$checkoutRoot = "${{ github.workspace }}".Replace('\', '/')
169+
$wslCheckoutRoot = "/mnt/" + $checkoutRoot.Substring(0,1).ToLower() + $checkoutRoot.Substring(2).Replace(':', '')
170+
171+
Write-Host "Running tests..."
172+
wsl -d $distroName bash -c "source /root/.bashrc && cd '$wslCheckoutRoot/node' && make test-ci -j1 V=1 TEST_CI_ARGS='-p actions --measure-flakiness 9'"
173+
174+
- name: Re-run test in a folder whose name contains unusual chars
175+
shell: powershell
176+
run: |
177+
$distroName = "$env:DISTRO_NAME"
178+
$checkoutRoot = "${{ github.workspace }}".Replace('\', '/')
179+
$wslCheckoutRoot = "/mnt/" + $checkoutRoot.Substring(0,1).ToLower() + $checkoutRoot.Substring(2).Replace(':', '')
180+
$unusualDir = "dir%20with `$unusual`"chars?'åß∂ƒ©∆¬…"
181+
182+
Write-Host "Re-running tests in unusual directory..."
183+
wsl -d $distroName bash -c "source /root/.bashrc && cd '$wslCheckoutRoot' && mv node '$unusualDir' && cd '$unusualDir' && ./tools/test.py --flaky-tests keep_retrying -p actions -j 4"
184+
185+
- name: Cleanup
186+
if: always()
187+
shell: powershell
188+
run: |
189+
$distroName = "$env:DISTRO_NAME"
190+
if ($distroName) {
191+
Write-Host "Unregistering WSL distribution: $distroName"
192+
wsl --unregister $distroName
193+
}

0 commit comments

Comments
 (0)