惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Jina AI
Jina AI
T
The Blog of Author Tim Ferriss
B
Blog
L
LangChain Blog
Y
Y Combinator Blog
美团技术团队
博客园 - 三生石上(FineUI控件)
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
G
Google Developers Blog
量子位
博客园_首页
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
C
Check Point Blog
D
Docker
小众软件
小众软件
The Cloudflare Blog
大猫的无限游戏
大猫的无限游戏
T
Tailwind CSS Blog
Apple Machine Learning Research
Apple Machine Learning Research
博客园 - 聂微东
Blog — PlanetScale
Blog — PlanetScale
GbyAI
GbyAI
Google DeepMind News
Google DeepMind News
IT之家
IT之家

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix(test): route release ref resolver · openclaw/openclaw...
vincentkoc · 2026-06-21 · via Recent Commits to openclaw:main
1+

// Resolve OpenClaw ref tests cover the release workflow ref resolver script.

2+

import { execFileSync, spawnSync } from "node:child_process";

3+

import { join } from "node:path";

4+

import { afterEach, describe, expect, it } from "vitest";

5+

import { createTempDirTracker } from "../helpers/temp-dir.js";

6+7+

const SCRIPT_PATH = "scripts/github/resolve-openclaw-ref.sh";

8+

const tempDirs = createTempDirTracker();

9+10+

afterEach(() => {

11+

tempDirs.cleanup();

12+

});

13+14+

function git(cwd: string, args: string[]): string {

15+

return execFileSync("git", args, {

16+

cwd,

17+

encoding: "utf8",

18+

stdio: ["ignore", "pipe", "pipe"],

19+

}).trim();

20+

}

21+22+

function createRemoteRepo() {

23+

const repo = tempDirs.make("openclaw-ref-remote-");

24+

git(repo, ["init", "-q", "-b", "main"]);

25+

git(repo, ["config", "user.email", "test-user"]);

26+

git(repo, ["config", "user.name", "Test User"]);

27+

execFileSync("bash", ["-c", "printf seed > seed.txt"], { cwd: repo });

28+

git(repo, ["add", "seed.txt"]);

29+

git(repo, ["commit", "-qm", "seed"]);

30+

const sha = git(repo, ["rev-parse", "HEAD"]);

31+

git(repo, ["branch", "release/test"]);

32+

git(repo, ["branch", "ambiguous"]);

33+

git(repo, ["-c", "tag.gpgSign=false", "tag", "v2026.6.21"]);

34+

git(repo, ["-c", "tag.gpgSign=false", "tag", "ambiguous"]);

35+

return { repo, sha };

36+

}

37+38+

function runResolver(remote: string, args: string[]) {

39+

return spawnSync("bash", [SCRIPT_PATH, ...args], {

40+

cwd: process.cwd(),

41+

encoding: "utf8",

42+

env: {

43+

...process.env,

44+

OPENCLAW_REF_REMOTE: remote,

45+

},

46+

});

47+

}

48+49+

function parseOutput(output: string): Record<string, string> {

50+

return Object.fromEntries(

51+

output

52+

.trim()

53+

.split("\n")

54+

.filter(Boolean)

55+

.map((line) => {

56+

const separator = line.indexOf("=");

57+

return [line.slice(0, separator), line.slice(separator + 1)];

58+

}),

59+

);

60+

}

61+62+

function expectSuccessfulOutput(result: ReturnType<typeof runResolver>): Record<string, string> {

63+

expect(result.status).toBe(0);

64+

expect(result.stderr).toBe("");

65+

return parseOutput(result.stdout);

66+

}

67+68+

describe("scripts/github/resolve-openclaw-ref.sh", () => {

69+

it("resolves branch and tag refs with git ls-remote", () => {

70+

const { repo, sha } = createRemoteRepo();

71+72+

expect(expectSuccessfulOutput(runResolver(repo, ["--ref", "release/test"]))).toEqual({

73+

fallback: "false",

74+

fast: "true",

75+

ref_kind: "branch",

76+

sha,

77+

});

78+

expect(expectSuccessfulOutput(runResolver(repo, ["--ref", "v2026.6.21"]))).toEqual({

79+

fallback: "false",

80+

fast: "true",

81+

ref_kind: "tag",

82+

sha,

83+

});

84+

});

85+86+

it("accepts full commit SHA refs without remote lookup", () => {

87+

const { repo, sha } = createRemoteRepo();

88+

const result = runResolver(repo, ["--ref", sha.toUpperCase()]);

89+90+

expect(expectSuccessfulOutput(result)).toEqual({

91+

fallback: "true",

92+

fast: "false",

93+

ref_kind: "sha",

94+

sha,

95+

});

96+

});

97+98+

it("writes fallback outputs for unresolved refs when a caller supplies an expected SHA", () => {

99+

const { repo, sha } = createRemoteRepo();

100+

const outputPath = join(tempDirs.make("openclaw-ref-output-"), "github-output.txt");

101+

const result = runResolver(repo, [

102+

"--ref",

103+

"missing-ref",

104+

"--expected-sha",

105+

sha,

106+

"--fallback-ok",

107+

"--github-output",

108+

outputPath,

109+

]);

110+111+

expect(result.status).toBe(0);

112+

expect(result.stdout).toBe("");

113+

expect(parseOutput(execFileSync("cat", [outputPath], { encoding: "utf8" }))).toEqual({

114+

fallback: "true",

115+

fast: "false",

116+

ref_kind: "unknown",

117+

sha,

118+

});

119+

});

120+121+

it("does not let fallback mode hide remote lookup failures", () => {

122+

const missingRemote = join(tempDirs.make("openclaw-ref-missing-"), "missing.git");

123+

const result = runResolver(missingRemote, [

124+

"--ref",

125+

"missing-ref",

126+

"--expected-sha",

127+

"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",

128+

"--fallback-ok",

129+

]);

130+131+

expect(result.status).toBe(1);

132+

expect(result.stderr).toContain("does not appear to be a git repository");

133+

expect(result.stdout).toBe("");

134+

});

135+136+

it("rejects ambiguous branch and tag names before emitting outputs", () => {

137+

const { repo } = createRemoteRepo();

138+

const result = runResolver(repo, ["--ref", "ambiguous"]);

139+140+

expect(result.status).toBe(1);

141+

expect(result.stderr).toContain("Ref resolved ambiguously as both branch and tag: ambiguous");

142+

expect(result.stdout).toBe("");

143+

});

144+

});