Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

smoke-wsl2-native-runtime.ps1

64 lines2.4 KB

1param(
2 [Parameter(Mandatory = $true)][string]$RuntimeDir,
3 [string[]]$Distros = @("Ubuntu-24.04", "Debian")
4)
5​
6$ErrorActionPreference = "Stop"
7Set-StrictMode -Version Latest
8​
9$repoRoot = (Resolve-Path (Join-Path $PSScriptRoot "..")).Path
10$runtimeRoot = (Resolve-Path $RuntimeDir).Path
11$nodeWindowsPath = (Resolve-Path (Join-Path $runtimeRoot "node")).Path
12$ptyWindowsPath = (Resolve-Path (Join-Path $runtimeRoot "pty.node")).Path
13$manifestWindowsPath = (Resolve-Path (Join-Path $runtimeRoot "wsl-native-abi.json")).Path
14$smokeWindowsPath = (Resolve-Path (Join-Path $repoRoot "scripts/smoke-wsl-native-runtime.mjs")).Path
15​
16function Convert-ToWslPath {
17 param([Parameter(Mandatory = $true)][string]$Distro, [Parameter(Mandatory = $true)][string]$WindowsPath)
18 $normalized = $WindowsPath.Replace('\', '/')
19 $output = & wsl.exe --distribution $Distro -- wslpath -u $normalized
20 if ($LASTEXITCODE -ne 0) {
21 throw "wslpath failed for '$WindowsPath' in $Distro"
22 }
23 $value = ($output | Out-String).Trim()
24 if (-not $value.StartsWith("/")) {
25 throw "wslpath returned a non-absolute path for '$WindowsPath' in ${Distro}: $value"
26 }
27 return $value
29​
30foreach ($distro in $Distros) {
31 $nodeWslPath = Convert-ToWslPath -Distro $distro -WindowsPath $nodeWindowsPath
32 $ptyWslPath = Convert-ToWslPath -Distro $distro -WindowsPath $ptyWindowsPath
33 $manifestWslPath = Convert-ToWslPath -Distro $distro -WindowsPath $manifestWindowsPath
34 $smokeWslPath = Convert-ToWslPath -Distro $distro -WindowsPath $smokeWindowsPath
35 $repoWslPath = Convert-ToWslPath -Distro $distro -WindowsPath $repoRoot
36 $cachedNode = "/tmp/t3code-wsl-ci/node"
37​
38 Write-Host "=== Native runtime smoke inside $distro ==="
39 & wsl.exe --distribution $distro -- /bin/sh -c @'
40set -eu
41source_node="$1"
42target_node="$2"
43smoke_script="$3"
44repo_root="$4"
45pty_path="$5"
46manifest_path="$6"
47mkdir -p "$(dirname "$target_node")"
48cp "$source_node" "$target_node"
49chmod 0755 "$target_node"
50"$target_node" "$smoke_script" \
51 --server-root "$repo_root/apps/server" \
52 --arch x64 \
53 --node-pty "$pty_path" \
54 --node-runtime "$target_node" \
55 --manifest "$manifest_path"
56'@ sh $nodeWslPath $cachedNode $smokeWslPath $repoWslPath $ptyWslPath $manifestWslPath
57 if ($LASTEXITCODE -ne 0) {
58 throw "Native runtime smoke failed inside $distro with exit code $LASTEXITCODE"
59 }
61​
62if ($env:GITHUB_ENV) {
63 "T3CODE_WSL_TEST_BUNDLED_NODE_WINDOWS_PATH=$nodeWindowsPath" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append