Skip to content

Commit 60ef721

Browse files
authored
[viable/strict] Fix failing jobs with unstable issues (#6444)
Follow up to #6362, I forgot that the format is slightly different for test jobs due to the shards Tested by running on a couple of commits pytorch. Checked that executorch test config (currently has an issue) got ignored Checked that commit with trunk job failing was correctly marked as red
1 parent 8054bbb commit 60ef721

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

tools/scripts/fetch_latest_green_commit.py

+16-4
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,20 @@ def fetch_unstable_issues() -> List[str]:
9191
]
9292

9393

94+
UNSTABLE_REGEX = re.compile(r"(.*) \(([^,]*),.*\)")
95+
96+
9497
def is_unstable(job: dict[str, Any]) -> bool:
9598
# Check if the job is an unstable job, either by name or by issue
96-
if "unstable" in job["jobName"]:
99+
unstable_issues = fetch_unstable_issues()
100+
job_name = job["name"]
101+
if "unstable" in job_name or job_name in unstable_issues:
97102
return True
98-
return job["name"] in fetch_unstable_issues()
103+
# Go from something like pull / something / test (config, 1, 2, 3) to pull / something / test (config)
104+
match = UNSTABLE_REGEX.match(job_name)
105+
if match:
106+
return f"{match.group(1)} ({match.group(2)})" in unstable_issues
107+
return False
99108

100109

101110
def is_green(
@@ -108,15 +117,18 @@ def is_green(
108117
for check in workflow_checks:
109118
jobName = check["name"]
110119
# Ignore result from unstable job, be it success or failure
111-
if "unstable" in jobName or jobName in fetch_unstable_issues():
120+
if is_unstable(check):
112121
continue
113122

114123
workflow_name = check["workflowName"]
115124
conclusion = check["conclusion"]
116125
for required_check in regex:
117126
if re.match(required_check, workflow_name, flags=re.IGNORECASE):
118127
if conclusion not in ["success", "skipped"]:
119-
return False, workflow_name + " checks were not successful"
128+
return (
129+
False,
130+
f"{workflow_name} was not successful, {jobName} failed",
131+
)
120132
else:
121133
regex[required_check] = True
122134

tools/tests/test_fetch_latest_green_commit.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def test_necessary_failed(
131131
workflow_checks = set_workflow_job_status(workflow_checks, "Lint", "failed")
132132
result = is_green("sha", requires, workflow_checks)
133133
self.assertFalse(result[0])
134-
self.assertEqual(result[1], "Lint checks were not successful")
134+
self.assertEqual(result[1], "Lint was not successful, test/job failed")
135135

136136
@mock.patch(
137137
"tools.scripts.fetch_latest_green_commit.get_commit_results",

0 commit comments

Comments
 (0)