Skip to content

Commit 4790c27

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 4790c27

File tree

1 file changed

+124
-0
lines changed

1 file changed

+124
-0
lines changed

.github/workflows/test-windows.yml

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
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@v6
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+
Start-Sleep -Seconds 10
59+
60+
- name: Set up Python ${{ env.PYTHON_VERSION }} in WSL
61+
shell: powershell
62+
run: |
63+
wsl -d Ubuntu-22.04 bash -c "sudo apt-get update && sudo apt-get install -y python3 python3-pip"
64+
wsl -d Ubuntu-22.04 bash -c "python3 --version"
65+
66+
- name: Install Clang ${{ env.CLANG_VERSION }} in WSL
67+
shell: powershell
68+
run: |
69+
wsl -d Ubuntu-22.04 bash -c "sudo apt-get update && sudo apt-get install -y clang-${{ env.CLANG_VERSION }}"
70+
wsl -d Ubuntu-22.04 bash -c "sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-${{ env.CLANG_VERSION }} 100"
71+
wsl -d Ubuntu-22.04 bash -c "sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-${{ env.CLANG_VERSION }} 100"
72+
wsl -d Ubuntu-22.04 bash -c "clang --version"
73+
74+
- name: Install Rust ${{ env.RUSTC_VERSION }} in WSL
75+
shell: powershell
76+
run: |
77+
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 }}"
78+
wsl -d Ubuntu-22.04 bash -c "echo 'export PATH=\"$HOME/.cargo/bin:\$PATH\"' >> \$HOME/.bashrc"
79+
wsl -d Ubuntu-22.04 bash -c "source \$HOME/.bashrc && rustup override set ${{ env.RUSTC_VERSION }}"
80+
wsl -d Ubuntu-22.04 bash -c "source \$HOME/.bashrc && rustup --version"
81+
82+
- name: Set up sccache in WSL
83+
shell: powershell
84+
run: |
85+
$wslRepoPath = "/mnt/c/Users/runneradmin/work/${env:GITHUB_REPOSITORY//\/\_}/node"
86+
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"
87+
wsl -d Ubuntu-22.04 bash -c "mv $wslRepoPath/sccache-v0.3.0-x86_64-unknown-linux-gnu/sccache $wslRepoPath/.cargo/bin/"
88+
wsl -d Ubuntu-22.04 bash -c "echo 'CC=$wslRepoPath/.cargo/bin/sccache clang' >> $HOME/.bashrc"
89+
wsl -d Ubuntu-22.04 bash -c "echo 'CXX=$wslRepoPath/.cargo/bin/sccache clang++' >> $HOME/.bashrc"
90+
wsl -d Ubuntu-22.04 bash -c "echo 'SCCACHE_GHA_ENABLED=true' >> $HOME/.bashrc"
91+
92+
- name: Environment Information
93+
shell: powershell
94+
run: |
95+
$wslRepoPath = "/mnt/c/Users/runneradmin/work/${env:GITHUB_REPOSITORY//\/\_}/node"
96+
wsl -d Ubuntu-22.04 bash -c "cd $wslRepoPath && npx envinfo"
97+
98+
- name: tools/doc/node_modules workaround
99+
shell: powershell
100+
run: |
101+
$wslRepoPath = "/mnt/c/Users/runneradmin/work/${env:GITHUB_REPOSITORY//\/\_}/node"
102+
wsl -d Ubuntu-22.04 bash -c "cd $wslRepoPath && make tools/doc/node_modules"
103+
104+
- name: Build Node.js in WSL
105+
shell: powershell
106+
run: |
107+
$wslRepoPath = "/mnt/c/Users/runneradmin/work/${env:GITHUB_REPOSITORY//\/\_}/node"
108+
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\""
109+
110+
- name: Test Node.js in WSL
111+
shell: powershell
112+
run: |
113+
$repoPath = "node"
114+
$wslRepoPath = "/mnt/c/Users/runneradmin/work/${env:GITHUB_REPOSITORY//\/\_}/$repoPath"
115+
wsl -d Ubuntu-22.04 bash -c "cd $wslRepoPath && make test-ci -j1 V=1 TEST_CI_ARGS=\"-p actions --measure-flakiness 9\""
116+
117+
- name: Re-run test in a folder whose name contains unusual chars
118+
shell: powershell
119+
run: |
120+
$repoPath = "node"
121+
$wslRepoPath = "/mnt/c/Users/runneradmin/work/${env:GITHUB_REPOSITORY//\/\_}/$repoPath"
122+
$dir = "dir%20with \$unusual`"chars?'åß∂ƒ©∆¬…`"
123+
wsl -d Ubuntu-22.04 bash -c "cd $wslRepoPath && mv node \"$dir\""
124+
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)