Skip to content

Commit 0aee809

Browse files
authored
Merge pull request github#17899 from hvitved/accept-changes-multi-jobs
Handle matrix jobs in accept changes script
2 parents 8f80c24 + 5f20f19 commit 0aee809

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

misc/scripts/accept-expected-changes-from-ci.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -196,15 +196,16 @@ class GithubStatus():
196196
target_url: str
197197
created_at: datetime
198198
nwo: str
199-
job_id: int = None
199+
job_ids: set = None
200200

201201

202202
def get_log_content(status: GithubStatus) -> str:
203203
LOGGER.debug(f"'{status.context}': Getting logs")
204-
if status.job_id:
205-
content = subprocess.check_output(
206-
["gh", "api", f"/repos/{status.nwo}/actions/jobs/{status.job_id}/logs"],
207-
).decode("utf-8")
204+
if status.job_ids:
205+
contents = [subprocess.check_output(
206+
["gh", "api", f"/repos/{status.nwo}/actions/jobs/{job_id}/logs"],
207+
).decode("utf-8") for job_id in status.job_ids]
208+
content = "\n".join(contents)
208209
else:
209210
m = re.fullmatch(r"^https://github\.com/([^/]+/[^/]+)/actions/runs/(\d+)(?:/jobs/(\d+))?$", status.target_url)
210211
nwo = m.group(1)
@@ -301,8 +302,10 @@ def main(pr_number: Optional[int], sha_override: Optional[str] = None, force=Fal
301302
api_name: str = job["name"]
302303

303304
if api_name.lower().startswith(expected_workflow_name.lower()):
304-
lang_test_failure.job_id = job["id"]
305-
break
305+
if lang_test_failure.job_ids is None:
306+
lang_test_failure.job_ids = set()
307+
lang_test_failure.job_ids.add(job["id"])
308+
continue
306309

307310
if " / " not in api_name:
308311
continue
@@ -311,11 +314,11 @@ def main(pr_number: Optional[int], sha_override: Optional[str] = None, force=Fal
311314
# The job names we're looking for looks like "Python2 Language Tests / Python2 Language Tests" or "Java Language Tests / Java Language Tests Linux"
312315
# for "Java Integration Tests Linux / Java Integration tests Linux" we need to ignore case :|
313316
if workflow_name == expected_workflow_name and job_name.lower().startswith(lang_test_failure.context.lower()):
314-
lang_test_failure.job_id = job["id"]
315-
break
317+
lang_test_failure.job_ids.add(job["id"])
318+
continue
316319

317320
for lang_test_failure in lang_test_failures:
318-
if lang_test_failure.job_id is None:
321+
if lang_test_failure.job_ids is None:
319322
LOGGER.error(f"Could not find job for {lang_test_failure.context!r}")
320323
sys.exit(1)
321324

@@ -370,7 +373,7 @@ def ok_job_name(job_name: str) -> bool:
370373
target_url=job["html_url"],
371374
created_at=check_run["completed_at"],
372375
nwo=nwo,
373-
job_id=job["id"],
376+
job_ids={job["id"]},
374377
))
375378
break
376379
else:

0 commit comments

Comments
 (0)