mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 15:40:44 +00:00
chore: add positive proof labels (#78117)
This commit is contained in:
@@ -5,6 +5,10 @@ import {
|
||||
managedLabelSpecs,
|
||||
runBarnacleAutoResponse,
|
||||
} from "../../scripts/github/barnacle-auto-response.mjs";
|
||||
import {
|
||||
PROOF_SUFFICIENT_LABEL,
|
||||
PROOF_SUPPLIED_LABEL,
|
||||
} from "../../scripts/github/real-behavior-proof-policy.mjs";
|
||||
|
||||
const blankTemplateBody = [
|
||||
"## Summary",
|
||||
@@ -227,6 +231,8 @@ describe("barnacle-auto-response", () => {
|
||||
expect(managedLabelSpecs["r: false-positive"].description).toContain("false positive");
|
||||
expect(managedLabelSpecs["r: third-party-extension"].description).toContain("ClawHub");
|
||||
expect(managedLabelSpecs["r: too-many-prs"].description).toContain("twenty active PRs");
|
||||
expect(managedLabelSpecs[PROOF_SUPPLIED_LABEL].color).toBe("C2E0C6");
|
||||
expect(managedLabelSpecs[PROOF_SUFFICIENT_LABEL].color).toBe("0E8A16");
|
||||
|
||||
for (const label of Object.values(candidateLabels)) {
|
||||
expect(managedLabelSpecs[label]).toBeDefined();
|
||||
@@ -283,7 +289,7 @@ describe("barnacle-auto-response", () => {
|
||||
expect(labels).not.toContain(candidateLabels.needsRealBehaviorProof);
|
||||
});
|
||||
|
||||
it("does not label external PRs that include real behavior proof", () => {
|
||||
it("labels external PRs that include real behavior proof as supplied", () => {
|
||||
const labels = classifyPullRequestCandidateLabels(
|
||||
pr(
|
||||
"Fix gateway startup",
|
||||
@@ -292,6 +298,23 @@ describe("barnacle-auto-response", () => {
|
||||
[file("src/gateway/server.ts")],
|
||||
);
|
||||
|
||||
expect(labels).toContain(PROOF_SUPPLIED_LABEL);
|
||||
expect(labels).not.toContain(candidateLabels.needsRealBehaviorProof);
|
||||
expect(labels).not.toContain(candidateLabels.mockOnlyProof);
|
||||
});
|
||||
|
||||
it("labels CRLF-formatted external PRs with screenshot proof as supplied", () => {
|
||||
const labels = classifyPullRequestCandidateLabels(
|
||||
pr(
|
||||
"Fix gateway startup",
|
||||
realBehaviorProofBody(
|
||||
"",
|
||||
).replace(/\n/g, "\r\n"),
|
||||
),
|
||||
[file("src/gateway/server.ts")],
|
||||
);
|
||||
|
||||
expect(labels).toContain(PROOF_SUPPLIED_LABEL);
|
||||
expect(labels).not.toContain(candidateLabels.needsRealBehaviorProof);
|
||||
expect(labels).not.toContain(candidateLabels.mockOnlyProof);
|
||||
});
|
||||
@@ -662,18 +685,115 @@ describe("barnacle-auto-response", () => {
|
||||
|
||||
await runBarnacleAutoResponse({
|
||||
github,
|
||||
context: barnacleContext({}, [candidateLabels.needsRealBehaviorProof, "proof: override"]),
|
||||
context: barnacleContext({}, [
|
||||
candidateLabels.needsRealBehaviorProof,
|
||||
candidateLabels.mockOnlyProof,
|
||||
PROOF_SUPPLIED_LABEL,
|
||||
PROOF_SUFFICIENT_LABEL,
|
||||
"proof: override",
|
||||
]),
|
||||
core: {
|
||||
info: () => undefined,
|
||||
},
|
||||
});
|
||||
|
||||
expect(calls.removeLabel).toContainEqual(
|
||||
expect.objectContaining({ name: candidateLabels.needsRealBehaviorProof }),
|
||||
expect(calls.removeLabel.map((call) => call.name)).toEqual(
|
||||
expect.arrayContaining([
|
||||
candidateLabels.needsRealBehaviorProof,
|
||||
candidateLabels.mockOnlyProof,
|
||||
PROOF_SUPPLIED_LABEL,
|
||||
PROOF_SUFFICIENT_LABEL,
|
||||
]),
|
||||
);
|
||||
expect(calls.update).toEqual([]);
|
||||
});
|
||||
|
||||
it("removes stale negative proof labels and adds supplied when proof is present", async () => {
|
||||
const { calls, github } = barnacleGithub([file("src/gateway/server.ts")]);
|
||||
|
||||
await runBarnacleAutoResponse({
|
||||
github,
|
||||
context: barnacleContext(
|
||||
{
|
||||
body: realBehaviorProofBody(
|
||||
"",
|
||||
),
|
||||
},
|
||||
[candidateLabels.needsRealBehaviorProof, candidateLabels.mockOnlyProof],
|
||||
),
|
||||
core: {
|
||||
info: () => undefined,
|
||||
},
|
||||
});
|
||||
|
||||
expect(calls.removeLabel.map((call) => call.name)).toEqual(
|
||||
expect.arrayContaining([
|
||||
candidateLabels.needsRealBehaviorProof,
|
||||
candidateLabels.mockOnlyProof,
|
||||
]),
|
||||
);
|
||||
expect(calls.addLabels).toContainEqual(
|
||||
expect.objectContaining({
|
||||
labels: expect.arrayContaining([PROOF_SUPPLIED_LABEL]),
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it.each(["edited", "synchronize"])(
|
||||
"removes stale sufficient proof label after PR %s events",
|
||||
async (action) => {
|
||||
const { calls, github } = barnacleGithub([file("src/gateway/server.ts")]);
|
||||
|
||||
await runBarnacleAutoResponse({
|
||||
github,
|
||||
context: barnacleContext(
|
||||
{
|
||||
body: realBehaviorProofBody(
|
||||
"",
|
||||
),
|
||||
},
|
||||
[PROOF_SUPPLIED_LABEL, PROOF_SUFFICIENT_LABEL],
|
||||
{ action },
|
||||
),
|
||||
core: {
|
||||
info: () => undefined,
|
||||
},
|
||||
});
|
||||
|
||||
expect(calls.removeLabel).toContainEqual(
|
||||
expect.objectContaining({ name: PROOF_SUFFICIENT_LABEL }),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
it("preserves ClawSweeper's sufficient proof label on ordinary label events", async () => {
|
||||
const { calls, github } = barnacleGithub([file("src/gateway/server.ts")]);
|
||||
|
||||
await runBarnacleAutoResponse({
|
||||
github,
|
||||
context: barnacleContext(
|
||||
{
|
||||
body: realBehaviorProofBody(
|
||||
"",
|
||||
),
|
||||
},
|
||||
[PROOF_SUPPLIED_LABEL, PROOF_SUFFICIENT_LABEL],
|
||||
{
|
||||
action: "labeled",
|
||||
label: { name: PROOF_SUFFICIENT_LABEL },
|
||||
sender: { login: "openclaw-clawsweeper[bot]", type: "Bot" },
|
||||
},
|
||||
),
|
||||
core: {
|
||||
info: () => undefined,
|
||||
},
|
||||
});
|
||||
|
||||
expect(calls.removeLabel).not.toContainEqual(
|
||||
expect.objectContaining({ name: PROOF_SUFFICIENT_LABEL }),
|
||||
);
|
||||
});
|
||||
|
||||
it("actions manually applied candidate labels", async () => {
|
||||
const { calls, github } = barnacleGithub([file("extensions/example/openclaw.plugin.json")]);
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ import {
|
||||
MOCK_ONLY_PROOF_LABEL,
|
||||
NEEDS_REAL_BEHAVIOR_PROOF_LABEL,
|
||||
PROOF_OVERRIDE_LABEL,
|
||||
PROOF_SUPPLIED_LABEL,
|
||||
evaluateRealBehaviorProof,
|
||||
labelsForRealBehaviorProof,
|
||||
} from "../../scripts/github/real-behavior-proof-policy.mjs";
|
||||
@@ -56,7 +57,26 @@ describe("real-behavior-proof-policy", () => {
|
||||
});
|
||||
|
||||
expect(evaluation.status).toBe("passed");
|
||||
expect(labelsForRealBehaviorProof(evaluation)).toEqual([]);
|
||||
expect(labelsForRealBehaviorProof(evaluation)).toEqual([PROOF_SUPPLIED_LABEL]);
|
||||
});
|
||||
|
||||
it("passes CRLF-formatted external PRs with screenshot proof", () => {
|
||||
const evaluation = evaluateRealBehaviorProof({
|
||||
pullRequest: externalPr(
|
||||
proofBody("").replace(
|
||||
/\n/g,
|
||||
"\r\n",
|
||||
),
|
||||
),
|
||||
});
|
||||
|
||||
expect(evaluation.status).toBe("passed");
|
||||
expect(evaluation.fields).toMatchObject({
|
||||
behavior: "Gateway startup no longer drops the configured Discord channel.",
|
||||
evidence: "",
|
||||
observedResult: "The gateway stayed connected and the Discord channel showed ready.",
|
||||
});
|
||||
expect(labelsForRealBehaviorProof(evaluation)).toEqual([PROOF_SUPPLIED_LABEL]);
|
||||
});
|
||||
|
||||
it("fails external PRs without a real behavior proof section", () => {
|
||||
|
||||
Reference in New Issue
Block a user