@@ -1225,11 +1225,20 @@ def request_bot_build_issue_comments(repo_name, pr_number):
12251225 # it is building for)
12261226 # Then, check that it has at least 4 lines so that we can safely index up to that number
12271227 if instance_repo_match and len (comment_body ) >= 4 :
1228+ # Set some defaults
1229+ repo_id = ""
1230+ on_arch = ""
1231+ for_arch = ""
1232+ date = ""
1233+ status = ""
1234+ url = ""
1235+ result = ""
1236+
12281237 log (f"{ fn } (): found bot build response in issue, processing..." )
12291238
12301239 # First, extract the repo_id
12311240 log (f"{ fn } (): found build for repository: { instance_repo_match .group ('repo_id' )} " )
1232- status_table [ 'for repo' ]. append ( instance_repo_match .group ('repo_id' ) )
1241+ repo_id = instance_repo_match .group ('repo_id' )
12331242
12341243 # Then, try to match the architecture we build on.
12351244 # First try this including accelerator, to see if one was defined
@@ -1241,16 +1250,15 @@ def request_bot_build_issue_comments(repo_name, pr_number):
12411250 # Pattern with accelerator matched, append to status_table
12421251 log (f"{ fn } (): found build on architecture: { on_arch_match .group ('on_arch' )} , "
12431252 f"with accelerator { on_arch_match .group ('accelerator' )} " )
1244- status_table ['on arch' ].append (f"`{ on_arch_match .group ('on_arch' )} `, "
1245- f"`{ on_arch_match .group ('accelerator' )} `" )
1253+ on_arch = f"`{ on_arch_match .group ('on_arch' )} `, `{ on_arch_match .group ('accelerator' )} `"
12461254 else :
12471255 # Pattern with accelerator did not match, retry without accelerator
12481256 on_arch_re = template_to_regex (on_arch_fmt )
12491257 on_arch_match = re .match (on_arch_re , comment_body [1 ])
12501258 if on_arch_match :
12511259 # Pattern without accelerator matched, append to status_table
12521260 log (f"{ fn } (): found build on architecture: { on_arch_match .group ('on_arch' )} " )
1253- status_table [ 'on arch' ]. append ( f"`{ on_arch_match .group ('on_arch' )} `" )
1261+ on_arch = f"`{ on_arch_match .group ('on_arch' )} `"
12541262 else :
12551263 # This shouldn't happen: we had an instance_repo_match, but no match for the 'on architecture'
12561264 msg = "Could not match regular expression for extracting the architecture to build on.\n "
@@ -1271,16 +1279,15 @@ def request_bot_build_issue_comments(repo_name, pr_number):
12711279 # Pattern with accelerator matched, append to status_table
12721280 log (f"{ fn } (): found build for architecture: { for_arch_match .group ('for_arch' )} , "
12731281 f"with accelerator { for_arch_match .group ('accelerator' )} " )
1274- status_table ['for arch' ].append (f"`{ for_arch_match .group ('for_arch' )} `, "
1275- f"`{ for_arch_match .group ('accelerator' )} `" )
1282+ for_arch = f"`{ for_arch_match .group ('for_arch' )} `, `{ for_arch_match .group ('accelerator' )} `"
12761283 else :
12771284 # Pattern with accelerator did not match, retry without accelerator
12781285 for_arch_re = template_to_regex (for_arch_fmt )
12791286 for_arch_match = re .match (for_arch_re , comment_body [2 ])
12801287 if for_arch_match :
12811288 # Pattern without accelerator matched, append to status_table
12821289 log (f"{ fn } (): found build for architecture: { for_arch_match .group ('for_arch' )} " )
1283- status_table [ 'for arch' ]. append ( f"`{ for_arch_match .group ('for_arch' )} `" )
1290+ for_arch = f"`{ for_arch_match .group ('for_arch' )} `"
12841291 else :
12851292 # This shouldn't happen: we had an instance_repo_match, but no match for the 'on architecture'
12861293 msg = "Could not match regular expression for extracting the architecture to build for.\n "
@@ -1315,17 +1322,39 @@ def request_bot_build_issue_comments(repo_name, pr_number):
13151322 # add date, status, url to status_table if
13161323 for row in rows :
13171324 if row ['job status' ] == 'finished' :
1318- status_table [ ' date' ]. append ( row ['date' ])
1319- status_table [ ' status' ]. append ( row ['job status' ])
1320- status_table [ ' url' ]. append ( comment ['html_url' ])
1325+ date = row ['date' ]
1326+ status = row ['job status' ]
1327+ url = comment ['html_url' ]
13211328 if 'FAILURE' in row ['comment' ]:
1322- status_table [ ' result' ]. append ( ' :cry: FAILURE')
1329+ result = ' :cry: FAILURE'
13231330 elif 'SUCCESS' in row ['comment' ]:
1324- status_table [ ' result' ]. append ( ' :grin: SUCCESS')
1331+ result = ' :grin: SUCCESS'
13251332 elif 'UNKNOWN' in row ['comment' ]:
1326- status_table [ ' result' ]. append ( ' :shrug: UNKNOWN')
1333+ result = ' :shrug: UNKNOWN'
13271334 else :
1328- status_table ['result' ].append (row ['comment' ])
1335+ result = row ['comment' ]
1336+ elif row ['job status' ] in ['submitted' , 'received' , 'running' ]:
1337+ # Make sure that if the job is not finished yet, we also put something useful in these fields
1338+ # It is useful to know a job is submitted, running, etc
1339+ date = row ['date' ]
1340+ status = row ['job status' ]
1341+ url = comment ['html_url' ]
1342+ result = row ['comment' ]
1343+ else :
1344+ # Don't do anything for the test line for now - we might add an extra entry to the status
1345+ # table later to reflect the test result
1346+ continue
1347+
1348+ # Add all entries to status_table. We do this at the end of this loop so that the operation is
1349+ # more or less 'atomic', i.e. all vectors in the status_table dict have the same length
1350+ status_table ['for repo' ].append (repo_id )
1351+ status_table ['on arch' ].append (on_arch )
1352+ status_table ['for arch' ].append (for_arch )
1353+ status_table ['date' ].append (date )
1354+ status_table ['status' ].append (status )
1355+ status_table ['url' ].append (url )
1356+ status_table ['result' ].append (result )
1357+
13291358 if len (comments ) != 100 :
13301359 break
13311360 return status_table
0 commit comments