|
1 | 1 | // Telegram package Docker harness. |
2 | 2 | // Runs QA live transport code against the package candidate installed in Docker. |
3 | 3 | |
| 4 | +import { randomUUID } from "node:crypto"; |
4 | 5 | import fs from "node:fs/promises"; |
5 | 6 | import path from "node:path"; |
6 | 7 | import { pathToFileURL } from "node:url"; |
@@ -40,6 +41,17 @@ function resolveCredentialRole(env: NodeJS.ProcessEnv) {
|
40 | 41 | return env.OPENCLAW_NPM_TELEGRAM_CREDENTIAL_ROLE ?? env.OPENCLAW_QA_CREDENTIAL_ROLE; |
41 | 42 | } |
42 | 43 | |
| 44 | +function createRunId() { |
| 45 | +return `${Date.now().toString(36)}-${randomUUID().slice(0, 8)}`; |
| 46 | +} |
| 47 | + |
| 48 | +function resolvePackageTelegramOutputDir(env: NodeJS.ProcessEnv, repoRoot: string) { |
| 49 | +return ( |
| 50 | +env.OPENCLAW_NPM_TELEGRAM_OUTPUT_DIR?.trim() || |
| 51 | +path.join(repoRoot, ".artifacts", "qa-e2e", `npm-telegram-live-${createRunId()}`) |
| 52 | +); |
| 53 | +} |
| 54 | + |
43 | 55 | const DEFAULT_RTT_CHECK_ID = "telegram-mentioned-message-reply"; |
44 | 56 | |
45 | 57 | function resolveRttOptions(env: NodeJS.ProcessEnv, selectedScenarioIds: readonly string[] = []) { |
@@ -107,9 +119,7 @@ async function main() {
|
107 | 119 | const sutOpenClawCommand = await resolveTrustedOpenClawCommand(rawSutOpenClawCommand); |
108 | 120 | |
109 | 121 | const repoRoot = path.resolve(process.env.OPENCLAW_NPM_TELEGRAM_REPO_ROOT ?? process.cwd()); |
110 | | -const outputDir = |
111 | | -process.env.OPENCLAW_NPM_TELEGRAM_OUTPUT_DIR?.trim() || |
112 | | -path.join(repoRoot, ".artifacts", "qa-e2e", `npm-telegram-live-${Date.now().toString(36)}`); |
| 122 | +const outputDir = resolvePackageTelegramOutputDir(process.env, repoRoot); |
113 | 123 | const scenarioIds = splitCsv(process.env.OPENCLAW_NPM_TELEGRAM_SCENARIOS); |
114 | 124 | const result = await runTelegramQaLive({ |
115 | 125 | env: process.env, |
@@ -154,6 +164,7 @@ if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href)
|
154 | 164 | |
155 | 165 | export const testing = { |
156 | 166 | parsePositiveIntegerEnv, |
| 167 | + resolvePackageTelegramOutputDir, |
157 | 168 | resolveCredentialRole, |
158 | 169 | resolveCredentialSource, |
159 | 170 | resolveRttOptions, |
|