diff --git a/packit_service/constants.py b/packit_service/constants.py index 4ad07a94b..fcfdb0e30 100644 --- a/packit_service/constants.py +++ b/packit_service/constants.py @@ -46,6 +46,10 @@ "" ) +MSG_DOWNSTREAM_JOB_ERROR_ROW = ( + '{branch}See {url}\n' +) + MSG_GET_IN_TOUCH = f"\n\n---\n\n*Get in [touch with us]({CONTACTS_URL}) if you need some help.*" MSG_RETRIGGER = ( diff --git a/packit_service/service/urls.py b/packit_service/service/urls.py index faec20308..d3a95a397 100644 --- a/packit_service/service/urls.py +++ b/packit_service/service/urls.py @@ -50,3 +50,7 @@ def get_pull_from_upstream_info_url(id_: int) -> str: def get_openscanhub_info_url(id_: int) -> str: return _get_url_for_dashboard_results("openscanhub", id_) + + +def get_bodhi_update_info_url(id_: int) -> str: + return _get_url_for_dashboard_results("bodhi", id_) diff --git a/packit_service/worker/handlers/bodhi.py b/packit_service/worker/handlers/bodhi.py index edf64e007..c13d7f605 100644 --- a/packit_service/worker/handlers/bodhi.py +++ b/packit_service/worker/handlers/bodhi.py @@ -19,6 +19,7 @@ from packit_service.constants import ( DEFAULT_RETRY_BACKOFF, MSG_DOWNSTREAM_JOB_ERROR_HEADER, + MSG_DOWNSTREAM_JOB_ERROR_ROW, MSG_GET_IN_TOUCH, MSG_RETRIGGER, ) @@ -28,6 +29,7 @@ KojiBuildTargetModel, PipelineModel, ) +from packit_service.service.urls import get_bodhi_update_info_url from packit_service.worker.checker.abstract import Checker from packit_service.worker.checker.bodhi import ( HasIssueCommenterRetriggeringPermissions, @@ -187,7 +189,7 @@ def run(self) -> TaskResults: ) error = str(ex) - errors[target_model.target] = error + errors[target_model.target] = get_bodhi_update_info_url(target_model.id) target_model.set_status("error") target_model.set_data({"error": error}) @@ -198,7 +200,7 @@ def run(self) -> TaskResults: raise error = f"Internal error, please contact us: {ex}" - errors[target_model.target] = error + errors[target_model.target] = get_bodhi_update_info_url(target_model.id) target_model.set_status("error") target_model.set_data({"error": error}) @@ -285,8 +287,8 @@ def report_in_issue_repository(self, errors: dict[str, str]) -> None: object="Bodhi update", dist_git_url=self.packit_api.dg.local_project.git_url, ) - for branch, ex in errors.items(): - body += "" f"{branch}" f"
{ex}
" "\n" + for branch, url in errors.items(): + body += MSG_DOWNSTREAM_JOB_ERROR_ROW.format(branch=branch, url=url) body += "\n" msg_retrigger = MSG_RETRIGGER.format( diff --git a/packit_service/worker/handlers/distgit.py b/packit_service/worker/handlers/distgit.py index 5d18ddcd9..5e3fa9e52 100644 --- a/packit_service/worker/handlers/distgit.py +++ b/packit_service/worker/handlers/distgit.py @@ -34,6 +34,7 @@ CONTACTS_URL, DEFAULT_RETRY_BACKOFF, MSG_DOWNSTREAM_JOB_ERROR_HEADER, + MSG_DOWNSTREAM_JOB_ERROR_ROW, MSG_GET_IN_TOUCH, MSG_RETRIGGER, MSG_RETRIGGER_DISTGIT, @@ -518,11 +519,8 @@ def run(self) -> TaskResults: branch_errors = "" for model in sorted(models_with_errors, key=lambda model: model.branch): dashboard_url = self.get_dashboard_url(model.id) - branch_errors += ( - "" - f"{model.branch}" - f'See {dashboard_url}' - "\n" + branch_errors += MSG_DOWNSTREAM_JOB_ERROR_ROW.format( + branch=model.branch, url=dashboard_url ) branch_errors += "\n" @@ -1072,7 +1070,7 @@ def run(self) -> TaskResults: error += f"\n{ex.stderr_output}" koji_build_model.set_build_submission_stdout(ex.stdout_output) - errors[branch] = error + errors[branch] = get_koji_build_info_url(koji_build_model.id) koji_build_model.set_data({"error": error}) koji_build_model.set_status("error") continue @@ -1091,8 +1089,8 @@ def report_in_issue_repository(self, errors: dict[str, str]) -> None: object="Koji build", dist_git_url=self.packit_api.dg.local_project.git_url, ) - for branch, ex in errors.items(): - body += "" f"{branch}" f"
{ex}
" "\n" + for branch, url in errors.items(): + body += MSG_DOWNSTREAM_JOB_ERROR_ROW.format(branch=branch, url=url) body += "\n" msg_retrigger = MSG_RETRIGGER.format( diff --git a/tests/integration/test_bodhi_update.py b/tests/integration/test_bodhi_update.py index 29d1fbbf0..a7abe29cd 100644 --- a/tests/integration/test_bodhi_update.py +++ b/tests/integration/test_bodhi_update.py @@ -324,6 +324,7 @@ def test_bodhi_update_for_unknown_koji_build_failed_issue_created( group_model = flexmock( grouped_targets=[ flexmock( + id=12, target="rawhide", koji_nvrs="packit-0.43.0-1.fc36", sidetag=None, @@ -447,6 +448,7 @@ def test_bodhi_update_for_unknown_koji_build_failed_issue_comment( group_model = flexmock( grouped_targets=[ flexmock( + id=12, target="rawhide", koji_nvrs="packit-0.43.0-1.fc36", sidetag=None, diff --git a/tests/integration/test_dg_commit.py b/tests/integration/test_dg_commit.py index aaf702ca3..27a9be12b 100644 --- a/tests/integration/test_dg_commit.py +++ b/tests/integration/test_dg_commit.py @@ -511,6 +511,7 @@ def test_downstream_koji_build_failure_issue_created(): nvr = "package-1.2.3-1.fc40" koji_build = flexmock( + id=12, target="main", status="queued", sidetag=None, @@ -620,6 +621,7 @@ def test_downstream_koji_build_failure_issue_comment(): nvr = "package-1.2.3-1.fc40" koji_build = flexmock( + id=12, target="main", status="queued", sidetag=None, diff --git a/tests/integration/test_issue_comment.py b/tests/integration/test_issue_comment.py index 32a70a45e..ab5c86e79 100644 --- a/tests/integration/test_issue_comment.py +++ b/tests/integration/test_issue_comment.py @@ -362,6 +362,7 @@ def mock_repository_issue_retriggering(): nvr_f37 = "package-1.2.3-1.fc37" koji_build_f37 = flexmock( + id=12, target="f37", status="queued", sidetag=None, @@ -376,6 +377,7 @@ def mock_repository_issue_retriggering(): nvr_f38 = "package-1.2.3-1.fc38" koji_build_f38 = flexmock( + id=13, target="f38", status="queued", sidetag=None, @@ -622,7 +624,9 @@ def test_issue_comment_retrigger_koji_build_error_msg( "Packit failed on creating Koji build in dist-git (an url):" "\n\n" "" - "\n
dist-git brancherror
f37
error abc
\n\n" + "f37" + 'See https://localhost/jobs/koji/12' + "\n\n\n" "Fedora Koji build was re-triggered by comment in issue 1.\n\n" "You can retrigger the build by adding a comment " "(`/packit koji-build`) into this issue.\n\n" diff --git a/tests/integration/test_koji_build.py b/tests/integration/test_koji_build.py index 4da324128..bfaf1c972 100644 --- a/tests/integration/test_koji_build.py +++ b/tests/integration/test_koji_build.py @@ -165,6 +165,7 @@ def test_koji_build_error_msg(distgit_push_packit): nvr = "package-1.2.3-1.fc40" koji_build = flexmock( + id=12, target="f36", status="queued", sidetag=None, @@ -211,7 +212,9 @@ def test_koji_build_error_msg(distgit_push_packit): "dist-git branch" "error" "" - "f36
error abc
\n" + "f36" + 'See https://localhost/jobs/koji/12' + "\n" "\n\n" "Fedora Koji build was triggered by push " "with sha ad0c308af91da45cf40b253cd82f07f63ea9cbbf." diff --git a/tests/unit/test_bodhi_update_error_msgs.py b/tests/unit/test_bodhi_update_error_msgs.py index b65030d8e..064f11f00 100644 --- a/tests/unit/test_bodhi_update_error_msgs.py +++ b/tests/unit/test_bodhi_update_error_msgs.py @@ -93,7 +93,8 @@ def test_pull_request_retrigger_bodhi_update_with_koji_data( "in dist-git (an url):\n\n" "" "" - "\n" + "" + '\n' "
dist-git brancherror
f36
error abc
f36See /jobs/bodhi/12
\n\n" "Fedora Bodhi update was re-triggered by comment in dist-git PR with id 123.\n\n" "You can retrigger the update by adding a comment (`/packit create-update`) " @@ -122,6 +123,7 @@ def test_pull_request_retrigger_bodhi_update_with_koji_data( flexmock( grouped_targets=[ flexmock( + id=12, target="f36", koji_nvrs="a_package_1.f36", sidetag=None,