4646from easybuild .tools .build_log import EasyBuildError
4747from easybuild .tools .config import build_option
4848from easybuild .tools .filetools import find_easyconfigs , mkdir , read_file , write_file
49- from easybuild .tools .github import GITHUB_EASYCONFIGS_REPO , create_gist , post_comment_in_issue
49+ from easybuild .tools .github import GITHUB_EASYBLOCKS_REPO , GITHUB_EASYCONFIGS_REPO , create_gist , post_comment_in_issue
5050from easybuild .tools .jenkins import aggregate_xml_in_dirs
5151from easybuild .tools .parallelbuild import build_easyconfigs_in_parallel
5252from easybuild .tools .robot import resolve_dependencies
@@ -160,7 +160,7 @@ def create_test_report(msg, ecs_with_res, init_session_state, pr_nr=None, gist_l
160160 "" ,
161161 ])
162162
163- build_overview = []
163+ build_overview = ["#### Overview of tested easyconfigs (in order)" ]
164164 for (ec , ec_res ) in ecs_with_res :
165165 test_log = ''
166166 if ec_res .get ('success' , False ):
@@ -189,7 +189,8 @@ def create_test_report(msg, ecs_with_res, init_session_state, pr_nr=None, gist_l
189189 test_log = "(partial log available at %s)" % gist_url
190190
191191 build_overview .append (" * **%s** _%s_ %s" % (test_result , os .path .basename (ec ['spec' ]), test_log ))
192- test_report .extend (["#### Overview of tested easyconfigs (in order)" ] + build_overview + ["" ])
192+ build_overview .append ("" )
193+ test_report .extend (build_overview )
193194
194195 time_format = "%a, %d %b %Y %H:%M:%S +0000 (UTC)"
195196 start_time = strftime (time_format , init_session_state ['time' ])
@@ -232,7 +233,7 @@ def create_test_report(msg, ecs_with_res, init_session_state, pr_nr=None, gist_l
232233
233234 test_report .extend (["#### Environment" , "```" ] + environment + ["```" ])
234235
235- return ' \n ' .join (test_report )
236+ return { 'full' : ' \n ' .join (test_report ), 'overview' : ' \n ' . join ( build_overview )}
236237
237238
238239def upload_test_report_as_gist (test_report , descr = None , fn = None ):
@@ -248,18 +249,18 @@ def upload_test_report_as_gist(test_report, descr=None, fn=None):
248249 return gist_url
249250
250251
251- def post_easyconfigs_pr_test_report (pr_nr , test_report , msg , init_session_state , success ):
252- """Post test report in a gist, and submit comment in easyconfigs PR."""
252+ def post_pr_test_report (pr_nr , repo_type , test_report , msg , init_session_state , success ):
253+ """Post test report in a gist, and submit comment in easyconfigs or easyblocks PR."""
253254
254255 github_user = build_option ('github_user' )
255256 pr_target_account = build_option ('pr_target_account' )
256- pr_target_repo = build_option ('pr_target_repo' ) or GITHUB_EASYCONFIGS_REPO
257+ pr_target_repo = build_option ('pr_target_repo' ) or repo_type
257258
258259 # create gist with test report
259260 descr = "EasyBuild test report for %s/%s PR #%s" % (pr_target_account , pr_target_repo , pr_nr )
260261 timestamp = strftime ("%Y%M%d-UTC-%H-%M-%S" , gmtime ())
261262 fn = 'easybuild_test_report_%s_%s_pr%s_%s.md' % (pr_nr , pr_target_account , pr_target_repo , timestamp )
262- gist_url = upload_test_report_as_gist (test_report , descr = descr , fn = fn )
263+ gist_url = upload_test_report_as_gist (test_report [ 'full' ] , descr = descr , fn = fn )
263264
264265 # post comment to report test result
265266 system_info = init_session_state ['system_info' ]
@@ -276,18 +277,31 @@ def post_easyconfigs_pr_test_report(pr_nr, test_report, msg, init_session_state,
276277 'pyver' : system_info ['python_version' ].split (' ' )[0 ],
277278 }
278279
279- comment_lines = [
280- "Test report by @%s" % github_user ,
281- ('**FAILED**' , '**SUCCESS**' )[success ],
280+ comment_lines = ["Test report by @%s" % github_user ]
281+
282+ easyblocks_pr_nr = build_option ('include_easyblocks_from_pr' )
283+ if easyblocks_pr_nr :
284+ if repo_type == GITHUB_EASYCONFIGS_REPO :
285+ comment_lines .append ("Using easyblocks from https://github.com/%s/%s/pull/%s" % (
286+ pr_target_account , GITHUB_EASYBLOCKS_REPO , easyblocks_pr_nr ))
287+ elif repo_type == GITHUB_EASYBLOCKS_REPO :
288+ comment_lines .append (test_report ['overview' ])
289+ else :
290+ raise EasyBuildError ("Don't know how to submit test reports to repo %s." , repo_type )
291+
292+ if repo_type == GITHUB_EASYCONFIGS_REPO :
293+ comment_lines .append (('**FAILED**' , '**SUCCESS**' )[success ])
294+
295+ comment_lines .extend ([
282296 msg ,
283297 short_system_info ,
284298 "See %s for a full test report." % gist_url ,
285- ]
299+ ])
286300 comment = '\n ' .join (comment_lines )
287301
288302 post_comment_in_issue (pr_nr , comment , account = pr_target_account , repo = pr_target_repo , github_user = github_user )
289303
290- msg = "Test report uploaded to %s and mentioned in a comment in easyconfigs PR#%s" % (gist_url , pr_nr )
304+ msg = "Test report uploaded to %s and mentioned in a comment in %s PR#%s" % (gist_url , pr_target_repo , pr_nr )
291305 return msg
292306
293307
@@ -302,25 +316,29 @@ def overall_test_report(ecs_with_res, orig_cnt, success, msg, init_session_state
302316 """
303317 dump_path = build_option ('dump_test_report' )
304318 pr_nr = build_option ('from_pr' )
319+ eb_pr_nr = build_option ('include_easyblocks_from_pr' )
305320 upload = build_option ('upload_test_report' )
306321
307322 if upload :
308- msg = msg + " (%d easyconfigs in this PR )" % orig_cnt
323+ msg = msg + " (%d easyconfigs in total )" % orig_cnt
309324 test_report = create_test_report (msg , ecs_with_res , init_session_state , pr_nr = pr_nr , gist_log = True )
310325 if pr_nr :
311326 # upload test report to gist and issue a comment in the PR to notify
312- txt = post_easyconfigs_pr_test_report (pr_nr , test_report , msg , init_session_state , success )
327+ txt = post_pr_test_report (pr_nr , GITHUB_EASYCONFIGS_REPO , test_report , msg , init_session_state , success )
328+ elif eb_pr_nr :
329+ # upload test report to gist and issue a comment in the easyblocks PR to notify
330+ txt = post_pr_test_report (eb_pr_nr , GITHUB_EASYBLOCKS_REPO , test_report , msg , init_session_state , success )
313331 else :
314332 # only upload test report as a gist
315- gist_url = upload_test_report_as_gist (test_report )
333+ gist_url = upload_test_report_as_gist (test_report [ 'full' ] )
316334 txt = "Test report uploaded to %s" % gist_url
317335 else :
318336 test_report = create_test_report (msg , ecs_with_res , init_session_state )
319337 txt = None
320- _log .debug ("Test report: %s" % test_report )
338+ _log .debug ("Test report: %s" % test_report [ 'full' ] )
321339
322340 if dump_path is not None :
323- write_file (dump_path , test_report )
341+ write_file (dump_path , test_report [ 'full' ] )
324342 _log .info ("Test report dumped to %s" % dump_path )
325343
326344 return txt
0 commit comments