mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-21 10:16:44 +00:00
fix(ci): bound Telegram gateway diagnostics (#105645)
This commit is contained in:
@@ -2391,8 +2391,13 @@ jobs:
|
||||
NODE
|
||||
chmod 0600 "$redactor_script"
|
||||
|
||||
mapfile -t gateway_logs < <(
|
||||
sudo find "$RUNTIME_ROOT/tmp" -xdev -type f -name 'openclaw-*.log' -print | sort
|
||||
# The live suite can launch more than eight gateways. Keep the newest
|
||||
# bounded tails instead of failing diagnostics after a successful lane.
|
||||
mapfile -d '' -t gateway_logs < <(
|
||||
sudo find "$RUNTIME_ROOT/tmp" -xdev -type f -name 'openclaw-*.log' -printf '%T@\t%p\0' |
|
||||
sort -z -nr |
|
||||
sed -z -n '1,8p' |
|
||||
cut -z -f2-
|
||||
)
|
||||
((${#gateway_logs[@]} <= 8))
|
||||
if [[ "$RUN_LANE_OUTCOME" != "success" ]]; then
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { spawnSync } from "node:child_process";
|
||||
import { mkdirSync, readdirSync, readFileSync, writeFileSync } from "node:fs";
|
||||
import { mkdirSync, readdirSync, readFileSync, utimesSync, writeFileSync } from "node:fs";
|
||||
import { join } from "node:path";
|
||||
import { afterEach, describe, expect, it } from "vitest";
|
||||
import { parse } from "yaml";
|
||||
@@ -568,6 +568,12 @@ describe("release Telegram QA workflow", () => {
|
||||
expect(captureStep?.env?.RUN_LANE_OUTCOME).toBe("${{ steps.run_lane.outcome }}");
|
||||
expect(captureStep?.run).toContain('[[ "$RUN_LANE_OUTCOME" != "success" ]]');
|
||||
expect(captureStep?.run).toContain("((${#gateway_logs[@]} > 0))");
|
||||
expect(captureStep?.run).toContain("mapfile -d '' -t gateway_logs");
|
||||
expect(captureStep?.run).toContain("-printf '%T@\\t%p\\0'");
|
||||
expect(captureStep?.run).toContain("sort -z -nr");
|
||||
expect(captureStep?.run).toContain("sed -z -n '1,8p'");
|
||||
expect(captureStep?.run).toContain("cut -z -f2-");
|
||||
expect(captureStep?.run).toContain("((${#gateway_logs[@]} <= 8))");
|
||||
expect(captureStep?.run).toContain("((${#model_config_proofs[@]} > 0))");
|
||||
expect(captureStep?.run).toContain("-name 'openclaw-*.log'");
|
||||
expect(captureStep?.run).toContain(
|
||||
@@ -621,6 +627,43 @@ describe("release Telegram QA workflow", () => {
|
||||
expect(runStep?.run).toContain("::stop-commands::%s");
|
||||
});
|
||||
|
||||
it.runIf(process.platform === "linux")("keeps only the newest eight gateway logs", () => {
|
||||
const captureStep = workflowStep(
|
||||
workflowJob("run_telegram"),
|
||||
"Capture isolated Telegram runtime diagnostics",
|
||||
);
|
||||
const selectorSource = captureStep.run?.match(
|
||||
/mapfile -d '' -t gateway_logs < <\([\s\S]*?^\)$/mu,
|
||||
)?.[0];
|
||||
expect(selectorSource).toBeTruthy();
|
||||
|
||||
const workdir = tempDirs.make("openclaw-telegram-log-selector-");
|
||||
const runtimeRoot = join(workdir, "runtime");
|
||||
const fakeBin = join(workdir, "bin");
|
||||
mkdirSync(join(runtimeRoot, "tmp"), { recursive: true });
|
||||
mkdirSync(fakeBin);
|
||||
writeFileSync(join(fakeBin, "sudo"), '#!/bin/sh\nexec "$@"\n', { mode: 0o755 });
|
||||
|
||||
const logPaths = Array.from({ length: 12 }, (_, index) => {
|
||||
const logDir = join(runtimeRoot, "tmp", `gateway-${index}`);
|
||||
const logPath = join(logDir, `openclaw-${index}.log`);
|
||||
mkdirSync(logDir);
|
||||
writeFileSync(logPath, `${index}\n`);
|
||||
utimesSync(logPath, index + 1, index + 1);
|
||||
return logPath;
|
||||
});
|
||||
const result = spawnSync(
|
||||
"bash",
|
||||
["-c", `set -euo pipefail\n${selectorSource}\nprintf '%s\\0' "\${gateway_logs[@]}"`],
|
||||
{
|
||||
env: { ...process.env, PATH: `${fakeBin}:${process.env.PATH}`, RUNTIME_ROOT: runtimeRoot },
|
||||
},
|
||||
);
|
||||
expect(result.status, result.stderr.toString()).toBe(0);
|
||||
const selected = result.stdout.toString().split("\0").filter(Boolean);
|
||||
expect(selected).toEqual(logPaths.slice(4).reverse());
|
||||
});
|
||||
|
||||
it("retains only allowlisted verbose runtime diagnostics", () => {
|
||||
const captureStep = workflowStep(
|
||||
workflowJob("run_telegram"),
|
||||
|
||||
Reference in New Issue
Block a user