|
| 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@1af3b93b68115bc44a9784bd300feb67ff0d1eeb3 # v6.0.0, use consistent SHA |
| 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-wsl.rootfs.tar.gz" |
| 59 | + $output = "$env:TEMP\ubuntu-22.04.tar.gz" |
| 60 | + |
| 61 | + Invoke-WebRequest -Uri $url -OutFile $output |
| 62 | + Write-Host "Download complete: $output" |
| 63 | + |
| 64 | + - name: Import WSL Distribution |
| 65 | + shell: powershell |
| 66 | + run: | |
| 67 | + Write-Host "=== Importing distribution to WSL ===" |
| 68 | + $tarFile = "$env:TEMP\ubuntu-22.04.tar.gz" |
| 69 | + $installDir = "$env:LOCALAPPDATA\WSL\Ubuntu-22.04" |
| 70 | + $distroName = "Ubuntu-22.04" |
| 71 | + |
| 72 | + # Ensure target directory exists |
| 73 | + New-Item -ItemType Directory -Force -Path $installDir |
| 74 | + |
| 75 | + # wsl --import is fully non-interactive |
| 76 | + wsl --import $distroName $installDir $tarFile |
| 77 | + |
| 78 | + Write-Host "\n=== Installation check ===" |
| 79 | + wsl --list --verbose |
| 80 | + |
| 81 | + - name: Initial Setup in WSL |
| 82 | + shell: powershell |
| 83 | + run: | |
| 84 | + $distroName = "Ubuntu-22.04" |
| 85 | + $bashScript = @" |
| 86 | + set -ex |
| 87 | + export DEBIAN_FRONTEND=noninteractive |
| 88 | + apt update |
| 89 | + apt install -y python3 python3-pip git curl sudo # Install common tools |
| 90 | + |
| 91 | + # Install Clang |
| 92 | + apt install -y clang-${{ env.CLANG_VERSION }} |
| 93 | + update-alternatives --install /usr/bin/clang clang /usr/bin/clang-${{ env.CLANG_VERSION }} 100 |
| 94 | + update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-${{ env.CLANG_VERSION }} 100 |
| 95 | + clang --version |
| 96 | +
|
| 97 | + # Install Rust |
| 98 | + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain ${{ env.RUSTC_VERSION }} |
| 99 | + echo 'export PATH="\$HOME/.cargo/bin:\$PATH"' >> \$HOME/.bashrc |
| 100 | + source \$HOME/.bashrc # Source for current shell |
| 101 | + rustup override set ${{ env.RUSTC_VERSION }} |
| 102 | + rustup --version |
| 103 | + |
| 104 | + # Install sccache |
| 105 | + 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 |
| 106 | + mkdir -p ~/.cargo/bin |
| 107 | + mv sccache-v0.3.0-x86_64-unknown-linux-gnu/sccache ~/.cargo/bin/ |
| 108 | + echo 'export PATH="\$HOME/.cargo/bin:\$PATH"' >> \$HOME/.bashrc |
| 109 | + echo 'export CC="sccache clang"' >> \$HOME/.bashrc |
| 110 | + echo 'export CXX="sccache clang++"' >> \$HOME/.bashrc |
| 111 | + echo 'export SCCACHE_GHA_ENABLED="true"' >> \$HOME/.bashrc |
| 112 | + source \$HOME/.bashrc # Source again to apply sccache env vars |
| 113 | + "@ |
| 114 | + wsl -d $distroName -u root bash -c $bashScript |
| 115 | +
|
| 116 | + - name: Environment Information |
| 117 | + shell: powershell |
| 118 | + run: | |
| 119 | + $distroName = "Ubuntu-22.04" |
| 120 | + $wslCheckoutRoot = $env:GITHUB_WORKSPACE -replace '\\', '/' -replace 'C:', '/mnt/c' |
| 121 | + wsl -d $distroName bash -c "cd '$wslCheckoutRoot' && npx envinfo" |
| 122 | +
|
| 123 | + - name: tools/doc/node_modules workaround |
| 124 | + shell: powershell |
| 125 | + run: | |
| 126 | + $distroName = "Ubuntu-22.04" |
| 127 | + $wslCheckoutRoot = $env:GITHUB_WORKSPACE -replace '\\', '/' -replace 'C:', '/mnt/c' |
| 128 | + wsl -d $distroName bash -c "cd '$wslCheckoutRoot' && make -C node tools/doc/node_modules" |
| 129 | +
|
| 130 | + - name: Build Node.js in WSL |
| 131 | + shell: powershell |
| 132 | + run: | |
| 133 | + $distroName = "Ubuntu-22.04" |
| 134 | + $wslCheckoutRoot = $env:GITHUB_WORKSPACE -replace '\\', '/' -replace 'C:', '/mnt/c' |
| 135 | + 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\"" |
| 136 | + |
| 137 | + - name: Test Node.js in WSL |
| 138 | + shell: powershell |
| 139 | + run: | |
| 140 | + $distroName = "Ubuntu-22.04" |
| 141 | + $wslCheckoutRoot = $env:GITHUB_WORKSPACE -replace '\\', '/' -replace 'C:', '/mnt/c' |
| 142 | + wsl -d $distroName bash -c "cd '$wslCheckoutRoot' && make -C node test-ci -j1 V=1 TEST_CI_ARGS=\"-p actions --measure-flakiness 9\"" |
| 143 | +
|
| 144 | + - name: Re-run test in a folder whose name contains unusual chars |
| 145 | + shell: powershell |
| 146 | + run: | |
| 147 | + $distroName = "Ubuntu-22.04" |
| 148 | + $wslCheckoutRoot = $env:GITHUB_WORKSPACE -replace '\\', '/' -replace 'C:', '/mnt/c' |
| 149 | + $unusualDirName = "dir%20with \$unusual`"chars?'åß∂ƒ©∆¬…`" |
| 150 | + $nodeRenamedPath = "$wslCheckoutRoot/$unusualDirName" |
| 151 | +
|
| 152 | + wsl -d $distroName bash -c "cd '$wslCheckoutRoot' && mv node \"$unusualDirName\"" |
| 153 | + wsl -d $distroName bash -c "cd \"$nodeRenamedPath\" && ./tools/test.py --flaky-tests keep_retrying -p actions -j 4" |
| 154 | + |
| 155 | + - name: Cleanup |
| 156 | + if: always() |
| 157 | + shell: powershell |
| 158 | + run: | |
| 159 | + $distroName = "Ubuntu-22.04" |
| 160 | + wsl --unregister $distroName |
0 commit comments