ci: Add WSL testing workflow for Windows #25
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Test Windows | |
| on: | |
| pull_request: | |
| paths-ignore: | |
| - .mailmap | |
| - README.md | |
| - vcbuild.bat | |
| - test/internet/** | |
| - '**.nix' | |
| - .github/** | |
| - '!.github/workflows/test-windows.yml' | |
| types: [opened, synchronize, reopened, ready_for_review] | |
| push: | |
| branches: | |
| - main | |
| - canary | |
| - v[0-9]+.x-staging | |
| - v[0-9]+.x | |
| paths-ignore: | |
| - .mailmap | |
| - README.md | |
| - vcbuild.bat | |
| - test/internet/** | |
| - '**.nix' | |
| - .github/** | |
| - '!.github/workflows/test-windows.yml' | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | |
| cancel-in-progress: true | |
| env: | |
| PYTHON_VERSION: '3.14' | |
| FLAKY_TESTS: keep_retrying | |
| CLANG_VERSION: '19' | |
| RUSTC_VERSION: '1.82' | |
| permissions: | |
| contents: read | |
| jobs: | |
| test-wsl: | |
| if: github.event.pull_request.draft == false | |
| strategy: | |
| fail-fast: false | |
| runs-on: windows-latest | |
| steps: | |
| - uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0, use consistent SHA | |
| with: | |
| persist-credentials: false | |
| path: node | |
| - name: Download Ubuntu rootfs tarball | |
| shell: powershell | |
| run: | | |
| Write-Host "=== Downloading Ubuntu rootfs tarball ===" | |
| $url = "https://cloud-images.ubuntu.com/wsl/jammy/current/ubuntu-jammy-wsl-amd64-wsl.rootfs.tar.gz" | |
| $output = "$env:TEMP\ubuntu-22.04.tar.gz" | |
| Invoke-WebRequest -Uri $url -OutFile $output | |
| Write-Host "Download complete: $output" | |
| - name: Import WSL Distribution | |
| shell: powershell | |
| run: | | |
| Write-Host "=== Importing distribution to WSL ===" | |
| $tarFile = "$env:TEMP\ubuntu-22.04.tar.gz" | |
| $installDir = "$env:LOCALAPPDATA\WSL\Ubuntu-22.04" | |
| $distroName = "Ubuntu-22.04" | |
| # Ensure target directory exists | |
| New-Item -ItemType Directory -Force -Path $installDir | |
| # wsl --import is fully non-interactive | |
| wsl --import $distroName $installDir $tarFile | |
| Write-Host "\n=== Installation check ===" | |
| wsl --list --verbose | |
| - name: Initial Setup in WSL | |
| shell: powershell | |
| run: | | |
| $distroName = "Ubuntu-22.04" | |
| $bashScript = @" | |
| set -ex | |
| export DEBIAN_FRONTEND=noninteractive | |
| apt update | |
| apt install -y python3 python3-pip git curl sudo # Install common tools | |
| # Install Clang | |
| apt install -y clang-${{ 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 | |
| clang --version | |
| # Install Rust | |
| curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain ${{ env.RUSTC_VERSION }} | |
| echo 'export PATH="\$HOME/.cargo/bin:\$PATH"' >> \$HOME/.bashrc | |
| source \$HOME/.bashrc # Source for current shell | |
| rustup override set ${{ env.RUSTC_VERSION }} | |
| rustup --version | |
| # Install sccache | |
| 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 | |
| mkdir -p ~/.cargo/bin | |
| mv sccache-v0.3.0-x86_64-unknown-linux-gnu/sccache ~/.cargo/bin/ | |
| echo 'export PATH="\$HOME/.cargo/bin:\$PATH"' >> \$HOME/.bashrc | |
| echo 'export CC="sccache clang"' >> \$HOME/.bashrc | |
| echo 'export CXX="sccache clang++"' >> \$HOME/.bashrc | |
| echo 'export SCCACHE_GHA_ENABLED="true"' >> \$HOME/.bashrc | |
| source \$HOME/.bashrc # Source again to apply sccache env vars | |
| "@ | |
| wsl -d $distroName -u root bash -c $bashScript | |
| - name: Environment Information | |
| shell: powershell | |
| run: | | |
| $distroName = "Ubuntu-22.04" | |
| $wslCheckoutRoot = $env:GITHUB_WORKSPACE -replace '\\', '/' -replace 'C:', '/mnt/c' | |
| wsl -d $distroName bash -c "cd '$wslCheckoutRoot' && npx envinfo" | |
| - name: tools/doc/node_modules workaround | |
| shell: powershell | |
| run: | | |
| $distroName = "Ubuntu-22.04" | |
| $wslCheckoutRoot = $env:GITHUB_WORKSPACE -replace '\\', '/' -replace 'C:', '/mnt/c' | |
| wsl -d $distroName bash -c "cd '$wslCheckoutRoot' && make -C node tools/doc/node_modules" | |
| - name: Build Node.js in WSL | |
| shell: powershell | |
| run: | | |
| $distroName = "Ubuntu-22.04" | |
| $wslCheckoutRoot = $env:GITHUB_WORKSPACE -replace '\\', '/' -replace 'C:', '/mnt/c' | |
| wsl -d $distroName bash -c "cd '$wslCheckoutRoot' && make -C node build-ci -j$(nproc) V=1 CONFIG_FLAGS=\"--error-on-warn --v8-enable-temporal-support\"" | |
| - name: Test Node.js in WSL | |
| shell: powershell | |
| run: | | |
| $distroName = "Ubuntu-22.04" | |
| $wslCheckoutRoot = $env:GITHUB_WORKSPACE -replace '\\', '/' -replace 'C:', '/mnt/c' | |
| wsl -d $distroName bash -c "cd '$wslCheckoutRoot' && make -C node test-ci -j1 V=1 TEST_CI_ARGS=\"-p actions --measure-flakiness 9\"" | |
| - name: Re-run test in a folder whose name contains unusual chars | |
| shell: powershell | |
| run: | | |
| $distroName = "Ubuntu-22.04" | |
| $wslCheckoutRoot = $env:GITHUB_WORKSPACE -replace '\\', '/' -replace 'C:', '/mnt/c' | |
| $unusualDirName = "dir%20with \$unusual`"chars?'Γ₯ΓβΖΒ©βΒ¬β¦`" | |
| $nodeRenamedPath = "$wslCheckoutRoot/$unusualDirName" | |
| wsl -d $distroName bash -c "cd '$wslCheckoutRoot' && mv node \"$unusualDirName\"" | |
| wsl -d $distroName bash -c "cd \"$nodeRenamedPath\" && ./tools/test.py --flaky-tests keep_retrying -p actions -j 4" | |
| - name: Cleanup | |
| if: always() | |
| shell: powershell | |
| run: | | |
| $distroName = "Ubuntu-22.04" | |
| wsl --unregister $distroName |