Skip to content

Commit cb05706

Browse files
authored
[disablebot] Fix aggregate issues getting auto closed (#6860)
The deduper was closing them automatically, ex the action right above this comment: pytorch/pytorch#157070 (comment)
1 parent 266b030 commit cb05706

File tree

2 files changed

+46
-1
lines changed

2 files changed

+46
-1
lines changed

torchci/pages/api/flaky-tests/disable.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ async function dedupFlakyTestIssues(
221221

222222
// Close the issues that aren't favored
223223
const dedupedArrayNumbers = dedupedArray.map((i) => i.number);
224-
for (const issue of issues) {
224+
for (const issue of singleIssues) {
225225
if (!dedupedArrayNumbers.includes(issue.number) && issue.state === "open") {
226226
await octokit.rest.issues.update({
227227
owner: PYTORCH,

torchci/test/flakyBotTests/flakyBotUtils.test.ts

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { MASS_FLAKY_TEST_ISSUE_LABEL } from "lib/flakyBot/aggregateDisableIssue";
12
import * as flakyBotUtils from "lib/flakyBot/utils";
23
import { IssueData } from "lib/types";
34
import nock from "nock";
@@ -379,4 +380,48 @@ describe("Disable Flaky Test Bot Utils Unit Tests", () => {
379380
await helper([closedSmall, closedBig], closedBig, []);
380381
await helper([closedSmall, openSmall], openSmall, []);
381382
});
383+
384+
test("dedupFlakyTestIssues does not touch aggregate issues", async () => {
385+
const singleIssueToBeClosed: IssueData = {
386+
number: 1,
387+
title: "",
388+
html_url: "",
389+
state: "open",
390+
body: "",
391+
updated_at: "",
392+
author_association: "MEMBER",
393+
labels: [],
394+
};
395+
396+
const singleIssue: IssueData = {
397+
...singleIssueToBeClosed,
398+
number: 2,
399+
};
400+
401+
const aggregateIssue: IssueData = {
402+
...singleIssueToBeClosed,
403+
labels: [MASS_FLAKY_TEST_ISSUE_LABEL],
404+
};
405+
406+
// sanity check that it does get closed if its a single issue
407+
const scope = nock("https://api.github.com");
408+
scope
409+
.patch(`/repos/pytorch/pytorch/issues/${singleIssueToBeClosed.number}`)
410+
.reply(200);
411+
expect(
412+
await flakyBot.dedupFlakyTestIssues(octokit, [
413+
singleIssueToBeClosed,
414+
singleIssue,
415+
])
416+
).toEqual([singleIssue]);
417+
scope.done();
418+
419+
// Should not make any API calls either
420+
expect(
421+
await flakyBot.dedupFlakyTestIssues(octokit, [
422+
aggregateIssue,
423+
singleIssue,
424+
])
425+
).toEqual([singleIssue, aggregateIssue]);
426+
});
382427
});

0 commit comments

Comments
 (0)