@@ -149,20 +149,21 @@ def create_test_report(msg, ecs_with_res, init_session_state, pr_nrs=None, gist_
149149
150150 # create a gist with a full test report
151151 test_report = []
152- if pr_nrs is not None :
152+ pr_list = []
153+ if pr_nrs :
153154 repo = pr_target_repo or GITHUB_EASYCONFIGS_REPO
154155 pr_urls = ["https://github.com/%s/%s/pull/%s" % (pr_target_account , repo , x ) for x in pr_nrs ]
155- test_report .extend ([
156- "Test report for %s" % ', ' .join (pr_urls ),
157- "" ,
158- ])
156+ pr_list .append ("PR(s) %s" % ', ' .join (pr_urls ))
159157 if easyblock_pr_nrs :
160158 repo = pr_target_repo or GITHUB_EASYBLOCKS_REPO
159+ easyblock_pr_urls = ["https://github.com/%s/%s/pull/%s" % (pr_target_account , repo , x )
160+ for x in easyblock_pr_nrs ]
161+ pr_list .append ("easyblock PR(s) %s" % ', ' .join (easyblock_pr_urls ))
162+ if pr_list :
161163 test_report .extend ([
162- "Test report for https://github.com/%s/%s/pull/%s " % ( pr_target_account , repo , nr )
163- for nr in easyblock_pr_nrs
164+ "Test report for %s " % ', ' . join ( pr_list ),
165+ "" ,
164166 ])
165- test_report .append ("" )
166167 test_report .extend ([
167168 "#### Test result" ,
168169 "%s" % msg ,
@@ -192,11 +193,11 @@ def create_test_report(msg, ecs_with_res, init_session_state, pr_nrs=None, gist_
192193 partial_log_txt = '\n ' .join (logtxt .split ('\n ' )[- 500 :])
193194 descr = "(partial) EasyBuild log for failed build of %s" % ec ['spec' ]
194195
195- if pr_nrs is not None :
196- descr += " (PR #%s)" % ', #' .join (str (x ) for x in pr_nrs )
196+ if pr_nrs :
197+ descr += " (PR(s) #%s)" % ', #' .join (str (x ) for x in pr_nrs )
197198
198199 if easyblock_pr_nrs :
199- descr += "" . join ( " (easyblock PR #%s)" % nr for nr in easyblock_pr_nrs )
200+ descr += " (easyblock PR(s) #%s)" % ', #' . join ( str ( x ) for x in easyblock_pr_nrs )
200201
201202 fn = '%s_partial.log' % os .path .basename (ec ['spec' ])[:- 3 ]
202203 gist_url = create_gist (partial_log_txt , fn , descr = descr , github_user = github_user )
@@ -263,21 +264,32 @@ def upload_test_report_as_gist(test_report, descr=None, fn=None):
263264 return gist_url
264265
265266
266- def post_pr_test_report (pr_nr , repo_type , test_report , msg , init_session_state , success ):
267+ def post_pr_test_report (pr_nrs , repo_type , test_report , msg , init_session_state , success ):
267268 """Post test report in a gist, and submit comment in easyconfigs or easyblocks PR."""
268269
270+ # make sure pr_nrs is a list of strings
271+ if isinstance (pr_nrs , str ):
272+ pr_nrs = [pr_nrs ]
273+ elif isinstance (pr_nrs , int ):
274+ pr_nrs = [str (pr_nrs )]
275+ else :
276+ try :
277+ pr_nrs = [str (x ) for x in pr_nrs ]
278+ except ValueError :
279+ raise EasyBuildError ("Can't convert %s to a list of PR #s." % pr_nrs )
280+
269281 github_user = build_option ('github_user' )
270282 pr_target_account = build_option ('pr_target_account' )
271283 pr_target_repo = build_option ('pr_target_repo' ) or repo_type
272284
273285 # create gist with test report
274- descr = "EasyBuild test report for %s/%s PR #%s" % (pr_target_account , pr_target_repo , pr_nr )
286+ descr = "EasyBuild test report for %s/%s PR(s) #%s" % (pr_target_account , pr_target_repo , ', #' . join ( pr_nrs ) )
275287 timestamp = strftime ("%Y%M%d-UTC-%H-%M-%S" , gmtime ())
276- fn = 'easybuild_test_report_%s_%s_pr%s_%s.md' % (pr_nr , pr_target_account , pr_target_repo , timestamp )
288+ fn = 'easybuild_test_report_%s_%s_pr%s_%s.md' % ('_' . join ( pr_nrs ) , pr_target_account , pr_target_repo , timestamp )
277289 gist_url = upload_test_report_as_gist (test_report ['full' ], descr = descr , fn = fn )
278290
279291 # post comment to report test result
280- system_info = init_session_state ['system_info' ]
292+ system_info = init_session_state ['system_info' ]. copy ()
281293
282294 # also mention CPU architecture name, but only if it's known
283295 if system_info ['cpu_arch_name' ] != UNKNOWN :
@@ -315,9 +327,11 @@ def post_pr_test_report(pr_nr, repo_type, test_report, msg, init_session_state,
315327 ])
316328 comment = '\n ' .join (comment_lines )
317329
318- post_comment_in_issue (pr_nr , comment , account = pr_target_account , repo = pr_target_repo , github_user = github_user )
330+ for pr_nr in pr_nrs :
331+ post_comment_in_issue (pr_nr , comment , account = pr_target_account , repo = pr_target_repo , github_user = github_user )
319332
320- msg = "Test report uploaded to %s and mentioned in a comment in %s PR#%s" % (gist_url , pr_target_repo , pr_nr )
333+ msg = "Test report uploaded to %s and mentioned in a comment in %s PR(s) #%s" % (gist_url , pr_target_repo ,
334+ ', #' .join (pr_nrs ))
321335 return msg
322336
323337
@@ -350,15 +364,13 @@ def overall_test_report(ecs_with_res, orig_cnt, success, msg, init_session_state
350364 test_report = create_test_report (msg , ecs_with_res , init_session_state , pr_nrs = pr_nrs , gist_log = True ,
351365 easyblock_pr_nrs = easyblock_pr_nrs )
352366 if pr_nrs :
353- # upload test report to gist and issue a comment in the PR to notify
354- for pr_nr in pr_nrs :
355- txt = post_pr_test_report (pr_nr , GITHUB_EASYCONFIGS_REPO , test_report , msg , init_session_state ,
356- success )
367+ # upload test report to gist and issue a comment in the PR(s) to notify
368+ txt = post_pr_test_report (pr_nrs , GITHUB_EASYCONFIGS_REPO , test_report , msg , init_session_state ,
369+ success )
357370 elif easyblock_pr_nrs :
358- # upload test report to gist and issue a comment in the easyblocks PR to notify
359- for easyblock_pr_nr in easyblock_pr_nrs :
360- txt = post_pr_test_report (easyblock_pr_nr , GITHUB_EASYBLOCKS_REPO , test_report , msg ,
361- init_session_state , success )
371+ # upload test report to gist and issue a comment in the easyblocks PR(s) to notify
372+ txt = post_pr_test_report (easyblock_pr_nrs , GITHUB_EASYBLOCKS_REPO , test_report , msg ,
373+ init_session_state , success )
362374
363375 else :
364376 # only upload test report as a gist
0 commit comments