From c84f61cd2ef0a8959017ab8b52873daed781e92e Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Tue, 26 May 2026 15:09:16 +0100 Subject: [PATCH] ci: normalize Windows toolcache Node paths --- .../setup-pnpm-store-cache/ensure-node.sh | 12 ++++- ...setup-pnpm-store-cache-ensure-node.test.ts | 52 +++++++++++++++++++ 2 files changed, 62 insertions(+), 2 deletions(-) diff --git a/.github/actions/setup-pnpm-store-cache/ensure-node.sh b/.github/actions/setup-pnpm-store-cache/ensure-node.sh index e4e72a740b8..c821fb5c15a 100644 --- a/.github/actions/setup-pnpm-store-cache/ensure-node.sh +++ b/.github/actions/setup-pnpm-store-cache/ensure-node.sh @@ -28,9 +28,17 @@ openclaw_active_node_version() { openclaw_prepend_node_bin() { local node_bin_dir="$1" - export PATH="$node_bin_dir:$PATH" + local shell_node_bin_dir="$node_bin_dir" + if command -v cygpath >/dev/null 2>&1; then + shell_node_bin_dir="$(cygpath -u "$node_bin_dir" 2>/dev/null || printf '%s' "$node_bin_dir")" + fi + export PATH="$shell_node_bin_dir:$PATH" if [[ -n "${GITHUB_PATH:-}" ]]; then - echo "$node_bin_dir" >> "$GITHUB_PATH" + local github_node_bin_dir="$shell_node_bin_dir" + if command -v cygpath >/dev/null 2>&1; then + github_node_bin_dir="$(cygpath -w "$shell_node_bin_dir" 2>/dev/null || printf '%s' "$shell_node_bin_dir")" + fi + echo "$github_node_bin_dir" >> "$GITHUB_PATH" fi hash -r } diff --git a/test/scripts/setup-pnpm-store-cache-ensure-node.test.ts b/test/scripts/setup-pnpm-store-cache-ensure-node.test.ts index d6dc65adfbb..4db88633167 100644 --- a/test/scripts/setup-pnpm-store-cache-ensure-node.test.ts +++ b/test/scripts/setup-pnpm-store-cache-ensure-node.test.ts @@ -94,6 +94,58 @@ describe("setup-pnpm-store-cache ensure-node", () => { } }); + it("normalizes Windows toolcache paths for Git Bash before prepending PATH", () => { + const root = mkdtempSync(join(tmpdir(), "openclaw-ensure-node-")); + try { + const activeBin = join(root, "active", "bin"); + writeFakeNode(activeBin, "22.22.3"); + const toolcacheBin = join(root, "toolcache", "node", "24.15.0", "x64"); + const toolcacheNode = writeFakeNode(toolcacheBin, "24.15.0"); + const helperBin = join(root, "helpers"); + mkdirSync(helperBin, { recursive: true }); + const cygpath = join(helperBin, "cygpath"); + writeFileSync( + cygpath, + `#!/usr/bin/env bash +if [[ "$1" == "-u" ]]; then + echo "${toolcacheBin}" + exit 0 +fi +if [[ "$1" == "-w" ]]; then + echo "C:\\\\hostedtoolcache\\\\windows\\\\node\\\\24.15.0\\\\x64" + exit 0 +fi +exit 1 +`, + ); + chmodSync(cygpath, 0o755); + const githubPath = join(root, "github-path"); + const result = spawnSync( + "bash", + [ + "-c", + [ + "set -e", + `export PATH=${JSON.stringify(`${helperBin}:${activeBin}:${process.env.PATH ?? ""}`)}`, + `export GITHUB_PATH=${JSON.stringify(githubPath)}`, + `source "${ensureNodeScript}"`, + `openclaw_prepend_node_bin "C:\\\\hostedtoolcache\\\\windows/node/24.15.0/x64"`, + "command -v node", + "node -p 'process.versions.node'", + `cat "${githubPath}"`, + ].join("; "), + ], + { encoding: "utf8", env: process.env }, + ); + + expect(result.status).toBe(0); + expect(result.stdout).toContain(`${toolcacheNode}\n24.15.0`); + expect(result.stdout).toContain("C:\\hostedtoolcache\\windows\\node\\24.15.0\\x64"); + } finally { + rmSync(root, { recursive: true, force: true }); + } + }); + it("repairs PATH from the container-mounted GitHub Actions toolcache", () => { const root = mkdtempSync(join(tmpdir(), "openclaw-ensure-node-")); try {