@@ -274,38 +274,39 @@ def main(pr_number: int):
274
274
for lang_test_failure in lang_test_failures :
275
275
job_failure_urls .add (lang_test_failure .target_url )
276
276
277
- assert len (job_failure_urls ) == 1 , f"Multiple job failure URLs: { job_failure_urls } "
278
- job_failure_url = job_failure_urls .pop ()
279
-
280
- # fixup URL. On the status, the target URL is the run, and it's really hard to
281
- # change this to link to the full `/runs/<run_id>/jobs/<numeric_job_id>` URL, since
282
- # the `<numeric_job_id>` is not available in a context: https://github.com/community/community/discussions/40291
283
- m = re .fullmatch (r"^https://github\.com/([^/]+/[^/]+)/actions/runs/(\d+)$" , job_failure_url )
284
- nwo = m .group (1 )
285
- run_id = m .group (2 )
286
- jobs_url = f"https://api.github.com/repos/{ nwo } /actions/runs/{ run_id } /jobs"
287
- LOGGER .info (f"Fixing up target url from looking at { jobs_url } " )
288
- jobs = json .loads (subprocess .check_output (["gh" , "api" , "--paginate" , jobs_url ]).decode ("utf-8" ))
289
- for lang_test_failure in lang_test_failures :
290
- workflow_translation = {
291
- "codeql-coding-standards Unit Tests Linux" : "Start codeql-coding-standards"
292
- }
293
- expected_workflow_name = workflow_translation .get (lang_test_failure .context , lang_test_failure .context )
294
-
295
- for job in jobs ["jobs" ]:
296
- api_name : str = job ["name" ]
297
- if " / " not in api_name :
298
- continue
277
+ if job_failure_urls :
278
+ assert len (job_failure_urls ) == 1 , f"Multiple job failure URLs: { job_failure_urls } "
279
+ job_failure_url = job_failure_urls .pop ()
280
+
281
+ # fixup URL. On the status, the target URL is the run, and it's really hard to
282
+ # change this to link to the full `/runs/<run_id>/jobs/<numeric_job_id>` URL, since
283
+ # the `<numeric_job_id>` is not available in a context: https://github.com/community/community/discussions/40291
284
+ m = re .fullmatch (r"^https://github\.com/([^/]+/[^/]+)/actions/runs/(\d+)$" , job_failure_url )
285
+ nwo = m .group (1 )
286
+ run_id = m .group (2 )
287
+ jobs_url = f"https://api.github.com/repos/{ nwo } /actions/runs/{ run_id } /jobs"
288
+ LOGGER .info (f"Fixing up target url from looking at { jobs_url } " )
289
+ jobs = json .loads (subprocess .check_output (["gh" , "api" , "--paginate" , jobs_url ]).decode ("utf-8" ))
290
+ for lang_test_failure in lang_test_failures :
291
+ workflow_translation = {
292
+ "codeql-coding-standards Unit Tests Linux" : "Start codeql-coding-standards"
293
+ }
294
+ expected_workflow_name = workflow_translation .get (lang_test_failure .context , lang_test_failure .context )
299
295
300
- workflow_name , job_name = api_name .split (" / " )
301
- # The job names we're looking for looks like "Python2 Language Tests / Python2 Language Tests" or "Java Language Tests / Java Language Tests Linux"
302
- # for "Java Integration Tests Linux / Java Integration tests Linux" we need to ignore case :|
303
- if workflow_name == expected_workflow_name and job_name .lower ().startswith (lang_test_failure .context .lower ()):
304
- lang_test_failure .job_id = job ["id" ]
305
- break
306
- else :
307
- LOGGER .error (f"Could not find job for { lang_test_failure .context !r} " )
308
- sys .exit (1 )
296
+ for job in jobs ["jobs" ]:
297
+ api_name : str = job ["name" ]
298
+ if " / " not in api_name :
299
+ continue
300
+
301
+ workflow_name , job_name = api_name .split (" / " )
302
+ # The job names we're looking for looks like "Python2 Language Tests / Python2 Language Tests" or "Java Language Tests / Java Language Tests Linux"
303
+ # for "Java Integration Tests Linux / Java Integration tests Linux" we need to ignore case :|
304
+ if workflow_name == expected_workflow_name and job_name .lower ().startswith (lang_test_failure .context .lower ()):
305
+ lang_test_failure .job_id = job ["id" ]
306
+ break
307
+ else :
308
+ LOGGER .error (f"Could not find job for { lang_test_failure .context !r} " )
309
+ sys .exit (1 )
309
310
310
311
# Ruby/Swift/C#/Go use github actions, and not internal CI. These are not reported
311
312
# from the /statuses API, but from the /check-suites API
0 commit comments