Skip to content

Commit 4f7eb22

Browse files
clee2000zxiiro
andauthored
[ez][bot] Add ci-no-td label on PRs titled revert (#6494)
In addition to "reland", also add the ci-no-td label to PRs that have "revert" in the title --------- Co-authored-by: Thanh Ha <[email protected]>
1 parent b69cbe1 commit 4f7eb22

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

torchci/lib/bot/autoLabelBot.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const IssueAndPRRegexToLabel: [RegExp, string][] = [
2121
// List of regex patterns for assigning labels to Pull Requests
2222
const PrTitleRegexToLabel: [RegExp, string][] = [
2323
[/reland/gi, "ci-no-td"],
24+
[/revert/gi, "ci-no-td"],
2425
[/rocm/gi, "ciflow/rocm"],
2526
...IssueAndPRRegexToLabel,
2627
];

torchci/test/autoLabelBot.test.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,30 @@ describe("auto-label-bot", () => {
128128
scope.done();
129129
});
130130

131+
test("add ci-no-td label when PR title contains Revert", async () => {
132+
nock("https://api.github.com")
133+
.post("/app/installations/2/access_tokens")
134+
.reply(200, { token: "test" });
135+
136+
const payload = requireDeepCopy("./fixtures/pull_request.opened")[
137+
"payload"
138+
];
139+
payload["pull_request"]["title"] = "Failed test [Revert]";
140+
payload["pull_request"]["labels"] = [];
141+
142+
const scope = nock("https://api.github.com")
143+
.get("/repos/zhouzhuojie/gha-ci-playground/pulls/31/files?per_page=100")
144+
.reply(200)
145+
.post("/repos/zhouzhuojie/gha-ci-playground/issues/31/labels", (body) => {
146+
expect(body).toMatchObject({ labels: ["ci-no-td"] });
147+
return true;
148+
})
149+
.reply(200);
150+
await probot.receive({ name: "pull_request", payload: payload, id: "2" });
151+
152+
handleScope(scope);
153+
});
154+
131155
test("add ci-no-td label when PR title contains mixed cases reLanD", async () => {
132156
nock("https://api.github.com")
133157
.post("/app/installations/2/access_tokens")

0 commit comments

Comments
 (0)