|
| 1 | +name: Test Windows |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + types: [opened, synchronize, reopened, ready_for_review] |
| 6 | + paths-ignore: |
| 7 | + - '**.md' |
| 8 | + - '**.nix' |
| 9 | + - eslint.config.mjs |
| 10 | + - '**/eslint.config_partial.mjs' |
| 11 | + - android-configure |
| 12 | + - android-configure.py |
| 13 | + - android-patches/** |
| 14 | + - benchmarks/** |
| 15 | + - codecov.yml |
| 16 | + - doc/** |
| 17 | + - pyproject.yml |
| 18 | + - tsconfig.json |
| 19 | + - test/internet/** |
| 20 | + - tools/** |
| 21 | + - .** |
| 22 | + - '!.github/workflows/test-windows.yml' |
| 23 | + push: |
| 24 | + branches: |
| 25 | + - main |
| 26 | + - canary |
| 27 | + - v[0-9]+.x-staging |
| 28 | + - v[0-9]+.x |
| 29 | + paths-ignore: |
| 30 | + - '**.md' |
| 31 | + - '**.nix' |
| 32 | + - eslint.config.mjs |
| 33 | + - '**/eslint.config_partial.mjs' |
| 34 | + - android-configure |
| 35 | + - android-configure.py |
| 36 | + - android-patches/** |
| 37 | + - benchmarks/** |
| 38 | + - codecov.yml |
| 39 | + - doc/** |
| 40 | + - pyproject.yml |
| 41 | + - tsconfig.json |
| 42 | + - test/internet/** |
| 43 | + - tools/** |
| 44 | + - .** |
| 45 | + - '!.github/workflows/test-windows.yml' |
| 46 | + |
| 47 | +concurrency: |
| 48 | + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} |
| 49 | + cancel-in-progress: true |
| 50 | + |
| 51 | +env: |
| 52 | + PYTHON_VERSION: '3.14' |
| 53 | + FLAKY_TESTS: keep_retrying |
| 54 | + CLANG_VERSION: '19' |
| 55 | + RUSTC_VERSION: '1.85' |
| 56 | + |
| 57 | +permissions: |
| 58 | + contents: read |
| 59 | + |
| 60 | +jobs: |
| 61 | + test-wsl: |
| 62 | + if: github.event.pull_request.draft == false |
| 63 | + runs-on: windows-latest |
| 64 | + env: |
| 65 | + DISTRO_NAME: Ubuntu-22.04 |
| 66 | + CC: sccache clang |
| 67 | + CXX: sccache clang++ |
| 68 | + SCCACHE_GHA_ENABLED: 'true' |
| 69 | + |
| 70 | + steps: |
| 71 | + - name: Checkout code |
| 72 | + uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0 |
| 73 | + with: |
| 74 | + persist-credentials: false |
| 75 | + path: node |
| 76 | + |
| 77 | + - name: Download Ubuntu rootfs tarball |
| 78 | + shell: powershell |
| 79 | + run: | |
| 80 | + $url = "https://cloud-images.ubuntu.com/wsl/jammy/current/ubuntu-jammy-wsl-amd64-ubuntu22.04lts.rootfs.tar.gz" |
| 81 | + $output = "$env:TEMP\ubuntu-22.04.tar.gz" |
| 82 | + Write-Host "Downloading Ubuntu rootfs from $url to $output" |
| 83 | + Invoke-WebRequest -Uri $url -OutFile $output -UseBasicParsing |
| 84 | + Write-Host "Download complete. File size: $((Get-Item $output).Length) bytes" |
| 85 | +
|
| 86 | + - name: Import WSL Distribution |
| 87 | + shell: powershell |
| 88 | + run: | |
| 89 | + $distroName = "$env:DISTRO_NAME" |
| 90 | + $tarFile = "$env:TEMP\ubuntu-22.04.tar.gz" |
| 91 | + $installLocation = "$env:LOCALAPPDATA\WSL\$distroName" |
| 92 | +
|
| 93 | + Write-Host "Creating installation directory: $installLocation" |
| 94 | + New-Item -ItemType Directory -Force -Path $installLocation | Out-Null |
| 95 | +
|
| 96 | + Write-Host "Importing WSL distribution: $distroName" |
| 97 | + Write-Host " Tarball: $tarFile" |
| 98 | + Write-Host " Install location: $installLocation" |
| 99 | + wsl --import $distroName $installLocation $tarFile --version 2 |
| 100 | +
|
| 101 | + Write-Host "Verifying installation..." |
| 102 | + wsl --list --verbose |
| 103 | +
|
| 104 | + Write-Host "Testing WSL distribution..." |
| 105 | + wsl -d $distroName echo "WSL distribution is working!" |
| 106 | +
|
| 107 | + - name: Initial Setup in WSL |
| 108 | + shell: powershell |
| 109 | + run: | |
| 110 | + $distroName = "$env:DISTRO_NAME" |
| 111 | +
|
| 112 | + Write-Host "Installing basic packages..." |
| 113 | + wsl -d $distroName -u root bash -c "apt update && DEBIAN_FRONTEND=noninteractive apt install -y python3 python3-pip git curl sudo build-essential ca-certificates wget gnupg software-properties-common lsb-release" |
| 114 | +
|
| 115 | + Write-Host "Installing Clang ${{ env.CLANG_VERSION }}..." |
| 116 | + wsl -d $distroName -u root bash -c "wget -O /tmp/llvm.sh https://apt.llvm.org/llvm.sh && chmod +x /tmp/llvm.sh && /tmp/llvm.sh ${{ 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" |
| 117 | +
|
| 118 | + Write-Host "Installing Rust ${{ env.RUSTC_VERSION }}..." |
| 119 | + wsl -d $distroName -u root bash -c "curl --proto =https --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain ${{ env.RUSTC_VERSION }}" |
| 120 | +
|
| 121 | + Write-Host "Setting up Rust environment..." |
| 122 | + wsl -d $distroName -u root bash -c "echo 'export PATH=/root/.cargo/bin:\$PATH' >> /root/.bashrc" |
| 123 | +
|
| 124 | + Write-Host "Installing sccache v0.12.0..." |
| 125 | + wsl -d $distroName -u root bash -c "curl -L https://github.com/mozilla/sccache/releases/download/v0.12.0/sccache-v0.12.0-x86_64-unknown-linux-musl.tar.gz -o /tmp/sccache.tar.gz && tar -xzf /tmp/sccache.tar.gz -C /tmp && mv /tmp/sccache-v0.12.0-x86_64-unknown-linux-musl/sccache /usr/local/bin/ && chmod +x /usr/local/bin/sccache" |
| 126 | +
|
| 127 | + Write-Host "Setting environment variables..." |
| 128 | + wsl -d $distroName -u root bash -c "echo 'export CC=sccache clang' >> /root/.bashrc" |
| 129 | + wsl -d $distroName -u root bash -c "echo 'export CXX=sccache clang++' >> /root/.bashrc" |
| 130 | + wsl -d $distroName -u root bash -c "echo 'export SCCACHE_GHA_ENABLED=true' >> /root/.bashrc" |
| 131 | +
|
| 132 | + Write-Host "Verifying tools..." |
| 133 | + wsl -d $distroName bash -c "source /root/.bashrc && clang --version" |
| 134 | + wsl -d $distroName bash -c "source /root/.bashrc && rustc --version" |
| 135 | + wsl -d $distroName bash -c "source /root/.bashrc && sccache --version" |
| 136 | +
|
| 137 | + - name: Set up Python ${{ env.PYTHON_VERSION }} |
| 138 | + uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 |
| 139 | + with: |
| 140 | + python-version: ${{ env.PYTHON_VERSION }} |
| 141 | + allow-prereleases: true |
| 142 | + |
| 143 | + - name: Set up sccache (for GitHub Actions cache) |
| 144 | + uses: Mozilla-Actions/sccache-action@7d986dd989559c6ecdb630a3fd2557667be217ad # v0.0.9 |
| 145 | + with: |
| 146 | + version: v0.12.0 |
| 147 | + |
| 148 | + - name: Environment Information |
| 149 | + shell: powershell |
| 150 | + run: | |
| 151 | + $distroName = "$env:DISTRO_NAME" |
| 152 | + $checkoutRoot = "${{ github.workspace }}".Replace('\', '/') |
| 153 | + $wslCheckoutRoot = "/mnt/" + $checkoutRoot.Substring(0,1).ToLower() + $checkoutRoot.Substring(2).Replace(':', '') |
| 154 | +
|
| 155 | + Write-Host "WSL Checkout Root: $wslCheckoutRoot/node" |
| 156 | + Write-Host "Running envinfo in WSL..." |
| 157 | + wsl -d $distroName bash -c "source /root/.bashrc && cd '$wslCheckoutRoot/node' && npx envinfo" |
| 158 | +
|
| 159 | + - name: Build Node.js in WSL |
| 160 | + shell: powershell |
| 161 | + run: | |
| 162 | + $distroName = "$env:DISTRO_NAME" |
| 163 | + $checkoutRoot = "${{ github.workspace }}".Replace('\', '/') |
| 164 | + $wslCheckoutRoot = "/mnt/" + $checkoutRoot.Substring(0,1).ToLower() + $checkoutRoot.Substring(2).Replace(':', '') |
| 165 | +
|
| 166 | + $nproc = wsl -d $distroName bash -c "nproc" |
| 167 | + Write-Host "Building Node.js with $nproc cores..." |
| 168 | + wsl -d $distroName bash -c "source /root/.bashrc && cd '$wslCheckoutRoot/node' && make build-ci -j$nproc V=1 CONFIG_FLAGS='--error-on-warn'" |
| 169 | +
|
| 170 | + - name: Test Node.js in WSL |
| 171 | + shell: powershell |
| 172 | + run: | |
| 173 | + $distroName = "$env:DISTRO_NAME" |
| 174 | + $checkoutRoot = "${{ github.workspace }}".Replace('\', '/') |
| 175 | + $wslCheckoutRoot = "/mnt/" + $checkoutRoot.Substring(0,1).ToLower() + $checkoutRoot.Substring(2).Replace(':', '') |
| 176 | +
|
| 177 | + Write-Host "Running tests..." |
| 178 | + wsl -d $distroName bash -c "source /root/.bashrc && cd '$wslCheckoutRoot/node' && make test-ci -j1 V=1 TEST_CI_ARGS='-p actions --measure-flakiness 9'" |
| 179 | +
|
| 180 | + - name: Re-run test in a folder whose name contains unusual chars |
| 181 | + shell: powershell |
| 182 | + run: | |
| 183 | + $distroName = "$env:DISTRO_NAME" |
| 184 | + $checkoutRoot = "${{ github.workspace }}".Replace('\', '/') |
| 185 | + $wslCheckoutRoot = "/mnt/" + $checkoutRoot.Substring(0,1).ToLower() + $checkoutRoot.Substring(2).Replace(':', '') |
| 186 | + $unusualDir = "dir%20with `$unusual`"chars?'åß∂ƒ©∆¬…" |
| 187 | +
|
| 188 | + Write-Host "Re-running tests in unusual directory..." |
| 189 | + wsl -d $distroName bash -c "source /root/.bashrc && cd '$wslCheckoutRoot' && mv node '$unusualDir' && cd '$unusualDir' && ./tools/test.py --flaky-tests keep_retrying -p actions -j 4" |
| 190 | +
|
| 191 | + - name: Cleanup |
| 192 | + if: always() |
| 193 | + shell: powershell |
| 194 | + run: | |
| 195 | + $distroName = "$env:DISTRO_NAME" |
| 196 | + if ($distroName) { |
| 197 | + Write-Host "Unregistering WSL distribution: $distroName" |
| 198 | + wsl --unregister $distroName |
| 199 | + } |
0 commit comments