Skip to content

Commit 87ed433

Browse files
committed
update
1 parent 05ba050 commit 87ed433

2 files changed

Lines changed: 5 additions & 28 deletions

File tree

torchci/lib/bot/crcrOncallBot.ts

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -81,30 +81,13 @@ export default function crcrOncallBot(app: Probot): void {
8181

8282
// Get the PRs this check run belongs to.
8383
let prNumbers: number[] = [];
84-
if (checkRun.output?.summary) {
84+
if (checkRun.pull_requests && checkRun.pull_requests.length > 0) {
85+
prNumbers = checkRun.pull_requests.map((pr) => pr.number);
86+
} else if (checkRun.output?.summary) {
8587
const match = checkRun.output.summary.match(/for PR (\d+)/);
8688
if (match) {
8789
prNumbers = [parseInt(match[1], 10)];
8890
}
89-
} else if (checkRun.pull_requests && checkRun.pull_requests.length > 0) {
90-
prNumbers = checkRun.pull_requests.map((pr) => pr.number);
91-
}
92-
93-
// Fall back to Search API if still no PR found (e.g., pr_number was empty
94-
// on the Lambda side).
95-
if (prNumbers.length === 0 && checkRun.head_sha) {
96-
try {
97-
const result = await ctx.octokit.rest.search.issuesAndPullRequests({
98-
q: `${checkRun.head_sha} type:pr repo:${owner}/${repo}`,
99-
});
100-
prNumbers = result.data.items.map((item: any) => item.number);
101-
} catch (err) {
102-
ctx.log(
103-
{ err },
104-
`crcrOncall: failed to resolve PRs for commit ${checkRun.head_sha}, skipping`
105-
);
106-
return;
107-
}
10891
}
10992

11093
if (prNumbers.length === 0) {

torchci/test/crcrOncallBot.test.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -177,13 +177,8 @@ L3:
177177
});
178178

179179
test("does not comment when output has no PR number", async () => {
180-
// output.summary exists but regex doesn't match (empty pr_number);
181-
// falls through to Search API which also returns nothing
182-
const scope = nock("https://api.github.com")
183-
.get("/search/issues")
184-
.query(true)
185-
.reply(200, { total_count: 0, items: [] });
186-
180+
// output.summary exists but regex doesn't match (no PR number
181+
// after "for PR"), so the bot returns early without any API call.
187182
await probot.receive({
188183
name: "check_run" as any,
189184
payload: checkRunPayload({
@@ -195,7 +190,6 @@ L3:
195190
}) as any,
196191
id: "8",
197192
});
198-
handleScope(scope);
199193
});
200194

201195
test("posts comment when output contains PR number for cross-fork PR", async () => {

0 commit comments

Comments
 (0)