@@ -466,41 +466,50 @@ def main(argv):
466466 run ['log_success' ] = True
467467 run ['log_results' ] = ''
468468 artifacts = firebase_github .list_artifacts (FLAGS .token , run ['id' ])
469- if 'log-artifact' in [a ['name' ] for a in artifacts ]:
470- artifact_id = [a ['id' ] for a in artifacts if a ['name' ] == 'log-artifact' ][0 ]
471- artifact_contents = firebase_github .download_artifact (FLAGS .token , artifact_id )
472- if artifact_contents :
473- artifact_data = io .BytesIO (artifact_contents )
474- artifact_zip = zipfile .ZipFile (artifact_data )
475- with tempfile .TemporaryDirectory () as tmpdir :
476- artifact_zip .extractall (path = tmpdir )
477- (success , results ) = summarize_test_results .summarize_logs (tmpdir , False , False , True )
478- run ['log_success' ] = success
479- run ['log_results' ] = results
480- else :
481- # Artifacts expire after some time, so if they are gone, we need
482- # to read the GitHub logs instead. This is much slower, so we
483- # prefer to read artifacts instead whenever possible.
484- logging .info ("Reading github logs for run %s instead" , run ['id' ])
485-
486- logs_url = run ['logs_url' ]
487- headers = {'Accept' : 'application/vnd.github.v3+json' , 'Authorization' : 'Bearer %s' % FLAGS .token }
488- with requests .get (logs_url , headers = headers , stream = True ) as response :
489- if response .status_code == 200 :
490- logs_compressed_data = io .BytesIO (response .content )
491- logs_zip = zipfile .ZipFile (logs_compressed_data )
492- m = get_message_from_github_log (
493- logs_zip ,
494- r'summarize-results/.*Summarize results into GitHub' ,
495- r'\[error\]INTEGRATION TEST FAILURES\n—+\n(.*)$' )
496- if m :
497- run ['log_success' ] = False
498- m2 = re .match (r'(.*?)^' + day , m .group (1 ), re .MULTILINE | re .DOTALL )
499- if m2 :
500- run ['log_results' ] = m2 .group (1 )
501- else :
502- run ['log_results' ] = m .group (1 )
503- logging .debug ("Integration test results: %s" , run ['log_results' ])
469+ found_artifacts = False
470+ # There are possibly multiple artifacts, so iterate through all of them,
471+ # and extract the relevant ones into a temp folder, and then summarize them all.
472+ with tempfile .TemporaryDirectory () as tmpdir :
473+ for a in artifacts :
474+ if 'log-artifact' in a ['name' ]:
475+ print ("Checking this artifact:" , a ['name' ], "\n " )
476+ artifact_contents = firebase_github .download_artifact (FLAGS .token , a ['id' ])
477+ if artifact_contents :
478+ found_artifacts = True
479+ artifact_data = io .BytesIO (artifact_contents )
480+ artifact_zip = zipfile .ZipFile (artifact_data )
481+ artifact_zip .extractall (path = tmpdir )
482+ if found_artifacts :
483+ (success , results ) = summarize_test_results .summarize_logs (tmpdir , False , False , True )
484+ print ("Results:" , success , " " , results , "\n " )
485+ run ['log_success' ] = success
486+ run ['log_results' ] = results
487+
488+ if not found_artifacts :
489+ # Artifacts expire after some time, so if they are gone, we need
490+ # to read the GitHub logs instead. This is much slower, so we
491+ # prefer to read artifacts instead whenever possible.
492+ logging .info ("Reading github logs for run %s instead" , run ['id' ])
493+
494+ logs_url = run ['logs_url' ]
495+ headers = {'Accept' : 'application/vnd.github.v3+json' , 'Authorization' : 'Bearer %s' % FLAGS .token }
496+ with requests .get (logs_url , headers = headers , stream = True ) as response :
497+ if response .status_code == 200 :
498+ logs_compressed_data = io .BytesIO (response .content )
499+ logs_zip = zipfile .ZipFile (logs_compressed_data )
500+ m = get_message_from_github_log (
501+ logs_zip ,
502+ r'summarize-results/.*Summarize results into GitHub' ,
503+ r'\[error\]INTEGRATION TEST FAILURES\n—+\n(.*)$' )
504+ if m :
505+ run ['log_success' ] = False
506+ m2 = re .match (r'(.*?)^' + day , m .group (1 ), re .MULTILINE | re .DOTALL )
507+ if m2 :
508+ run ['log_results' ] = m2 .group (1 )
509+ else :
510+ run ['log_results' ] = m .group (1 )
511+ logging .debug ("Integration test results: %s" , run ['log_results' ])
512+
504513 tests [day ] = run
505514 bar .next ()
506515
0 commit comments