mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-12 21:53:00 -06:00
fe261b0f59
* chore(types): add declaration files for scripts/lib and scripts/e2e modules
* chore(types): add declaration files for top-level script modules (a-m)
* chore(types): add declaration files for top-level script modules (n-z)
* test: use a non-secret-shaped gateway token fixture
* test: type ci workflow guard helpers for the root test lane
* chore(tooling): typecheck root test/** with a dedicated tsgo lane
- test/tsconfig/tsconfig.test.root.json: root-test program (strict unused checks,
fixtures excluded; two Docker E2E clients that import built dist/** stay out,
same rationale as the scripts/e2e exclusion in tsconfig.scripts.json)
- tsgo:test:root wired into tsgo:test, check:test-types, scripts/check.mjs, and
the ci.yml test-types shard, mirroring the tsgo:scripts lane (#104348)
- changed-lane routing: test/**/*.ts (excluding fixtures) and the lane tsconfig
now trigger 'typecheck test root' in check:changed; previously test/ paths ran
lint only, so harness type errors surfaced first in CI (#104287 envDir case)
- burn down all 1071 latent type errors in the program: precise param/local
types across test/scripts, test/vitest, test/e2e, and transitive scripts/e2e
program members; 205 sibling .d.mts declaration files for imported .mjs
modules (committed separately); zero any, zero ts-expect-error
- resolve the pre-existing testing star-export ambiguity in
scripts/e2e/parallels/common.ts with an explicit re-export
Closes #104388
* chore(types): correct declaration fidelity per structured review
- re-derive 51 .d.mts files from implementation data flow instead of
initializers: fix a wrong never return (runTestProjectsDelegation returns
the child), add encoding-sensitive exec/spawn overloads (plain-gh), restore
the full release profile union, make parsed paths string | null, add missing
parseArgs fields via help/non-help unions, add a missing sibling declaration
(budget-number-args), drop 15 unused lint directives
- precise install-record/tuple typing removes the type-aware oxlint
regressions the first declarations caused in scripts/e2e implementations
- route .mts declaration edits under test/ to the testRoot lane and reference
the test-root project from tsconfig.projects.json so tsgo:all covers it
(closes both review findings against the lane wiring)
* chore(scripts): keep telegram runner dist typing structural for the boundary guard
* chore(types): declare runtime pack and gateway readiness exports added on main
* test: pin the importTargetPlan form of the plugin-contract plan import
The guard expectation still referenced the raw await import( form that
7ae5996bb3 (#103975) replaced with the importTargetPlan fallback helper;
the assertion fails on current main.
722 lines
23 KiB
TypeScript
722 lines
23 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import {
|
|
collectHostedGateEvidence as collectHostedGateEvidenceRaw,
|
|
HOSTED_GATE_MAX_AGE_HOURS,
|
|
parseArgs,
|
|
parseWorkflowRunPage,
|
|
SCHEDULED_HOSTED_WORKFLOWS,
|
|
workflowRunQueryPaths,
|
|
workflowRunPageCount,
|
|
} from "../../scripts/verify-pr-hosted-gates.mjs";
|
|
|
|
const sha = "773ffd87a1e1e34451ad6e38fda37380c2569a50";
|
|
const pr = 100606;
|
|
const nowMs = Date.parse("2026-06-17T10:55:00Z");
|
|
const BUILD_ARTIFACTS_WORKFLOW = "Blacksmith Build Artifacts Testbox";
|
|
const requiredCliArgs = [
|
|
"--repo",
|
|
"openclaw/openclaw",
|
|
"--sha",
|
|
sha,
|
|
"--pr",
|
|
String(pr),
|
|
"--output",
|
|
".local/gates-hosted-checks.json",
|
|
];
|
|
|
|
function successfulRun(name: string, id: number, updatedAt: string) {
|
|
return {
|
|
id,
|
|
name,
|
|
event: "pull_request",
|
|
status: "completed",
|
|
conclusion: "success",
|
|
head_sha: sha,
|
|
head_branch: "codex/clean-expanded-tool-calls",
|
|
head_repository: { full_name: "openclaw/openclaw" },
|
|
pull_requests: [{ number: pr }],
|
|
path: ".github/workflows/ci.yml",
|
|
created_at: "2026-06-17T10:46:24Z",
|
|
updated_at: updatedAt,
|
|
html_url: `https://github.com/openclaw/openclaw/actions/runs/${id}`,
|
|
};
|
|
}
|
|
|
|
function collectHostedGateEvidence(
|
|
options: Omit<Parameters<typeof collectHostedGateEvidenceRaw>[0], "nowMs" | "pr">,
|
|
) {
|
|
return collectHostedGateEvidenceRaw({ nowMs, pr, ...options });
|
|
}
|
|
|
|
describe("verify-pr-hosted-gates", () => {
|
|
it("requires the latest scheduled workflow run to pass", () => {
|
|
const evidence = collectHostedGateEvidence({
|
|
sha,
|
|
workflowRuns: [
|
|
successfulRun("CI", 1, "2026-06-17T10:47:00Z"),
|
|
{
|
|
...successfulRun("Blacksmith Testbox", 2, "2026-06-17T10:47:30Z"),
|
|
event: "workflow_dispatch",
|
|
},
|
|
successfulRun("Blacksmith Testbox", 3, "2026-06-17T10:48:00Z"),
|
|
successfulRun("Blacksmith ARM Testbox", 4, "2026-06-17T10:49:00Z"),
|
|
successfulRun("Blacksmith Build Artifacts Testbox", 5, "2026-06-17T10:50:00Z"),
|
|
successfulRun("Workflow Sanity", 6, "2026-06-17T10:51:00Z"),
|
|
],
|
|
});
|
|
|
|
expect(evidence).toEqual({
|
|
headSha: sha,
|
|
workflows: [
|
|
expect.objectContaining({ name: "CI", id: 1 }),
|
|
expect.objectContaining({ name: "Blacksmith Testbox", id: 3 }),
|
|
expect.objectContaining({ name: "Blacksmith ARM Testbox", id: 4 }),
|
|
expect.objectContaining({ name: "Blacksmith Build Artifacts Testbox", id: 5 }),
|
|
expect.objectContaining({ name: "Workflow Sanity", id: 6 }),
|
|
],
|
|
});
|
|
});
|
|
|
|
it("rejects a failed rerun of a workflow that was scheduled for the exact head", () => {
|
|
const workflowRuns = ["CI", ...SCHEDULED_HOSTED_WORKFLOWS].map((name, index) =>
|
|
successfulRun(name, index + 1, `2026-06-17T10:4${index}:00Z`),
|
|
);
|
|
workflowRuns[2] = {
|
|
...workflowRuns[2],
|
|
conclusion: "failure",
|
|
updated_at: "2026-06-17T10:50:00Z",
|
|
};
|
|
|
|
expect(() => collectHostedGateEvidence({ sha, workflowRuns })).toThrow(
|
|
"Missing successful Blacksmith ARM Testbox workflow",
|
|
);
|
|
});
|
|
|
|
it("accepts a non-docs PR when CI is the only scheduled authoritative workflow", () => {
|
|
expect(
|
|
collectHostedGateEvidence({
|
|
sha,
|
|
workflowRuns: [successfulRun("CI", 1, "2026-06-17T10:47:00Z")],
|
|
}),
|
|
).toEqual({
|
|
headSha: sha,
|
|
workflows: [expect.objectContaining({ name: "CI", id: 1 })],
|
|
});
|
|
});
|
|
|
|
it("accepts recent green evidence from the recorded pre-rebase head while current CI is pending", () => {
|
|
const previousSha = "8d86c44c6144f8f726a460914cddb8c9c201f119";
|
|
const evidence = collectHostedGateEvidence({
|
|
sha,
|
|
recentSha: previousSha,
|
|
workflowRuns: [
|
|
{
|
|
...successfulRun("CI", 1, "2026-06-17T10:50:00Z"),
|
|
head_sha: previousSha,
|
|
},
|
|
{
|
|
...successfulRun("CI", 2, "2026-06-17T10:54:00Z"),
|
|
status: "in_progress",
|
|
conclusion: null,
|
|
},
|
|
],
|
|
});
|
|
|
|
expect(evidence).toEqual({
|
|
headSha: sha,
|
|
evidenceHeadSha: previousSha,
|
|
workflows: [expect.objectContaining({ name: "CI", id: 1, headSha: previousSha })],
|
|
});
|
|
});
|
|
|
|
it("accepts recent green evidence from an earlier head of the same PR", () => {
|
|
const previousSha = "8d86c44c6144f8f726a460914cddb8c9c201f119";
|
|
const evidence = collectHostedGateEvidence({
|
|
sha,
|
|
workflowRuns: [
|
|
{
|
|
...successfulRun("CI", 1, "2026-06-17T10:50:00Z"),
|
|
head_sha: previousSha,
|
|
},
|
|
{
|
|
...successfulRun("CI", 2, "2026-06-17T10:54:00Z"),
|
|
status: "in_progress",
|
|
conclusion: null,
|
|
},
|
|
],
|
|
});
|
|
|
|
expect(evidence).toEqual({
|
|
headSha: sha,
|
|
evidenceHeadSha: previousSha,
|
|
workflows: [expect.objectContaining({ name: "CI", id: 1, headSha: previousSha })],
|
|
});
|
|
});
|
|
|
|
it("requires recent evidence for scheduled gates observed on the target head", () => {
|
|
const previousSha = "8d86c44c6144f8f726a460914cddb8c9c201f119";
|
|
const targetArmRun = {
|
|
...successfulRun("Blacksmith ARM Testbox", 3, "2026-06-17T10:54:00Z"),
|
|
status: "queued",
|
|
conclusion: null,
|
|
};
|
|
const workflowRuns = [
|
|
{
|
|
...successfulRun("CI", 1, "2026-06-17T10:50:00Z"),
|
|
head_sha: previousSha,
|
|
},
|
|
{
|
|
...successfulRun("CI", 2, "2026-06-17T10:54:00Z"),
|
|
status: "in_progress",
|
|
conclusion: null,
|
|
},
|
|
targetArmRun,
|
|
];
|
|
|
|
expect(() => collectHostedGateEvidence({ sha, recentSha: previousSha, workflowRuns })).toThrow(
|
|
`Missing successful recent Blacksmith ARM Testbox workflow for ${previousSha}`,
|
|
);
|
|
|
|
const evidence = collectHostedGateEvidence({
|
|
sha,
|
|
recentSha: previousSha,
|
|
workflowRuns: [
|
|
...workflowRuns,
|
|
{
|
|
...successfulRun("Blacksmith ARM Testbox", 4, "2026-06-17T10:51:00Z"),
|
|
head_sha: previousSha,
|
|
},
|
|
],
|
|
});
|
|
expect(evidence.workflows).toEqual([
|
|
expect.objectContaining({ name: "CI", headSha: previousSha }),
|
|
expect.objectContaining({ name: "Blacksmith ARM Testbox", headSha: previousSha }),
|
|
]);
|
|
});
|
|
|
|
it.each(["failure", "cancelled", "skipped"])(
|
|
"does not reuse older green evidence after a current-head %s run",
|
|
(conclusion) => {
|
|
const previousSha = "8d86c44c6144f8f726a460914cddb8c9c201f119";
|
|
expect(() =>
|
|
collectHostedGateEvidence({
|
|
sha,
|
|
recentSha: previousSha,
|
|
workflowRuns: [
|
|
{
|
|
...successfulRun("CI", 1, "2026-06-17T10:50:00Z"),
|
|
head_sha: previousSha,
|
|
},
|
|
{
|
|
...successfulRun("CI", 2, "2026-06-17T10:54:00Z"),
|
|
conclusion,
|
|
},
|
|
],
|
|
}),
|
|
).toThrow(`Missing successful CI workflow for ${sha}`);
|
|
},
|
|
);
|
|
|
|
it("does not reuse green evidence from another PR", () => {
|
|
const previousSha = "8d86c44c6144f8f726a460914cddb8c9c201f119";
|
|
expect(() =>
|
|
collectHostedGateEvidence({
|
|
sha,
|
|
workflowRuns: [
|
|
{
|
|
...successfulRun("CI", 1, "2026-06-17T10:50:00Z"),
|
|
head_sha: previousSha,
|
|
pull_requests: [{ number: pr + 1 }],
|
|
},
|
|
{
|
|
...successfulRun("CI", 2, "2026-06-17T10:54:00Z"),
|
|
status: "in_progress",
|
|
conclusion: null,
|
|
},
|
|
],
|
|
}),
|
|
).toThrow(`Missing successful CI workflow for ${sha}`);
|
|
});
|
|
|
|
it("requires the complete recent gate cohort from the recorded head", () => {
|
|
const previousSha = "8d86c44c6144f8f726a460914cddb8c9c201f119";
|
|
expect(() =>
|
|
collectHostedGateEvidence({
|
|
sha,
|
|
recentSha: previousSha,
|
|
workflowRuns: [
|
|
{
|
|
...successfulRun("CI", 1, "2026-06-17T10:50:00Z"),
|
|
head_sha: previousSha,
|
|
},
|
|
{
|
|
...successfulRun("Blacksmith ARM Testbox", 2, "2026-06-17T10:51:00Z"),
|
|
head_sha: previousSha,
|
|
conclusion: "failure",
|
|
},
|
|
{
|
|
...successfulRun("CI", 3, "2026-06-17T10:54:00Z"),
|
|
status: "in_progress",
|
|
conclusion: null,
|
|
},
|
|
],
|
|
}),
|
|
).toThrow(`Missing successful recent Blacksmith ARM Testbox workflow for ${previousSha}`);
|
|
});
|
|
|
|
it("does not drop an applicable scheduled gate when its success is stale", () => {
|
|
const previousSha = "8d86c44c6144f8f726a460914cddb8c9c201f119";
|
|
expect(() =>
|
|
collectHostedGateEvidence({
|
|
sha,
|
|
recentSha: previousSha,
|
|
workflowRuns: [
|
|
{
|
|
...successfulRun("CI", 1, "2026-06-17T10:50:00Z"),
|
|
head_sha: previousSha,
|
|
},
|
|
{
|
|
...successfulRun("Blacksmith ARM Testbox", 2, "2026-06-16T10:54:59Z"),
|
|
head_sha: previousSha,
|
|
},
|
|
{
|
|
...successfulRun("CI", 3, "2026-06-17T10:54:00Z"),
|
|
status: "in_progress",
|
|
conclusion: null,
|
|
},
|
|
],
|
|
}),
|
|
).toThrow(`Missing successful recent Blacksmith ARM Testbox workflow for ${previousSha}`);
|
|
});
|
|
|
|
it("does not reuse pre-rebase green evidence after a failed current-head manual gate", () => {
|
|
const previousSha = "8d86c44c6144f8f726a460914cddb8c9c201f119";
|
|
expect(() =>
|
|
collectHostedGateEvidence({
|
|
sha,
|
|
recentSha: previousSha,
|
|
workflowRuns: [
|
|
{
|
|
...successfulRun("CI", 1, "2026-06-17T10:50:00Z"),
|
|
head_sha: previousSha,
|
|
},
|
|
{
|
|
...successfulRun("CI", 2, "2026-06-17T10:53:00Z"),
|
|
status: "in_progress",
|
|
conclusion: null,
|
|
},
|
|
{
|
|
...successfulRun(`CI release gate ${sha}`, 3, "2026-06-17T10:54:00Z"),
|
|
event: "workflow_dispatch",
|
|
display_title: `CI release gate ${sha}`,
|
|
conclusion: "failure",
|
|
},
|
|
],
|
|
}),
|
|
).toThrow(`Missing successful CI workflow for ${sha}`);
|
|
});
|
|
|
|
it("rejects stale or unrecorded fallback heads", () => {
|
|
const previousSha = "8d86c44c6144f8f726a460914cddb8c9c201f119";
|
|
const unrelatedSha = "ec159b0222cf4fa21b318317a7c5a29d52c846d2";
|
|
const currentPending = {
|
|
...successfulRun("CI", 2, "2026-06-17T10:54:00Z"),
|
|
status: "in_progress",
|
|
conclusion: null,
|
|
};
|
|
const staleRun = {
|
|
...successfulRun("CI", 3, "2026-06-16T10:54:59Z"),
|
|
head_sha: previousSha,
|
|
};
|
|
expect(() =>
|
|
collectHostedGateEvidence({
|
|
sha,
|
|
recentSha: previousSha,
|
|
workflowRuns: [staleRun, currentPending],
|
|
}),
|
|
).toThrow(`Missing successful recent CI workflow for ${previousSha}`);
|
|
|
|
const recentUnrelatedRun = {
|
|
...successfulRun("CI", 4, "2026-06-17T10:50:00Z"),
|
|
head_sha: unrelatedSha,
|
|
pull_requests: [{ number: pr + 1 }],
|
|
};
|
|
expect(() =>
|
|
collectHostedGateEvidence({
|
|
sha,
|
|
recentSha: previousSha,
|
|
workflowRuns: [recentUnrelatedRun, currentPending],
|
|
}),
|
|
).toThrow(`Missing successful recent CI workflow for ${previousSha}`);
|
|
expect(() =>
|
|
collectHostedGateEvidence({
|
|
sha,
|
|
workflowRuns: [{ ...recentUnrelatedRun, head_sha: previousSha }, currentPending],
|
|
}),
|
|
).toThrow(`Missing successful CI workflow for ${sha}`);
|
|
});
|
|
|
|
it("allows a later scheduled success to clear an earlier current-head failure", () => {
|
|
expect(
|
|
collectHostedGateEvidence({
|
|
sha,
|
|
workflowRuns: [
|
|
{
|
|
...successfulRun("CI", 1, "2026-06-17T10:50:00Z"),
|
|
conclusion: "failure",
|
|
},
|
|
successfulRun("CI", 2, "2026-06-17T10:52:00Z"),
|
|
],
|
|
}),
|
|
).toEqual({
|
|
headSha: sha,
|
|
workflows: [expect.objectContaining({ name: "CI", id: 2, headSha: sha })],
|
|
});
|
|
});
|
|
|
|
it("does not let a late failure from an obsolete head override a green target head", () => {
|
|
const previousSha = "8d86c44c6144f8f726a460914cddb8c9c201f119";
|
|
expect(
|
|
collectHostedGateEvidence({
|
|
sha,
|
|
workflowRuns: [
|
|
successfulRun("CI", 1, "2026-06-17T10:50:00Z"),
|
|
{
|
|
...successfulRun("CI", 2, "2026-06-17T10:54:00Z"),
|
|
head_sha: previousSha,
|
|
conclusion: "failure",
|
|
},
|
|
],
|
|
}),
|
|
).toEqual({
|
|
headSha: sha,
|
|
workflows: [expect.objectContaining({ name: "CI", id: 1, headSha: sha })],
|
|
});
|
|
});
|
|
|
|
it("uses the latest CI run when an older duplicate was cancelled", () => {
|
|
expect(
|
|
collectHostedGateEvidence({
|
|
sha,
|
|
workflowRuns: [
|
|
{
|
|
...successfulRun("CI", 1, "2026-06-17T10:47:00Z"),
|
|
conclusion: "cancelled",
|
|
},
|
|
successfulRun("CI", 2, "2026-06-17T10:48:00Z"),
|
|
],
|
|
}),
|
|
).toEqual({
|
|
headSha: sha,
|
|
workflows: [expect.objectContaining({ name: "CI", id: 2 })],
|
|
});
|
|
});
|
|
|
|
it("accepts the explicit exact-SHA manual CI release gate", () => {
|
|
expect(
|
|
collectHostedGateEvidence({
|
|
sha,
|
|
workflowRuns: [
|
|
{
|
|
...successfulRun(`CI release gate ${sha}`, 1, "2026-06-17T10:47:00Z"),
|
|
event: "workflow_dispatch",
|
|
path: ".github/workflows/ci.yml@refs/heads/release-controls",
|
|
display_title: `CI release gate ${sha}`,
|
|
},
|
|
],
|
|
}),
|
|
).toEqual({
|
|
headSha: sha,
|
|
workflows: [expect.objectContaining({ name: `CI release gate ${sha}`, id: 1 })],
|
|
});
|
|
});
|
|
|
|
it("prefers the exact release-gate fallback while scheduled CI remains queued", () => {
|
|
expect(
|
|
collectHostedGateEvidence({
|
|
sha,
|
|
workflowRuns: [
|
|
{
|
|
...successfulRun("CI", 1, "2026-06-17T10:47:00Z"),
|
|
status: "queued",
|
|
conclusion: null,
|
|
updated_at: "2026-06-17T10:50:00Z",
|
|
},
|
|
{
|
|
...successfulRun(`CI release gate ${sha}`, 2, "2026-06-17T10:49:00Z"),
|
|
event: "workflow_dispatch",
|
|
display_title: `CI release gate ${sha}`,
|
|
},
|
|
],
|
|
}),
|
|
).toEqual({
|
|
headSha: sha,
|
|
workflows: [expect.objectContaining({ name: `CI release gate ${sha}`, id: 2 })],
|
|
});
|
|
});
|
|
|
|
it("rejects a completed scheduled CI failure even when a fallback passed", () => {
|
|
expect(() =>
|
|
collectHostedGateEvidence({
|
|
sha,
|
|
workflowRuns: [
|
|
{
|
|
...successfulRun("CI", 1, "2026-06-17T10:50:00Z"),
|
|
conclusion: "failure",
|
|
},
|
|
{
|
|
...successfulRun(`CI release gate ${sha}`, 2, "2026-06-17T10:49:00Z"),
|
|
event: "workflow_dispatch",
|
|
display_title: `CI release gate ${sha}`,
|
|
},
|
|
],
|
|
}),
|
|
).toThrow("Missing successful CI workflow");
|
|
});
|
|
|
|
it("does not mask a failed CI run with a queued rerun and release-gate fallback", () => {
|
|
expect(() =>
|
|
collectHostedGateEvidence({
|
|
sha,
|
|
workflowRuns: [
|
|
{
|
|
...successfulRun("CI", 1, "2026-06-17T10:47:00Z"),
|
|
conclusion: "failure",
|
|
},
|
|
{
|
|
...successfulRun("CI", 2, "2026-06-17T10:48:00Z"),
|
|
status: "in_progress",
|
|
conclusion: null,
|
|
},
|
|
{
|
|
...successfulRun(`CI release gate ${sha}`, 3, "2026-06-17T10:49:00Z"),
|
|
event: "workflow_dispatch",
|
|
display_title: `CI release gate ${sha}`,
|
|
},
|
|
],
|
|
}),
|
|
).toThrow("Missing successful CI workflow");
|
|
});
|
|
|
|
it("covers a queued artifact Testbox only with a completed exact CI fallback", () => {
|
|
expect(
|
|
collectHostedGateEvidence({
|
|
sha,
|
|
workflowRuns: [
|
|
{
|
|
...successfulRun(`CI release gate ${sha}`, 1, "2026-06-17T10:49:00Z"),
|
|
event: "workflow_dispatch",
|
|
display_title: `CI release gate ${sha}`,
|
|
},
|
|
successfulRun("CI", 3, "2026-06-17T10:51:00Z"),
|
|
successfulRun("Blacksmith Testbox", 4, "2026-06-17T10:52:00Z"),
|
|
successfulRun("Blacksmith ARM Testbox", 5, "2026-06-17T10:53:00Z"),
|
|
successfulRun("Workflow Sanity", 6, "2026-06-17T10:54:00Z"),
|
|
{
|
|
...successfulRun(BUILD_ARTIFACTS_WORKFLOW, 2, "2026-06-17T10:50:00Z"),
|
|
status: "queued",
|
|
conclusion: null,
|
|
},
|
|
],
|
|
}),
|
|
).toEqual({
|
|
headSha: sha,
|
|
workflows: [
|
|
expect.objectContaining({ name: "CI", id: 3 }),
|
|
expect.objectContaining({ name: "Blacksmith Testbox", id: 4 }),
|
|
expect.objectContaining({ name: "Blacksmith ARM Testbox", id: 5 }),
|
|
expect.objectContaining({ name: "Workflow Sanity", id: 6 }),
|
|
],
|
|
fallbackCoveredWorkflows: [
|
|
{
|
|
name: BUILD_ARTIFACTS_WORKFLOW,
|
|
coveredBy: "CI release gate",
|
|
reason: "scheduled workflow is queued",
|
|
},
|
|
],
|
|
});
|
|
});
|
|
|
|
it("does not cover queued artifacts until all supporting workflow gates pass", () => {
|
|
expect(() =>
|
|
collectHostedGateEvidence({
|
|
sha,
|
|
workflowRuns: [
|
|
{
|
|
...successfulRun(`CI release gate ${sha}`, 1, "2026-06-17T10:49:00Z"),
|
|
event: "workflow_dispatch",
|
|
display_title: `CI release gate ${sha}`,
|
|
},
|
|
{
|
|
...successfulRun(BUILD_ARTIFACTS_WORKFLOW, 2, "2026-06-17T10:50:00Z"),
|
|
status: "queued",
|
|
conclusion: null,
|
|
},
|
|
],
|
|
}),
|
|
).toThrow("Missing successful Blacksmith Build Artifacts Testbox workflow");
|
|
});
|
|
|
|
it("keeps active or terminal non-successful artifact Testboxes blocking", () => {
|
|
const ciFallback = {
|
|
...successfulRun(`CI release gate ${sha}`, 1, "2026-06-17T10:49:00Z"),
|
|
event: "workflow_dispatch",
|
|
display_title: `CI release gate ${sha}`,
|
|
};
|
|
|
|
for (const artifactRun of [
|
|
{
|
|
...successfulRun(BUILD_ARTIFACTS_WORKFLOW, 2, "2026-06-17T10:50:00Z"),
|
|
status: "in_progress",
|
|
conclusion: null,
|
|
},
|
|
{
|
|
...successfulRun(BUILD_ARTIFACTS_WORKFLOW, 3, "2026-06-17T10:51:00Z"),
|
|
conclusion: "failure",
|
|
},
|
|
]) {
|
|
expect(() =>
|
|
collectHostedGateEvidence({
|
|
sha,
|
|
workflowRuns: [ciFallback, artifactRun],
|
|
}),
|
|
).toThrow("Missing successful Blacksmith Build Artifacts Testbox workflow");
|
|
}
|
|
|
|
expect(() =>
|
|
collectHostedGateEvidence({
|
|
sha,
|
|
workflowRuns: [
|
|
ciFallback,
|
|
{
|
|
...successfulRun(BUILD_ARTIFACTS_WORKFLOW, 4, "2026-06-17T10:52:00Z"),
|
|
conclusion: "failure",
|
|
},
|
|
{
|
|
...successfulRun(BUILD_ARTIFACTS_WORKFLOW, 5, "2026-06-17T10:53:00Z"),
|
|
status: "queued",
|
|
conclusion: null,
|
|
},
|
|
],
|
|
}),
|
|
).toThrow("Missing successful Blacksmith Build Artifacts Testbox workflow");
|
|
});
|
|
|
|
it("rejects an unmarked manual CI run", () => {
|
|
expect(() =>
|
|
collectHostedGateEvidence({
|
|
sha,
|
|
workflowRuns: [
|
|
{
|
|
...successfulRun(`CI release gate ${sha}`, 1, "2026-06-17T10:47:00Z"),
|
|
event: "workflow_dispatch",
|
|
display_title: "CI",
|
|
},
|
|
],
|
|
}),
|
|
).toThrow("Missing successful CI workflow");
|
|
});
|
|
|
|
it("rejects a manual release-gate title from another workflow", () => {
|
|
expect(() =>
|
|
collectHostedGateEvidence({
|
|
sha,
|
|
workflowRuns: [
|
|
{
|
|
...successfulRun(`CI release gate ${sha}`, 1, "2026-06-17T10:47:00Z"),
|
|
event: "workflow_dispatch",
|
|
path: ".github/workflows/something-else.yml",
|
|
display_title: `CI release gate ${sha}`,
|
|
},
|
|
],
|
|
}),
|
|
).toThrow("Missing successful CI workflow");
|
|
});
|
|
|
|
it("requires CI for docs unless the head changes only CHANGELOG.md", () => {
|
|
expect(() => collectHostedGateEvidence({ sha, workflowRuns: [] })).toThrow(
|
|
"Missing successful CI workflow",
|
|
);
|
|
expect(collectHostedGateEvidence({ sha, workflowRuns: [], changelogOnly: true })).toEqual({
|
|
headSha: sha,
|
|
workflows: [],
|
|
});
|
|
});
|
|
|
|
it("parses required CLI arguments", () => {
|
|
expect(parseArgs(requiredCliArgs)).toEqual({
|
|
repo: "openclaw/openclaw",
|
|
sha,
|
|
pr,
|
|
recentSha: "",
|
|
output: ".local/gates-hosted-checks.json",
|
|
changelogOnly: false,
|
|
});
|
|
expect(() => parseArgs(["--repo", "openclaw/openclaw"])).toThrow("Usage:");
|
|
expect(() => parseArgs(requiredCliArgs.with(1, "-h"))).toThrow("Expected --repo <value>.");
|
|
expect(() => parseArgs(requiredCliArgs.with(3, "-h"))).toThrow("Expected --sha <value>.");
|
|
expect(() => parseArgs(requiredCliArgs.with(5, "zero"))).toThrow(
|
|
"Expected --pr <positive-integer>.",
|
|
);
|
|
expect(() => parseArgs(requiredCliArgs.with(requiredCliArgs.length - 1, "-h"))).toThrow(
|
|
"Expected --output <value>.",
|
|
);
|
|
});
|
|
|
|
it("rejects duplicate hosted gate verifier CLI arguments", () => {
|
|
const duplicateCases = [
|
|
["--repo", [...requiredCliArgs, "--repo", "fork/openclaw"]],
|
|
["--sha", [...requiredCliArgs, "--sha", "other-sha"]],
|
|
["--pr", [...requiredCliArgs, "--pr", "7"]],
|
|
["--recent-sha", [...requiredCliArgs, "--recent-sha", "one", "--recent-sha", "other"]],
|
|
["--output", [...requiredCliArgs, "--output", "two.json"]],
|
|
["--changelog-only", [...requiredCliArgs, "--changelog-only", "--changelog-only"]],
|
|
] satisfies Array<[string, string[]]>;
|
|
|
|
for (const [flag, args] of duplicateCases) {
|
|
expect(() => parseArgs(args), flag).toThrow(`${flag} was provided more than once.`);
|
|
}
|
|
});
|
|
|
|
it("accepts one workflow-runs page emitted through a colorizing GitHub CLI shim", () => {
|
|
expect(
|
|
parseWorkflowRunPage(
|
|
'\u001B[1;37m{"total_count":101,"workflow_runs":[{"id":1,"name":"CI"}]}\u001B[0m',
|
|
),
|
|
).toEqual({ totalCount: 101, workflowRuns: [{ id: 1, name: "CI" }] });
|
|
});
|
|
|
|
it("queries the target and recorded pre-rebase SHAs", () => {
|
|
const previousSha = "8d86c44c6144f8f726a460914cddb8c9c201f119";
|
|
expect(
|
|
workflowRunQueryPaths("openclaw/openclaw", {
|
|
sha,
|
|
recentSha: previousSha,
|
|
}),
|
|
).toEqual([
|
|
`repos/openclaw/openclaw/actions/runs?head_sha=${sha}&per_page=100&page=1`,
|
|
`repos/openclaw/openclaw/actions/runs?head_sha=${previousSha}&per_page=100&page=1`,
|
|
]);
|
|
expect(HOSTED_GATE_MAX_AGE_HOURS).toBe(12);
|
|
});
|
|
|
|
it("queries recent pull-request runs for the head branch", () => {
|
|
expect(
|
|
workflowRunQueryPaths("openclaw/openclaw", {
|
|
sha,
|
|
recentSha: "",
|
|
headBranch: "codex/relax hosted gates",
|
|
}),
|
|
).toEqual([
|
|
`repos/openclaw/openclaw/actions/runs?head_sha=${sha}&per_page=100&page=1`,
|
|
"repos/openclaw/openclaw/actions/runs?branch=codex%2Frelax%20hosted%20gates&event=pull_request&per_page=100&page=1",
|
|
]);
|
|
});
|
|
|
|
it("bounds workflow-run pagination to GitHub's search result limit", () => {
|
|
expect(workflowRunPageCount(0)).toBe(0);
|
|
expect(workflowRunPageCount(101)).toBe(2);
|
|
expect(workflowRunPageCount(10_000)).toBe(10);
|
|
});
|
|
});
|