-
Notifications
You must be signed in to change notification settings - Fork 219
take into account --include-easyblocks-from-pr when uploading test reports #3446
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
boegel
merged 5 commits into
easybuilders:develop
from
migueldiascosta:upload_test_report_easyblocks
Oct 12, 2020
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
68c97b2
take into account --include-easyblocks-from-pr when uploading test re…
migueldiascosta 1c7f27d
update test for pr_test_report
migueldiascosta d912f95
add overview of tested easyconfigs to test report comment in easybloc…
migueldiascosta fd7d579
use GITHUB_ constants to set repo type in post_pr_test_report
migueldiascosta b34f13f
fix style
migueldiascosta File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -46,7 +46,7 @@ | |
| from easybuild.tools.build_log import EasyBuildError | ||
| from easybuild.tools.config import build_option | ||
| from easybuild.tools.filetools import find_easyconfigs, mkdir, read_file, write_file | ||
| from easybuild.tools.github import GITHUB_EASYCONFIGS_REPO, create_gist, post_comment_in_issue | ||
| from easybuild.tools.github import GITHUB_EASYBLOCKS_REPO, GITHUB_EASYCONFIGS_REPO, create_gist, post_comment_in_issue | ||
| from easybuild.tools.jenkins import aggregate_xml_in_dirs | ||
| from easybuild.tools.parallelbuild import build_easyconfigs_in_parallel | ||
| from 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 | |
| "", | ||
| ]) | ||
|
|
||
| build_overview = [] | ||
| build_overview = ["#### Overview of tested easyconfigs (in order)"] | ||
| for (ec, ec_res) in ecs_with_res: | ||
| test_log = '' | ||
| 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 | |
| test_log = "(partial log available at %s)" % gist_url | ||
|
|
||
| build_overview.append(" * **%s** _%s_ %s" % (test_result, os.path.basename(ec['spec']), test_log)) | ||
| test_report.extend(["#### Overview of tested easyconfigs (in order)"] + build_overview + [""]) | ||
| build_overview.append("") | ||
| test_report.extend(build_overview) | ||
|
|
||
| time_format = "%a, %d %b %Y %H:%M:%S +0000 (UTC)" | ||
| 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 | |
|
|
||
| test_report.extend(["#### Environment", "```"] + environment + ["```"]) | ||
|
|
||
| return '\n'.join(test_report) | ||
| return {'full': '\n'.join(test_report), 'overview': '\n'.join(build_overview)} | ||
|
|
||
|
|
||
| def upload_test_report_as_gist(test_report, descr=None, fn=None): | ||
|
|
@@ -248,18 +249,21 @@ def upload_test_report_as_gist(test_report, descr=None, fn=None): | |
| return gist_url | ||
|
|
||
|
|
||
| def post_easyconfigs_pr_test_report(pr_nr, test_report, msg, init_session_state, success): | ||
| """Post test report in a gist, and submit comment in easyconfigs PR.""" | ||
| def post_pr_test_report(pr_nr, repo, test_report, msg, init_session_state, success): | ||
| """Post test report in a gist, and submit comment in easyconfigs or easyblocks PR.""" | ||
|
|
||
| github_user = build_option('github_user') | ||
| pr_target_account = build_option('pr_target_account') | ||
| pr_target_repo = build_option('pr_target_repo') or GITHUB_EASYCONFIGS_REPO | ||
| if repo == 'easyconfigs': | ||
| pr_target_repo = build_option('pr_target_repo') or GITHUB_EASYCONFIGS_REPO | ||
| else: | ||
| pr_target_repo = build_option('pr_target_repo') or GITHUB_EASYBLOCKS_REPO | ||
|
|
||
| # create gist with test report | ||
| descr = "EasyBuild test report for %s/%s PR #%s" % (pr_target_account, pr_target_repo, pr_nr) | ||
| timestamp = strftime("%Y%M%d-UTC-%H-%M-%S", gmtime()) | ||
| fn = 'easybuild_test_report_%s_%s_pr%s_%s.md' % (pr_nr, pr_target_account, pr_target_repo, timestamp) | ||
| gist_url = upload_test_report_as_gist(test_report, descr=descr, fn=fn) | ||
| gist_url = upload_test_report_as_gist(test_report['full'], descr=descr, fn=fn) | ||
|
|
||
| # post comment to report test result | ||
| system_info = init_session_state['system_info'] | ||
|
|
@@ -276,18 +280,29 @@ def post_easyconfigs_pr_test_report(pr_nr, test_report, msg, init_session_state, | |
| 'pyver': system_info['python_version'].split(' ')[0], | ||
| } | ||
|
|
||
| comment_lines = [ | ||
| "Test report by @%s" % github_user, | ||
| ('**FAILED**', '**SUCCESS**')[success], | ||
| comment_lines = ["Test report by @%s" % github_user] | ||
|
|
||
| easyblocks_pr_nr = build_option('include_easyblocks_from_pr') | ||
| if easyblocks_pr_nr: | ||
| if repo == 'easyconfigs': | ||
| comment_lines.append("Using easyblocks from https://github.com/%s/%s/pull/%s" % ( | ||
| pr_target_account, GITHUB_EASYBLOCKS_REPO, easyblocks_pr_nr)) | ||
| else: | ||
|
||
| comment_lines.append(test_report['overview']) | ||
|
|
||
| if repo == 'easyconfigs': | ||
| comment_lines.append(('**FAILED**', '**SUCCESS**')[success]) | ||
|
|
||
| comment_lines.extend([ | ||
| msg, | ||
| short_system_info, | ||
| "See %s for a full test report." % gist_url, | ||
| ] | ||
| ]) | ||
| comment = '\n'.join(comment_lines) | ||
|
|
||
| post_comment_in_issue(pr_nr, comment, account=pr_target_account, repo=pr_target_repo, github_user=github_user) | ||
|
|
||
| msg = "Test report uploaded to %s and mentioned in a comment in easyconfigs PR#%s" % (gist_url, pr_nr) | ||
| msg = "Test report uploaded to %s and mentioned in a comment in %s PR#%s" % (gist_url, repo, pr_nr) | ||
| return msg | ||
|
|
||
|
|
||
|
|
@@ -302,25 +317,29 @@ def overall_test_report(ecs_with_res, orig_cnt, success, msg, init_session_state | |
| """ | ||
| dump_path = build_option('dump_test_report') | ||
| pr_nr = build_option('from_pr') | ||
| easyblocks_pr_nr = build_option('include_easyblocks_from_pr') | ||
| upload = build_option('upload_test_report') | ||
|
|
||
| if upload: | ||
| msg = msg + " (%d easyconfigs in this PR)" % orig_cnt | ||
| msg = msg + " (%d easyconfigs in total)" % orig_cnt | ||
| test_report = create_test_report(msg, ecs_with_res, init_session_state, pr_nr=pr_nr, gist_log=True) | ||
| if pr_nr: | ||
| # upload test report to gist and issue a comment in the PR to notify | ||
| txt = post_easyconfigs_pr_test_report(pr_nr, test_report, msg, init_session_state, success) | ||
| txt = post_pr_test_report(pr_nr, 'easyconfigs', test_report, msg, init_session_state, success) | ||
| elif easyblocks_pr_nr: | ||
| # upload test report to gist and issue a comment in the easyblocks PR to notify | ||
| txt = post_pr_test_report(easyblocks_pr_nr, 'easyblocks', test_report, msg, init_session_state, success) | ||
| else: | ||
| # only upload test report as a gist | ||
| gist_url = upload_test_report_as_gist(test_report) | ||
| gist_url = upload_test_report_as_gist(test_report['full']) | ||
| txt = "Test report uploaded to %s" % gist_url | ||
| else: | ||
| test_report = create_test_report(msg, ecs_with_res, init_session_state) | ||
| txt = None | ||
| _log.debug("Test report: %s" % test_report) | ||
| _log.debug("Test report: %s" % test_report['full']) | ||
|
|
||
| if dump_path is not None: | ||
| write_file(dump_path, test_report) | ||
| write_file(dump_path, test_report['full']) | ||
| _log.info("Test report dumped to %s" % dump_path) | ||
|
|
||
| return txt | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we manage to enhance this to framework in the future (test reports that is) then we should protect against that by making this a case-stmt instead (of elif) and error out if repo isn't easyconfigs/easyblocks. That way we'll easily catch this one.