57 lines
2.3 KiB
TypeScript
57 lines
2.3 KiB
TypeScript
import { readFileSync } from "node:fs";
|
|
import { ciHelp } from "./src/ci";
|
|
|
|
function assertCondition(condition: unknown, message: string, detail: unknown = {}): void {
|
|
if (!condition) throw new Error(`${message}: ${JSON.stringify(detail)}`);
|
|
}
|
|
|
|
const help = JSON.stringify(ciHelp());
|
|
const source = readFileSync("scripts/src/ci.ts", "utf8");
|
|
|
|
assertCondition(
|
|
help.includes("ci logs <runId-or-pipelineRun> [--provider-id G14] [--tail-lines 80]"),
|
|
"ci help must expose bounded log tail control",
|
|
ciHelp(),
|
|
);
|
|
|
|
assertCondition(
|
|
help.includes('"defaultCapture":"ssh-stream"') || help.includes('"defaultCapture": "ssh-stream"'),
|
|
"ci help must declare ssh-stream as the default logs capture path",
|
|
ciHelp(),
|
|
);
|
|
|
|
assertCondition(
|
|
source.includes("interface CiLogsOptions")
|
|
&& source.includes("function ciLogsOptions(args: string[]): CiLogsOptions")
|
|
&& source.includes("ci logs --tail-lines must be an integer between 1 and 2000")
|
|
&& source.includes('capture: args.includes("--dispatch-task") ? "dispatch-task" : "ssh-stream"'),
|
|
"ci logs must parse bounded tail options",
|
|
);
|
|
|
|
assertCondition(
|
|
source.includes("function extractCiLogConditionHints(value: string): string[]")
|
|
&& source.includes("function extractCiLogFailureHints(value: string): string[]")
|
|
&& source.includes("conditionHints")
|
|
&& source.includes("failureHints"),
|
|
"ci logs must expose condition and failure hints without requiring raw output",
|
|
);
|
|
|
|
assertCondition(
|
|
source.includes("runSshCommandCapture(config, `${target.providerId}:k3s`, [\"script\"], script)")
|
|
&& source.includes("runRemoteKubectl(script, 60_000, 45_000, target)")
|
|
&& source.includes("kubectl get pipelinerun/${shellQuote(name)} -n unidesk-ci -o jsonpath")
|
|
&& source.includes("kubectl logs -n unidesk-ci \"$pod\" --all-containers=true --tail=\"$tail_lines\""),
|
|
"ci logs must default to SSH stream capture while retaining dispatch-task fallback for Tekton conditions and bounded pod log tails",
|
|
);
|
|
|
|
console.log(JSON.stringify({
|
|
ok: true,
|
|
checks: [
|
|
"ci logs help exposes bounded tail control",
|
|
"ci logs help declares ssh-stream default capture",
|
|
"ci logs parses bounded tail options",
|
|
"ci logs exposes condition and failure hints",
|
|
"ci logs defaults to SSH stream capture and retains dispatch-task fallback",
|
|
],
|
|
}));
|