Skip to content

Commit 838c0e9

Browse files
committed
ci: Add WSL testing workflow for Windows
This commit introduces a new GitHub Actions workflow for running Node.js builds and tests within a Windows Subsystem for Linux (WSL) environment. The primary goal is to expand our continuous integration coverage to ensure Node.js functions correctly in WSL, which is a common development and deployment scenario. The workflow leverages the `windows-latest` runner and executes commands within an Ubuntu-22.04 WSL instance. The structure and styling of this new workflow closely follow the conventions established in `test-macos.yml` to maintain consistency and improve overall maintainability across our CI configurations.
1 parent 0457bfe commit 838c0e9

File tree

1 file changed

+142
-0
lines changed

1 file changed

+142
-0
lines changed

.github/workflows/test-windows.yml

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
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: Install WSL Distribution (Ubuntu-22.04)
55+
shell: powershell
56+
run: |
57+
wsl --install Ubuntu-22.04 --no-launch
58+
$sleepTime = 5
59+
$maxAttempts = 12
60+
$attempt = 0
61+
while ($attempt -lt $maxAttempts) {
62+
$attempt++
63+
Write-Host "Waiting for Ubuntu-22.04 to be installed (Attempt $attempt/$maxAttempts)..."
64+
Start-Sleep -Seconds $sleepTime
65+
$distros = wsl -l -q
66+
if ($distros -match "Ubuntu-22.04") {
67+
Write-Host "Ubuntu-22.04 is installed."
68+
break
69+
}
70+
if ($attempt -eq $maxAttempts) {
71+
Write-Error "Ubuntu-22.04 did not install within the expected time."
72+
exit 1
73+
}
74+
}
75+
# Ensure the distro is fully initialized by running a dummy command
76+
wsl -d Ubuntu-22.04 echo "WSL distribution ready."
77+
78+
- name: Set up Python ${{ env.PYTHON_VERSION }} in WSL
79+
shell: powershell
80+
run: |
81+
wsl -d Ubuntu-22.04 bash -c "sudo apt-get update && sudo apt-get install -y python3 python3-pip"
82+
wsl -d Ubuntu-22.04 bash -c "python3 --version"
83+
84+
- name: Install Clang ${{ env.CLANG_VERSION }} in WSL
85+
shell: powershell
86+
run: |
87+
wsl -d Ubuntu-22.04 bash -c "sudo apt-get update && sudo apt-get install -y clang-${{ env.CLANG_VERSION }}"
88+
wsl -d Ubuntu-22.04 bash -c "sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-${{ env.CLANG_VERSION }} 100"
89+
wsl -d Ubuntu-22.04 bash -c "sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-${{ env.CLANG_VERSION }} 100"
90+
wsl -d Ubuntu-22.04 bash -c "clang --version"
91+
92+
- name: Install Rust ${{ env.RUSTC_VERSION }} in WSL
93+
shell: powershell
94+
run: |
95+
wsl -d Ubuntu-22.04 bash -c "curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain ${{ env.RUSTC_VERSION }}"
96+
wsl -d Ubuntu-22.04 bash -c "echo 'export PATH=\"$HOME/.cargo/bin:\$PATH\"' >> \$HOME/.bashrc"
97+
wsl -d Ubuntu-22.04 bash -c "source \$HOME/.bashrc && rustup override set ${{ env.RUSTC_VERSION }}"
98+
wsl -d Ubuntu-22.04 bash -c "source \$HOME/.bashrc && rustup --version"
99+
100+
- name: Set up sccache in WSL
101+
shell: powershell
102+
run: |
103+
$wslRepoPath = "/mnt/c/Users/runneradmin/work/${env:GITHUB_REPOSITORY//\/\_}/node"
104+
wsl -d Ubuntu-22.04 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 -C $wslRepoPath"
105+
wsl -d Ubuntu-22.04 bash -c "mv $wslRepoPath/sccache-v0.3.0-x86_64-unknown-linux-gnu/sccache $wslRepoPath/.cargo/bin/"
106+
wsl -d Ubuntu-22.04 bash -c "echo 'CC=$wslRepoPath/.cargo/bin/sccache clang' >> $HOME/.bashrc"
107+
wsl -d Ubuntu-22.04 bash -c "echo 'CXX=$wslRepoPath/.cargo/bin/sccache clang++' >> $HOME/.bashrc"
108+
wsl -d Ubuntu-22.04 bash -c "echo 'SCCACHE_GHA_ENABLED=true' >> $HOME/.bashrc"
109+
110+
- name: Environment Information
111+
shell: powershell
112+
run: |
113+
$wslRepoPath = "/mnt/c/Users/runneradmin/work/${env:GITHUB_REPOSITORY//\/\_}/node"
114+
wsl -d Ubuntu-22.04 bash -c "cd $wslRepoPath && npx envinfo"
115+
116+
- name: tools/doc/node_modules workaround
117+
shell: powershell
118+
run: |
119+
$wslRepoPath = "/mnt/c/Users/runneradmin/work/${env:GITHUB_REPOSITORY//\/\_}/node"
120+
wsl -d Ubuntu-22.04 bash -c "cd $wslRepoPath && make tools/doc/node_modules"
121+
122+
- name: Build Node.js in WSL
123+
shell: powershell
124+
run: |
125+
$wslRepoPath = "/mnt/c/Users/runneradmin/work/${env:GITHUB_REPOSITORY//\/\_}/node"
126+
wsl -d Ubuntu-22.04 bash -c "cd $wslRepoPath && make build-ci -j$(nproc) V=1 CONFIG_FLAGS=\"--error-on-warn --v8-enable-temporal-support\""
127+
128+
- name: Test Node.js in WSL
129+
shell: powershell
130+
run: |
131+
$repoPath = "node"
132+
$wslRepoPath = "/mnt/c/Users/runneradmin/work/${env:GITHUB_REPOSITORY//\/\_}/$repoPath"
133+
wsl -d Ubuntu-22.04 bash -c "cd $wslRepoPath && make test-ci -j1 V=1 TEST_CI_ARGS=\"-p actions --measure-flakiness 9\""
134+
135+
- name: Re-run test in a folder whose name contains unusual chars
136+
shell: powershell
137+
run: |
138+
$repoPath = "node"
139+
$wslRepoPath = "/mnt/c/Users/runneradmin/work/${env:GITHUB_REPOSITORY//\/\_}/$repoPath"
140+
$dir = "dir%20with \$unusual`"chars?'åß∂ƒ©∆¬…`"
141+
wsl -d Ubuntu-22.04 bash -c "cd $wslRepoPath && mv node \"$dir\""
142+
wsl -d Ubuntu-22.04 bash -c "cd \"$wslRepoPath/$dir\" && ./tools/test.py --flaky-tests keep_retrying -p actions -j 4"

0 commit comments

Comments
 (0)