mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-27 19:58:50 +00:00
ci: normalize Windows toolcache Node paths
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user