Skip to content

Commit c0d1b8f

Browse files
committed
ci: add WSL testing workflow for Windows
1 parent 0457bfe commit c0d1b8f

File tree

1 file changed

+144
-0
lines changed

1 file changed

+144
-0
lines changed

.github/workflows/test-windows.yml

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
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+
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"
104+
wsl -d Ubuntu-22.04 bash -c "mkdir -p ~/.cargo/bin"
105+
wsl -d Ubuntu-22.04 bash -c "mv sccache-v0.3.0-x86_64-unknown-linux-gnu/sccache ~/.cargo/bin/"
106+
wsl -d Ubuntu-22.04 bash -c "echo 'export PATH=\"$HOME/.cargo/bin:\$PATH\"' >> \$HOME/.bashrc"
107+
wsl -d Ubuntu-22.04 bash -c "echo 'export CC=\"sccache clang\"' >> \$HOME/.bashrc"
108+
wsl -d Ubuntu-22.04 bash -c "echo 'export CXX=\"sccache clang++\"' >> \$HOME/.bashrc"
109+
wsl -d Ubuntu-22.04 bash -c "echo 'export SCCACHE_GHA_ENABLED=\"true\"' >> \$HOME/.bashrc"
110+
111+
- name: Environment Information
112+
shell: powershell
113+
run: |
114+
$wslCheckoutRoot = "/mnt/c/Users/runneradmin/work/${env:GITHUB_REPOSITORY//\/\_}"
115+
wsl -d Ubuntu-22.04 bash -c "cd $wslCheckoutRoot && npx envinfo"
116+
117+
- name: tools/doc/node_modules workaround
118+
shell: powershell
119+
run: |
120+
$wslCheckoutRoot = "/mnt/c/Users/runneradmin/work/${env:GITHUB_REPOSITORY//\/\_}"
121+
wsl -d Ubuntu-22.04 bash -c "cd $wslCheckoutRoot && make -C node tools/doc/node_modules"
122+
123+
- name: Build Node.js in WSL
124+
shell: powershell
125+
run: |
126+
$wslCheckoutRoot = "/mnt/c/Users/runneradmin/work/${env:GITHUB_REPOSITORY//\/\_}"
127+
wsl -d Ubuntu-22.04 bash -c "cd $wslCheckoutRoot && make -C node build-ci -j$(nproc) V=1 CONFIG_FLAGS=\"--error-on-warn --v8-enable-temporal-support\""
128+
129+
- name: Test Node.js in WSL
130+
shell: powershell
131+
run: |
132+
$wslCheckoutRoot = "/mnt/c/Users/runneradmin/work/${env:GITHUB_REPOSITORY//\/\_}"
133+
wsl -d Ubuntu-22.04 bash -c "cd $wslCheckoutRoot && make -C node 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+
$wslCheckoutRoot = "/mnt/c/Users/runneradmin/work/${env:GITHUB_REPOSITORY//\/\_}"
139+
$unusualDirName = "dir%20with \$unusual`"chars?'åß∂ƒ©∆¬…`" # This is the name *without* the 'node' prefix
140+
$nodeOriginalPath = "$wslCheckoutRoot/node"
141+
$nodeRenamedPath = "$wslCheckoutRoot/$unusualDirName"
142+
143+
wsl -d Ubuntu-22.04 bash -c "cd $wslCheckoutRoot && mv node \"$unusualDirName\""
144+
wsl -d Ubuntu-22.04 bash -c "cd \"$nodeRenamedPath\" && ./tools/test.py --flaky-tests keep_retrying -p actions -j 4"

0 commit comments

Comments
 (0)