Skip to content

Commit 9eec6cb

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

File tree

1 file changed

+145
-0
lines changed

1 file changed

+145
-0
lines changed

.github/workflows/test-windows.yml

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
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.85'
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 wget gnupg software-properties-common lsb-release"
82+
wsl -d $distroName -u root bash -c "wget https://apt.llvm.org/llvm.sh && chmod +x llvm.sh && ./llvm.sh ${{ 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 "export PATH=\`$HOME/.cargo/bin:\`$PATH && cargo install sccache --locked"
90+
wsl -d $distroName -u root bash -c "echo 'export PATH=\`"`$HOME/.cargo/bin:\`$PATH\`"' >> \`$HOME/.bashrc"
91+
wsl -d $distroName -u root bash -c "echo 'export CC=\`"sccache clang\`"' >> \`$HOME/.bashrc"
92+
wsl -d $distroName -u root bash -c "echo 'export CXX=\`"sccache clang++\`"' >> \`$HOME/.bashrc"
93+
wsl -d $distroName -u root bash -c "echo 'export SCCACHE_GHA_ENABLED=\`"true\`"' >> \`$HOME/.bashrc"
94+
wsl -d $distroName -u root bash -c "export PATH=\`$HOME/.cargo/bin:\`$PATH && rustc --version"
95+
wsl -d $distroName -u root bash -c "export PATH=\`$HOME/.cargo/bin:\`$PATH && sccache --version"
96+
97+
- name: Environment Information
98+
shell: powershell
99+
run: |
100+
$distroName = $env:DISTRO_NAME
101+
$wslCheckoutRoot = ($env:GITHUB_WORKSPACE -replace '\\', '/').ToLower() -replace '^([a-z]):', '/mnt/$1'
102+
$wslNodePath = "$wslCheckoutRoot/node"
103+
wsl -d $distroName bash -c "source ~/.bashrc && cd '$wslNodePath' && npx envinfo"
104+
105+
- name: tools/doc/node_modules workaround
106+
shell: powershell
107+
run: |
108+
$distroName = $env:DISTRO_NAME
109+
$wslCheckoutRoot = ($env:GITHUB_WORKSPACE -replace '\\', '/').ToLower() -replace '^([a-z]):', '/mnt/$1'
110+
$wslNodePath = "$wslCheckoutRoot/node"
111+
wsl -d $distroName bash -c "source ~/.bashrc && cd '$wslNodePath' && make tools/doc/node_modules"
112+
113+
- name: Build Node.js in WSL
114+
shell: powershell
115+
run: |
116+
$distroName = $env:DISTRO_NAME
117+
$wslCheckoutRoot = ($env:GITHUB_WORKSPACE -replace '\\', '/').ToLower() -replace '^([a-z]):', '/mnt/$1'
118+
$wslNodePath = "$wslCheckoutRoot/node"
119+
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'"
120+
121+
- name: Test Node.js in WSL
122+
shell: powershell
123+
run: |
124+
$distroName = $env:DISTRO_NAME
125+
$wslCheckoutRoot = ($env:GITHUB_WORKSPACE -replace '\\', '/').ToLower() -replace '^([a-z]):', '/mnt/$1'
126+
$wslNodePath = "$wslCheckoutRoot/node"
127+
wsl -d $distroName bash -c "source ~/.bashrc && cd '$wslNodePath' && make test-ci -j1 V=1 TEST_CI_ARGS='-p actions --measure-flakiness 9'"
128+
129+
- name: Re-run test in a folder whose name contains unusual chars
130+
shell: powershell
131+
run: |
132+
$distroName = $env:DISTRO_NAME
133+
$wslCheckoutRoot = ($env:GITHUB_WORKSPACE -replace '\\', '/').ToLower() -replace '^([a-z]):', '/mnt/$1'
134+
$unusualDirName = 'dir%20with $unusual"chars?''åß∂ƒ©∆¬…'
135+
wsl -d $distroName bash -c "cd '$wslCheckoutRoot' && mv node '$unusualDirName' && cd '$unusualDirName' && ./tools/test.py --flaky-tests keep_retrying -p actions -j 4"
136+
137+
- name: Cleanup
138+
if: always()
139+
shell: powershell
140+
run: |
141+
$distroName = $env:DISTRO_NAME
142+
if ($distroName) {
143+
Write-Host "Unregistering distro: $distroName"
144+
wsl --unregister $distroName
145+
}

0 commit comments

Comments
 (0)