mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 11:50:43 +00:00
chore: improve beta smoke release tooling
This commit is contained in:
@@ -88,17 +88,70 @@ if [ -z "$PACKAGE_LABEL" ]; then
|
||||
fi
|
||||
fi
|
||||
|
||||
credential_source="$(resolve_credential_source)"
|
||||
credential_role="$(resolve_credential_role)"
|
||||
if [ -z "$credential_role" ] && [ -n "${CI:-}" ] && [ "$credential_source" = "convex" ]; then
|
||||
credential_role="ci"
|
||||
fi
|
||||
|
||||
validate_credential_preflight() {
|
||||
if [ "${OPENCLAW_NPM_TELEGRAM_SKIP_CREDENTIAL_PREFLIGHT:-0}" = "1" ]; then
|
||||
return 0
|
||||
fi
|
||||
if [ "$credential_source" = "convex" ]; then
|
||||
if [ -z "${OPENCLAW_QA_CONVEX_SITE_URL:-}" ]; then
|
||||
echo "Missing required env for Convex credential mode: OPENCLAW_QA_CONVEX_SITE_URL" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [ "$credential_role" = "ci" ]; then
|
||||
if [ -z "${OPENCLAW_QA_CONVEX_SECRET_CI:-}" ]; then
|
||||
echo "Missing required env for Convex ci credential mode: OPENCLAW_QA_CONVEX_SECRET_CI" >&2
|
||||
exit 1
|
||||
fi
|
||||
return 0
|
||||
fi
|
||||
if [ "$credential_role" = "maintainer" ]; then
|
||||
if [ -z "${OPENCLAW_QA_CONVEX_SECRET_MAINTAINER:-}" ]; then
|
||||
echo "Missing required env for Convex maintainer credential mode: OPENCLAW_QA_CONVEX_SECRET_MAINTAINER" >&2
|
||||
exit 1
|
||||
fi
|
||||
return 0
|
||||
fi
|
||||
if [ -z "${OPENCLAW_QA_CONVEX_SECRET_CI:-}" ] && [ -z "${OPENCLAW_QA_CONVEX_SECRET_MAINTAINER:-}" ]; then
|
||||
echo "Missing required env for Convex credential mode: OPENCLAW_QA_CONVEX_SECRET_CI or OPENCLAW_QA_CONVEX_SECRET_MAINTAINER" >&2
|
||||
exit 1
|
||||
fi
|
||||
return 0
|
||||
fi
|
||||
|
||||
local missing=()
|
||||
for key in \
|
||||
OPENCLAW_QA_TELEGRAM_GROUP_ID \
|
||||
OPENCLAW_QA_TELEGRAM_DRIVER_BOT_TOKEN \
|
||||
OPENCLAW_QA_TELEGRAM_SUT_BOT_TOKEN; do
|
||||
if [ -z "${!key:-}" ]; then
|
||||
missing+=("$key")
|
||||
fi
|
||||
done
|
||||
if [ "${#missing[@]}" -gt 0 ]; then
|
||||
{
|
||||
echo "Missing required Telegram QA credential env before Docker work: ${missing[*]}"
|
||||
echo "Use one of:"
|
||||
echo " direct Telegram env: OPENCLAW_QA_TELEGRAM_GROUP_ID, OPENCLAW_QA_TELEGRAM_DRIVER_BOT_TOKEN, OPENCLAW_QA_TELEGRAM_SUT_BOT_TOKEN"
|
||||
echo " Convex env: OPENCLAW_NPM_TELEGRAM_CREDENTIAL_SOURCE=convex plus OPENCLAW_QA_CONVEX_SITE_URL and a role secret"
|
||||
} >&2
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
validate_credential_preflight
|
||||
|
||||
docker_e2e_build_or_reuse "$IMAGE_NAME" npm-telegram-live "$ROOT_DIR/scripts/e2e/Dockerfile" "$ROOT_DIR" "$DOCKER_TARGET"
|
||||
|
||||
mkdir -p "$ROOT_DIR/.artifacts/qa-e2e"
|
||||
run_log="$(mktemp "${TMPDIR:-/tmp}/openclaw-npm-telegram-live.XXXXXX")"
|
||||
npm_prefix_host="$(mktemp -d "$ROOT_DIR/.artifacts/qa-e2e/npm-telegram-live-prefix.XXXXXX")"
|
||||
trap 'rm -f "$run_log"; rm -rf "$npm_prefix_host"' EXIT
|
||||
credential_source="$(resolve_credential_source)"
|
||||
credential_role="$(resolve_credential_role)"
|
||||
if [ -z "$credential_role" ] && [ -n "${CI:-}" ] && [ "$credential_source" = "convex" ]; then
|
||||
credential_role="ci"
|
||||
fi
|
||||
|
||||
docker_env=(
|
||||
-e COREPACK_ENABLE_DOWNLOAD_PROMPT=0
|
||||
|
||||
@@ -65,10 +65,19 @@ interface NpmUpdateSummary {
|
||||
packageSpec: string;
|
||||
updateTarget: string;
|
||||
updateExpected: string;
|
||||
updateTargetBuildCommit: string;
|
||||
updateTargetPackageVersion: string;
|
||||
updateTargetTarball: string;
|
||||
provider: Provider;
|
||||
latestVersion: string;
|
||||
currentHead: string;
|
||||
runDir: string;
|
||||
slowestTiming?: {
|
||||
durationMs: number;
|
||||
label: string;
|
||||
phase: "fresh" | "fresh-target" | "update";
|
||||
};
|
||||
totalDurationMs: number;
|
||||
fresh: Record<Platform, string>;
|
||||
freshTarget: Record<Platform, string>;
|
||||
freshTargetSpec: string;
|
||||
@@ -184,6 +193,13 @@ function platformRecord<T>(value: T): Record<Platform, T> {
|
||||
return { linux: value, macos: value, windows: value };
|
||||
}
|
||||
|
||||
function formatDuration(durationMs: number): string {
|
||||
const seconds = Math.round(durationMs / 1000);
|
||||
const minutes = Math.floor(seconds / 60);
|
||||
const remainder = seconds % 60;
|
||||
return minutes > 0 ? `${minutes}m ${remainder}s` : `${remainder}s`;
|
||||
}
|
||||
|
||||
class NpmUpdateSmoke {
|
||||
private auth: ProviderAuth;
|
||||
private windowsAuth: ProviderAuth;
|
||||
@@ -197,8 +213,12 @@ class NpmUpdateSmoke {
|
||||
private server: HostServer | null = null;
|
||||
private artifact: PackageArtifact | null = null;
|
||||
private freshTargetSpec = "";
|
||||
private startedAt = Date.now();
|
||||
private updateTargetBuildCommit = "";
|
||||
private updateTargetEffective = "";
|
||||
private updateExpectedNeedle = "";
|
||||
private updateTargetPackageVersion = "";
|
||||
private updateTargetTarball = "";
|
||||
private linuxVm = linuxVmDefault;
|
||||
|
||||
private freshStatus = platformRecord("skip");
|
||||
@@ -221,6 +241,7 @@ class NpmUpdateSmoke {
|
||||
}
|
||||
|
||||
async run(): Promise<void> {
|
||||
this.startedAt = Date.now();
|
||||
this.runDir = await makeTempDir("openclaw-parallels-npm-update.");
|
||||
this.tgzDir = await makeTempDir("openclaw-parallels-npm-update-tgz.");
|
||||
try {
|
||||
@@ -394,12 +415,76 @@ class NpmUpdateSmoke {
|
||||
});
|
||||
this.updateTargetEffective = this.server.urlFor(this.artifact.path);
|
||||
this.updateExpectedNeedle = this.currentHeadShort;
|
||||
this.updateTargetPackageVersion = this.artifact.version ?? "";
|
||||
this.updateTargetBuildCommit =
|
||||
this.artifact.buildCommitShort ?? this.artifact.buildCommit ?? "";
|
||||
this.updateTargetTarball = this.updateTargetEffective;
|
||||
return;
|
||||
}
|
||||
this.updateTargetEffective = this.options.updateTarget;
|
||||
this.updateExpectedNeedle = this.isExplicitPackageTarget(this.updateTargetEffective)
|
||||
? ""
|
||||
: resolveOpenClawRegistryVersion(this.updateTargetEffective) || this.updateTargetEffective;
|
||||
const metadata = this.resolveRegistryPackageMetadata(this.updateTargetEffective);
|
||||
this.updateTargetPackageVersion = metadata.version;
|
||||
this.updateTargetBuildCommit =
|
||||
metadata.gitHead || this.resolvePackageBuildCommit(metadata.tarball);
|
||||
this.updateTargetTarball = metadata.tarball;
|
||||
}
|
||||
|
||||
private resolvePackageBuildCommit(tarball: string): string {
|
||||
if (!tarball) {
|
||||
return "";
|
||||
}
|
||||
const output = run(
|
||||
"bash",
|
||||
["-lc", `curl -fsSL ${shellQuote(tarball)} | tar -xzOf - package/dist/build-info.json`],
|
||||
{
|
||||
check: false,
|
||||
quiet: true,
|
||||
},
|
||||
).stdout.trim();
|
||||
if (!output) {
|
||||
return "";
|
||||
}
|
||||
try {
|
||||
const parsed = JSON.parse(output) as { commit?: string };
|
||||
return parsed.commit ? parsed.commit.slice(0, 7) : "";
|
||||
} catch {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
private resolveRegistryPackageMetadata(target: string): {
|
||||
gitHead: string;
|
||||
tarball: string;
|
||||
version: string;
|
||||
} {
|
||||
if (this.isExplicitPackageTarget(target)) {
|
||||
return { gitHead: "", tarball: "", version: "" };
|
||||
}
|
||||
const spec = target.startsWith("openclaw@") ? target : `openclaw@${target}`;
|
||||
const output = run("npm", ["view", spec, "version", "dist.tarball", "gitHead", "--json"], {
|
||||
check: false,
|
||||
quiet: true,
|
||||
}).stdout.trim();
|
||||
if (!output) {
|
||||
return { gitHead: "", tarball: "", version: "" };
|
||||
}
|
||||
try {
|
||||
const parsed = JSON.parse(output) as {
|
||||
dist?: { tarball?: string };
|
||||
gitHead?: string;
|
||||
version?: string;
|
||||
};
|
||||
return {
|
||||
gitHead: parsed.gitHead ?? "",
|
||||
tarball: parsed.dist?.tarball ?? "",
|
||||
version: parsed.version ?? "",
|
||||
};
|
||||
} catch {
|
||||
return { gitHead: "", tarball: "", version: "" };
|
||||
}
|
||||
}
|
||||
|
||||
private async runSameGuestUpdates(): Promise<void> {
|
||||
@@ -900,6 +985,7 @@ class NpmUpdateSmoke {
|
||||
}
|
||||
|
||||
private async writeSummary(): Promise<string> {
|
||||
const slowestTiming = this.timings.toSorted((a, b) => b.durationMs - a.durationMs)[0];
|
||||
const summary: NpmUpdateSummary = {
|
||||
currentHead: this.currentHeadShort,
|
||||
fresh: this.freshStatus,
|
||||
@@ -915,7 +1001,18 @@ class NpmUpdateSmoke {
|
||||
windows: { status: this.updateStatus.windows, version: this.updateVersion.windows },
|
||||
},
|
||||
timings: this.timings,
|
||||
slowestTiming: slowestTiming
|
||||
? {
|
||||
durationMs: slowestTiming.durationMs,
|
||||
label: slowestTiming.label,
|
||||
phase: slowestTiming.phase,
|
||||
}
|
||||
: undefined,
|
||||
totalDurationMs: Date.now() - this.startedAt,
|
||||
updateExpected: this.updateExpectedNeedle,
|
||||
updateTargetBuildCommit: this.updateTargetBuildCommit,
|
||||
updateTargetPackageVersion: this.updateTargetPackageVersion,
|
||||
updateTargetTarball: this.updateTargetTarball,
|
||||
updateTarget: this.updateTargetEffective,
|
||||
};
|
||||
const summaryPath = path.join(this.runDir, "summary.json");
|
||||
@@ -924,10 +1021,14 @@ class NpmUpdateSmoke {
|
||||
lines: [
|
||||
`- package spec: ${summary.packageSpec}`,
|
||||
`- update target: ${summary.updateTarget}`,
|
||||
`- update target package: ${summary.updateTargetPackageVersion || "unknown"}${summary.updateTargetBuildCommit ? ` (${summary.updateTargetBuildCommit})` : ""}`,
|
||||
`- update target tarball: ${summary.updateTargetTarball || "n/a"}`,
|
||||
`- update expected: ${summary.updateExpected}`,
|
||||
`- fresh: macOS=${summary.fresh.macos}, Windows=${summary.fresh.windows}, Linux=${summary.fresh.linux}`,
|
||||
`- update: macOS=${summary.update.macos.status} (${summary.update.macos.version}), Windows=${summary.update.windows.status} (${summary.update.windows.version}), Linux=${summary.update.linux.status} (${summary.update.linux.version})`,
|
||||
`- fresh target: ${summary.freshTargetSpec || "skip"} macOS=${summary.freshTarget.macos}, Windows=${summary.freshTarget.windows}, Linux=${summary.freshTarget.linux}`,
|
||||
`- wall clock: ${formatDuration(summary.totalDurationMs)}`,
|
||||
`- slowest phase: ${summary.slowestTiming ? `${summary.slowestTiming.phase}/${summary.slowestTiming.label} ${formatDuration(summary.slowestTiming.durationMs)}` : "n/a"}`,
|
||||
`- logs: ${summary.runDir}`,
|
||||
],
|
||||
summaryPath,
|
||||
|
||||
Reference in New Issue
Block a user