Skip to content

Commit

Permalink
[ez][drci] Make merge blocking sevs be based on label instead of stri…
Browse files Browse the repository at this point in the history
…ng (#5913)

Corresponds to pytorch/pytorch#140636
  • Loading branch information
clee2000 authored Nov 14, 2024
1 parent 6c870c6 commit a3d30d6
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 83 deletions.
3 changes: 2 additions & 1 deletion torchci/clickhouse_queries/issue_query/query.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ SELECT
issue.body,
issue.updated_at,
issue.author_association,
arrayMap(x -> x.'name', issue.labels) as labels
FROM
issues AS issue final
default.issues AS issue final
array join issue.labels AS label
WHERE
label.name = {label: String}
10 changes: 1 addition & 9 deletions torchci/lib/drciUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,7 @@ export async function getDrciComment(
}

export function isMergeBlockingSev(issue: IssueData): boolean {
let body = issue.body;
let previousBody;
do {
// Remove all matching pairs of comments
previousBody = body;
body = body.replace(/<!--[\s\S]*?-->/gm, "");
} while (body !== previousBody);

return body.includes("merge blocking");
return issue.labels.includes("merge blocking");
}

export function getActiveSEVs(issues: IssueData[]): [IssueData[], IssueData[]] {
Expand Down
1 change: 1 addition & 0 deletions torchci/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ export interface IssueData {
body: string;
updated_at: string;
author_association: string;
labels: string[];
}

export interface HudParams {
Expand Down
18 changes: 14 additions & 4 deletions torchci/test/disableFlakyBot.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ describe("Disable Flaky Test Bot Across Jobs", () => {
body: "random",
updated_at: dayjs().toString(),
author_association: "MEMBER",
labels: [],
},
];

Expand All @@ -188,6 +189,7 @@ describe("Disable Flaky Test Bot Across Jobs", () => {
body: "random",
updated_at: dayjs().toString(),
author_association: "MEMBER",
labels: [],
},
];

Expand Down Expand Up @@ -223,6 +225,7 @@ describe("Disable Flaky Test Bot Across Jobs", () => {
body: "random",
updated_at: dayjs().toString(),
author_association: "MEMBER",
labels: [],
},
];

Expand All @@ -245,6 +248,7 @@ describe("Disable Flaky Test Bot Across Jobs", () => {
body: "random",
updated_at: dayjs().toString(),
author_association: "MEMBER",
labels: [],
},
];

Expand Down Expand Up @@ -329,7 +333,7 @@ describe("Disable Flaky Test Bot Integration Tests", () => {
})
.reply(200, {});

const issues = [
const issues: IssueData[] = [
{
number: 1,
title: "DISABLED test_a (__main__.suite_a)",
Expand All @@ -338,6 +342,7 @@ describe("Disable Flaky Test Bot Integration Tests", () => {
body: "random",
updated_at: dayjs().toString(),
author_association: "MEMBER",
labels: [],
},
];

Expand All @@ -363,7 +368,7 @@ describe("Disable Flaky Test Bot Integration Tests", () => {
})
.reply(200, {});

const issues = [
const issues: IssueData[] = [
{
number: 1,
title: "DISABLED test_a (__main__.suite_a)",
Expand All @@ -372,6 +377,7 @@ describe("Disable Flaky Test Bot Integration Tests", () => {
body: "random",
updated_at: dayjs().toString(),
author_association: "MEMBER",
labels: [],
},
];

Expand Down Expand Up @@ -405,7 +411,7 @@ describe("Disable Flaky Test Bot Integration Tests", () => {
})
.reply(200, {});

const issues = [
const issues: IssueData[] = [
{
number: 1,
title: "DISABLED test_a (__main__.suite_a)",
Expand All @@ -419,6 +425,7 @@ describe("Disable Flaky Test Bot Integration Tests", () => {
)
.toString(),
author_association: "MEMBER",
labels: [],
},
];

Expand All @@ -445,7 +452,7 @@ describe("Disable Flaky Test Bot Integration Tests", () => {
})
.reply(200, {});

const issues = [
const issues: IssueData[] = [
{
number: 1,
title: "DISABLED test_a (__main__.suite_a)",
Expand All @@ -459,6 +466,7 @@ describe("Disable Flaky Test Bot Integration Tests", () => {
)
.toString(),
author_association: "MEMBER",
labels: [],
},
];

Expand Down Expand Up @@ -931,6 +939,7 @@ describe("Disable Flaky Test Bot Unit Tests", () => {
body: "",
updated_at: "",
author_association: "MEMBER",
labels: [],
};
const closedSmall: IssueData = { ...openSmall, number: 2, state: "closed" };
const openBig: IssueData = { ...openSmall, number: 3 };
Expand Down Expand Up @@ -990,6 +999,7 @@ describe("Disable Flaky Test Bot Unit Tests", () => {
body: "",
updated_at: "",
author_association: "MEMBER",
labels: [],
};
beforeEach(() => {});

Expand Down
76 changes: 7 additions & 69 deletions torchci/test/drci.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
formDrciSevBody,
getActiveSEVs,
HUD_URL,
isMergeBlockingSev,
OH_URL,
} from "lib/drciUtils";
import * as fetchPR from "lib/fetchPR";
Expand Down Expand Up @@ -266,26 +265,29 @@ const sev: IssueData = {
body: "random stuff",
updated_at: dayjs().toString(),
author_association: "MEMBER",
labels: [],
};

const mergeBlockingSev: IssueData = {
number: 74967,
title: "Linux CUDA builds are failing due to missing deps",
html_url: "https://github.com/pytorch/pytorch/issues/74967",
state: "open",
body: "**merge blocking**",
body: "",
updated_at: dayjs().toString(),
author_association: "MEMBER",
labels: ["merge blocking"],
};

const notMergeBlockingSev: IssueData = {
number: 74967,
title: "Linux CUDA builds are failing due to missing deps",
html_url: "https://github.com/pytorch/pytorch/issues/74967",
state: "open",
body: " <!-- **merge blocking** -->",
body: "not merge blocking",
updated_at: dayjs().toString(),
author_association: "MEMBER",
labels: [],
};

const closedSev: IssueData = {
Expand All @@ -296,6 +298,7 @@ const closedSev: IssueData = {
body: "random stuff",
updated_at: dayjs().toString(),
author_association: "MEMBER",
labels: [],
};

function constructResultsCommentHelper({
Expand Down Expand Up @@ -492,72 +495,6 @@ describe("Update Dr. CI Bot Unit Tests", () => {
expect(formDrciSevBody(getActiveSEVs([closedSev])) === "").toBeTruthy();
});

function createIssueData(body: string): IssueData {
return {
number: 1,
title: "Test Issue",
html_url: "https://example.com",
state: "open",
body: body,
updated_at: "2023-10-10T10:00:00Z",
author_association: "MEMBER",
};
}

test("should correctly identify merge blocking issues", () => {
expect(isMergeBlockingSev(createIssueData("**merge blocking**"))).toBe(
true
);
expect(
isMergeBlockingSev(createIssueData("<!-- **merge blocking** -->"))
).toBe(false);
expect(
isMergeBlockingSev(createIssueData("This is a merge blocking issue."))
).toBe(true);
expect(
isMergeBlockingSev(
createIssueData(
"Some text before **merge blocking** and some text after."
)
)
).toBe(true);
expect(
isMergeBlockingSev(
createIssueData(
"Some text before <!-- **merge blocking** --> and some text after."
)
)
).toBe(false);
expect(
isMergeBlockingSev(createIssueData("Line 1\n**merge blocking**\nLine 3"))
).toBe(true);
expect(
isMergeBlockingSev(
createIssueData("Line 1\n<!-- **merge blocking** -->\nLine 3")
)
).toBe(false);
expect(
isMergeBlockingSev(
createIssueData("Line 1\n<!--\n **merge blocking** -->\nLine 4")
)
).toBe(false);
expect(
isMergeBlockingSev(
createIssueData("Line 1\n<!--\nLine 2 merge blocking** -->\nLine 4")
)
).toBe(false);
expect(
isMergeBlockingSev(
createIssueData("<!-- **merge blocking** <!-- --> -->")
)
).toBe(false);
expect(
isMergeBlockingSev(
createIssueData("<!-- test --> **merge blocking** <!-- test2 -->")
)
).toBe(true);
});

test("test form dr ci comment with sevs", async () => {
const originalWorkflows = [successfulA, pendingA, failedA];
const workflowsByPR = await updateDrciBot.reorganizeWorkflows(
Expand Down Expand Up @@ -667,6 +604,7 @@ describe("Update Dr. CI Bot Unit Tests", () => {
body: "",
updated_at: "2024-04-24 00:44:19",
author_association: "CONTRIBUTOR",
labels: [],
},
];
const pr_1001 = workflowsByPR.get(1001)!;
Expand Down
4 changes: 4 additions & 0 deletions torchci/test/jobUtils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,7 @@ describe("Test various job utils", () => {
updated_at: "",
author_association: "",
html_url: "",
labels: [],
};

expect(isDisabledTest([])).toEqual(false);
Expand Down Expand Up @@ -642,6 +643,7 @@ describe("Test various job utils", () => {
updated_at: "",
author_association: "",
html_url: "",
labels: [],
};

expect(isDisabledTestMentionedInPR([], prInfo)).toEqual(false);
Expand Down Expand Up @@ -793,6 +795,7 @@ describe("Test various job utils", () => {
updated_at: "",
author_association: "",
html_url: "",
labels: [],
};

// At least one of the issue is still open
Expand Down Expand Up @@ -888,6 +891,7 @@ describe("Test various job utils", () => {
updated_at: "2024-05-06T00:30:00Z",
author_association: "",
html_url: "",
labels: [],
};

// Invalid input should return nothing
Expand Down

0 comments on commit a3d30d6

Please sign in to comment.