Skip to content

Commit 543356e

Browse files
authored
Stop accepting GitHub events from non-PyTorch, non-vLLM repos (#7408)
Signed-off-by: Huy Do <[email protected]>
1 parent a91395c commit 543356e

File tree

3 files changed

+53
-1
lines changed

3 files changed

+53
-1
lines changed

torchci/lib/bot/utils.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ export function repoKey(context: Context): string {
1616
return `${repo.owner}/${repo.repo}`;
1717
}
1818

19+
export function isVLLM(owner: string): boolean {
20+
return owner === "vllm-project";
21+
}
22+
1923
export function isPyTorchbotSupportedOrg(owner: string): boolean {
2024
// We frequently test CI changes on malfet/deleteme
2125
return owner === "pytorch" || owner === "meta-pytorch" || owner === "malfet";

torchci/lib/bot/webhookToDynamo.ts

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
import { getDynamoClient } from "lib/dynamo";
22
import { Context, Probot } from "probot";
33
import { v4 as uuidv4 } from "uuid";
4+
import { isPyTorchbotSupportedOrg, isVLLM } from "./utils";
45

56
async function handleWorkflowJob(
67
event: Context<"workflow_run" | "workflow_job">
78
) {
8-
// Thre is the chance that job ids from different repos could collide. To
9+
const owner = event.payload.repository.owner.login;
10+
if (!isPyTorchbotSupportedOrg(owner) && !isVLLM(owner)) {
11+
event.log(`${__filename} isn't enabled on ${owner}'s repos`);
12+
return;
13+
}
14+
15+
// There is the chance that job ids from different repos could collide. To
916
// prevent this, prefix the object key with the repo that they come from.
1017
const key_prefix = event.payload.repository.full_name + "/";
1118

@@ -35,6 +42,12 @@ async function handleWorkflowJob(
3542
}
3643

3744
async function handleIssues(event: Context<"issues">) {
45+
const owner = event.payload.repository.owner.login;
46+
if (!isPyTorchbotSupportedOrg(owner) && !isVLLM(owner)) {
47+
event.log(`${__filename} isn't enabled on ${owner}'s repos`);
48+
return;
49+
}
50+
3851
const client = getDynamoClient();
3952

4053
const issue_number = event.payload.issue.number;
@@ -69,6 +82,12 @@ async function handleIssues(event: Context<"issues">) {
6982
}
7083

7184
async function handleIssueComment(event: Context<"issue_comment">) {
85+
const owner = event.payload.repository.owner.login;
86+
if (!isPyTorchbotSupportedOrg(owner) && !isVLLM(owner)) {
87+
event.log(`${__filename} isn't enabled on ${owner}'s repos`);
88+
return;
89+
}
90+
7291
const key_prefix = event.payload.repository.full_name;
7392
const client = getDynamoClient();
7493

@@ -82,6 +101,12 @@ async function handleIssueComment(event: Context<"issue_comment">) {
82101
}
83102

84103
async function handlePullRequest(event: Context<"pull_request">) {
104+
const owner = event.payload.repository.owner.login;
105+
if (!isPyTorchbotSupportedOrg(owner) && !isVLLM(owner)) {
106+
event.log(`${__filename} isn't enabled on ${owner}'s repos`);
107+
return;
108+
}
109+
85110
const key_prefix = event.payload.repository.full_name + "/";
86111
const client = getDynamoClient();
87112

@@ -117,6 +142,12 @@ async function handlePullRequest(event: Context<"pull_request">) {
117142
}
118143

119144
async function handlePush(event: Context<"push">) {
145+
const owner = event.payload.repository.owner.login;
146+
if (!isPyTorchbotSupportedOrg(owner) && !isVLLM(owner)) {
147+
event.log(`${__filename} isn't enabled on ${owner}'s repos`);
148+
return;
149+
}
150+
120151
const key_prefix = event.payload.repository.full_name + "/";
121152
const client = getDynamoClient();
122153

@@ -130,6 +161,12 @@ async function handlePush(event: Context<"push">) {
130161
}
131162

132163
async function handlePullRequestReview(event: Context<"pull_request_review">) {
164+
const owner = event.payload.repository.owner.login;
165+
if (!isPyTorchbotSupportedOrg(owner) && !isVLLM(owner)) {
166+
event.log(`${__filename} isn't enabled on ${owner}'s repos`);
167+
return;
168+
}
169+
133170
const key_prefix = event.payload.repository.full_name;
134171
const client = getDynamoClient();
135172

@@ -145,6 +182,12 @@ async function handlePullRequestReview(event: Context<"pull_request_review">) {
145182
async function handlePullRequestReviewComment(
146183
event: Context<"pull_request_review_comment">
147184
) {
185+
const owner = event.payload.repository.owner.login;
186+
if (!isPyTorchbotSupportedOrg(owner) && !isVLLM(owner)) {
187+
event.log(`${__filename} isn't enabled on ${owner}'s repos`);
188+
return;
189+
}
190+
148191
const key_prefix = event.payload.repository.full_name;
149192
const client = getDynamoClient();
150193

torchci/test/wehookToDynamoBot.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ import * as utils from "./utils";
88

99
nock.disableNetConnect();
1010
jest.mock("uuid", () => ({ v4: () => "fake-uuid" }));
11+
jest.mock("../lib/bot/utils", () => ({
12+
...jest.requireActual("../lib/bot/utils"),
13+
isPyTorchbotSupportedOrg: jest.fn(() => true),
14+
isVLLM: jest.fn(() => false),
15+
}));
1116

1217
describe("webhookToDynamo tests", () => {
1318
let probot: Probot;

0 commit comments

Comments
 (0)