mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 15:50:46 +00:00
test(rtt): support main package measurements
This commit is contained in:
@@ -8,6 +8,7 @@ const execFileAsync = promisify(execFile);
|
||||
export type RttProviderMode = "mock-openai" | "live-frontier";
|
||||
|
||||
export type RttCliOptions = {
|
||||
packageTgz?: string;
|
||||
providerMode: RttProviderMode;
|
||||
runs: number;
|
||||
samples: number;
|
||||
@@ -75,7 +76,7 @@ export type TelegramQaSummary = {
|
||||
};
|
||||
|
||||
const OPENCLAW_PACKAGE_SPEC_RE =
|
||||
/^openclaw@(beta|latest|[0-9]{4}\.[1-9][0-9]*\.[1-9][0-9]*(-[1-9][0-9]*|-beta\.[1-9][0-9]*)?)$/u;
|
||||
/^openclaw@(main|beta|latest|[0-9]{4}\.[1-9][0-9]*\.[1-9][0-9]*(-[1-9][0-9]*|-beta\.[1-9][0-9]*)?)$/u;
|
||||
|
||||
const REQUIRED_TELEGRAM_ENV = [
|
||||
"OPENCLAW_QA_TELEGRAM_GROUP_ID",
|
||||
@@ -86,7 +87,7 @@ const REQUIRED_TELEGRAM_ENV = [
|
||||
export function validateOpenClawPackageSpec(spec: string) {
|
||||
if (!OPENCLAW_PACKAGE_SPEC_RE.test(spec)) {
|
||||
throw new Error(
|
||||
`Package spec must be openclaw@beta, openclaw@latest, or an exact OpenClaw release version; got: ${spec}`,
|
||||
`Package spec must be openclaw@main, openclaw@beta, openclaw@latest, or an exact OpenClaw release version; got: ${spec}`,
|
||||
);
|
||||
}
|
||||
return spec;
|
||||
@@ -128,6 +129,7 @@ export function extractRtt(summary: TelegramQaSummary) {
|
||||
|
||||
export function createHarnessEnv(params: {
|
||||
baseEnv: NodeJS.ProcessEnv;
|
||||
packageTgz?: string;
|
||||
providerMode: RttProviderMode;
|
||||
scenarios: string[];
|
||||
spec: string;
|
||||
@@ -140,6 +142,7 @@ export function createHarnessEnv(params: {
|
||||
return {
|
||||
...params.baseEnv,
|
||||
OPENCLAW_NPM_TELEGRAM_PACKAGE_SPEC: params.spec,
|
||||
...(params.packageTgz ? { OPENCLAW_NPM_TELEGRAM_PACKAGE_TGZ: params.packageTgz } : {}),
|
||||
OPENCLAW_NPM_TELEGRAM_PACKAGE_LABEL: `${params.spec} (${params.version})`,
|
||||
OPENCLAW_NPM_TELEGRAM_PROVIDER_MODE: params.providerMode,
|
||||
OPENCLAW_NPM_TELEGRAM_SCENARIOS: params.scenarios.join(","),
|
||||
@@ -189,6 +192,20 @@ export async function resolvePublishedVersion(spec: string) {
|
||||
return parsed.trim();
|
||||
}
|
||||
|
||||
export async function resolveMainVersion(harnessRoot: string) {
|
||||
const packageJson = JSON.parse(
|
||||
await fs.readFile(path.join(harnessRoot, "package.json"), "utf8"),
|
||||
) as { version?: unknown };
|
||||
if (typeof packageJson.version !== "string" || packageJson.version.trim().length === 0) {
|
||||
throw new Error("OpenClaw package.json must contain a non-empty version.");
|
||||
}
|
||||
const { stdout } = await execFileAsync("git", ["rev-parse", "--short=10", "HEAD"], {
|
||||
cwd: harnessRoot,
|
||||
timeout: 10_000,
|
||||
});
|
||||
return `${packageJson.version.trim()}+${stdout.trim()}`;
|
||||
}
|
||||
|
||||
export async function readTelegramSummary(summaryPath: string) {
|
||||
return JSON.parse(await fs.readFile(summaryPath, "utf8")) as TelegramQaSummary;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user