Skip to content

Commit 673d728

Browse files
authored
Update Dr.CI to use the list of unstable issues (#5131)
This is the next part of #5122 where Dr.CI also uses the list of unstable issues to check if a job is an unstable job. The same function `isUnstableJob` that powers HUD from #5122 is used. ### Testing Mark a job on ET as unstable pytorch/executorch#3344 as shown on HUD https://hud.pytorch.org/hud/pytorch/executorch/main and Dr.CI applies the same logic on a PR pytorch/executorch#3318 to show the job as unstable. ``` curl --request POST \ --url "http://localhost:3000/api/drci/drci?prNumber=3318" \ --header "Authorization: TOKEN" \ --data 'repo=executorch' ``` <!-- drci-comment-start --> ## 🔗 Helpful Links ### 🧪 See artifacts and rendered test results at [hud.pytorch.org/pr/pytorch/executorch/3318](https://hud.pytorch.org/pr/pytorch/executorch/3318) * 📄 Preview [Python docs built from this PR](https://docs-preview.pytorch.org/pytorch/executorch/3318/index.html) Note: Links to docs will display an error until the docs builds have been completed. ## ✅ You can merge normally! (1 Unrelated Failure) As of commit f712e381c161901b733baa6b1fe7d85dc25404d3 with merge base b669056c1cff5f7fe3786df9e68a14447cd5410b (<sub><sub><img alt="image" width=70 src="https://img.shields.io/date/1713981882?label=&color=FFFFFF&style=flat-square"></sub></sub>): <details ><summary><b>UNSTABLE</b> - The following job failed but was likely due to flakiness present on trunk and has been marked as unstable:</summary><p> * [Android / test-llama-app / mobile-job (android)](https://hud.pytorch.org/pr/pytorch/executorch/3318#24225451316) ([gh](https://github.com/pytorch/executorch/actions/runs/8821313480/job/24225451316)) `Credentials could not be loaded, please check your action inputs: Could not load credentials from any providers` </p></details> This comment was automatically generated by Dr. CI and updates every 15 minutes. <!-- drci-comment-end -->
1 parent 88b6a0a commit 673d728

File tree

3 files changed

+41
-7
lines changed

3 files changed

+41
-7
lines changed

torchci/pages/api/drci/drci.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
fetchRecentWorkflows,
55
fetchFailedJobsFromCommits,
66
} from "lib/fetchRecentWorkflows";
7-
import { RecentWorkflowsData } from "lib/types";
7+
import { RecentWorkflowsData, IssueData } from "lib/types";
88
import {
99
NUM_MINUTES,
1010
formDrciComment,
@@ -29,6 +29,7 @@ import {
2929
isSameFailure,
3030
removeCancelledJobAfterRetry,
3131
backfillMissingLog,
32+
isUnstableJob,
3233
} from "lib/jobUtils";
3334
import getRocksetClient from "lib/rockset";
3435
import _ from "lodash";
@@ -92,6 +93,7 @@ export async function updateDrciComments(
9293
await addMergeBaseCommits(octokit, repo, head, workflowsByPR);
9394
const sevs = getActiveSEVs(await fetchIssuesByLabel("ci: sev"));
9495
const flakyRules: FlakyRule[] = (await fetchJSON(FLAKY_RULES_JSON)) || [];
96+
const unstableIssues: IssueData[] = await fetchIssuesByLabel("unstable");
9597
const baseCommitJobs = await getBaseCommitJobs(workflowsByPR);
9698
const existingDrCiComments = await getExistingDrCiComments(
9799
`${OWNER}/${repo}`,
@@ -117,7 +119,8 @@ export async function updateDrciComments(
117119
pr_info,
118120
flakyRules,
119121
baseCommitJobs.get(pr_info.merge_base) || new Map(),
120-
labels || []
122+
labels || [],
123+
unstableIssues || []
121124
);
122125

123126
failures[pr_info.pr_number] = {
@@ -628,7 +631,8 @@ export async function getWorkflowJobsStatuses(
628631
prInfo: PRandJobs,
629632
flakyRules: FlakyRule[],
630633
baseJobs: Map<string, RecentWorkflowsData[]>,
631-
labels: string[] = []
634+
labels: string[] = [],
635+
unstableIssues: IssueData[] = []
632636
): Promise<{
633637
pending: number;
634638
failedJobs: RecentWorkflowsData[];
@@ -649,7 +653,7 @@ export async function getWorkflowJobsStatuses(
649653
) {
650654
pending++;
651655
} else if (job.conclusion === "failure" || job.conclusion === "cancelled") {
652-
if (job.name !== undefined && job.name.includes("unstable")) {
656+
if (await isUnstableJob(job, unstableIssues)) {
653657
unstableJobs.push(job);
654658
} else if (isBrokenTrunk(job, baseJobs)) {
655659
brokenTrunkJobs.push(job);

torchci/test/drci.test.ts

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,20 @@ const unstableA = getDummyJob({
231231
runnerName: "dummy",
232232
});
233233

234+
// From the list of mock unstable jobs
235+
const unstableB = getDummyJob({
236+
name: "trunk / test-coreml-delegate / macos-job",
237+
conclusion: "failure",
238+
completed_at: "2022-07-13T19:34:03Z",
239+
html_url: "a",
240+
head_sha: "abcdefg",
241+
id: "1",
242+
pr_number: 1001,
243+
failure_lines: ["a", "b"],
244+
failure_captures: ["a", "b"],
245+
runnerName: "dummy",
246+
});
247+
234248
const sev: IssueData = {
235249
number: 85362,
236250
title: "docker pulls failing with no space left on disk",
@@ -528,23 +542,37 @@ describe("Update Dr. CI Bot Unit Tests", () => {
528542
});
529543

530544
test("test flaky, broken trunk, and unstable jobs are filtered out", async () => {
531-
const originalWorkflows = [failedA, failedB, unstableA];
545+
const originalWorkflows = [failedA, failedB, unstableA, unstableB];
532546
const workflowsByPR = await updateDrciBot.reorganizeWorkflows(
533547
"pytorch",
534548
"pytorch",
535549
originalWorkflows
536550
);
551+
const mockUnstableIssues: IssueData[] = [
552+
{
553+
number: 3264,
554+
title: "UNSTABLE trunk / test-coreml-delegate / macos-job",
555+
html_url: "https://github.com/pytorch/executorch/issues/3264",
556+
state: "open",
557+
body: "",
558+
updated_at: "2024-04-24T00:44:19Z",
559+
author_association: "CONTRIBUTOR",
560+
},
561+
];
537562
const pr_1001 = workflowsByPR.get(1001)!;
563+
538564
const { failedJobs, brokenTrunkJobs, flakyJobs, unstableJobs } =
539565
await updateDrciBot.getWorkflowJobsStatuses(
540566
pr_1001,
541567
[{ name: failedB.name!, captures: failedB.failure_captures }],
542-
new Map().set(failedA.name, [failedA])
568+
new Map().set(failedA.name, [failedA]),
569+
[],
570+
mockUnstableIssues
543571
);
544572
expect(failedJobs.length).toBe(0);
545573
expect(brokenTrunkJobs.length).toBe(1);
546574
expect(flakyJobs.length).toBe(1);
547-
expect(unstableJobs.length).toBe(1);
575+
expect(unstableJobs.length).toBe(2);
548576
});
549577

550578
test(" test flaky rule regex", async () => {

torchci/test/drciBot.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,8 @@ describe("verify-drci-functionality", () => {
174174
.reply(200, { results: [] })
175175
.post((url) => url.includes("commit_failed_jobs"))
176176
.reply(200, { results: [] })
177+
.post((url) => url.includes("issue_query"))
178+
.reply(200, { results: [] })
177179
.post(
178180
(url) => url.includes("self/queries"),
179181
(body) => JSON.stringify(body).includes("merge_base_commit_date")

0 commit comments

Comments
 (0)