Skip to content

Commit

Permalink
Switch to HTML table for downstream error reporting
Browse files Browse the repository at this point in the history
Fixes #1865
  • Loading branch information
kapr200 committed Oct 1, 2024
1 parent eac0440 commit dd7833e
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 17 deletions.
7 changes: 5 additions & 2 deletions packit_service/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,11 @@
MSG_DOWNSTREAM_JOB_ERROR_HEADER = (
"Packit failed on creating {object} in dist-git "
"({dist_git_url}):\n\n"
"| dist-git branch | error |\n"
"| --------------- | ----- |\n"
"<table>"
"<tr>"
"<th>dist-git branch</th>"
"<th>error</th>"
"</tr>"
)

MSG_GET_IN_TOUCH = (
Expand Down
8 changes: 7 additions & 1 deletion packit_service/worker/handlers/bodhi.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,13 @@ 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}` | ```{ex}``` |\n"
body += (
"<tr>"
f"<td><code>{branch}</code></td>"
f"<td><pre>{ex}</pre></td>"
"</tr>\n"
)
body += "</table>\n"

msg_retrigger = MSG_RETRIGGER.format(
job="update",
Expand Down
17 changes: 15 additions & 2 deletions packit_service/worker/handlers/distgit.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,14 @@ 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}` | See {dashboard_url} |\n"
branch_errors += (
"<tr>"
f"<td><code>{model.branch}</code></td>"
f'<td>See <a href="{dashboard_url}">{dashboard_url}</a></td>'
"</tr>\n"
)
branch_errors += "</table>\n"

body_msg = MSG_DOWNSTREAM_JOB_ERROR_HEADER.format(
object="pull-requests",
dist_git_url=self.packit_api.dg.local_project.git_url,
Expand Down Expand Up @@ -873,7 +880,13 @@ 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}` | ```{ex}``` |\n"
body += (
"<tr>"
f"<td><code>{branch}</code></td>"
f"<td><pre>{ex}</pre></td>"
"</tr>\n"
)
body += "</table>\n"

msg_retrigger = MSG_RETRIGGER.format(
job="build",
Expand Down
5 changes: 3 additions & 2 deletions tests/integration/test_issue_comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -590,8 +590,9 @@ def test_issue_comment_retrigger_koji_build_error_msg(
).and_return(packit_api)
msg = (
"Packit failed on creating Koji build in dist-git (an url):"
"\n\n| dist-git branch | error |\n| --------------- | ----- |\n"
"| `f37` | ```error abc``` |\n\n"
"\n\n<table><tr>"
"<th>dist-git branch</th><th>error</th></tr>"
"<tr><td><code>f37</code></td><td><pre>error abc</pre></td></tr>\n</table>\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"
Expand Down
11 changes: 8 additions & 3 deletions tests/integration/test_koji_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,14 @@ def test_koji_build_error_msg(distgit_push_packit):
packit_api
)
msg = (
"Packit failed on creating Koji build in dist-git (an url):"
"\n\n| dist-git branch | error |\n| --------------- | ----- |"
"\n| `f36` | ```error abc``` |\n\n"
"Packit failed on creating Koji build in dist-git (an url):\n\n"
"<table>"
"<tr>"
"<th>dist-git branch</th>"
"<th>error</th>"
"</tr>"
"<tr><td><code>f36</code></td><td><pre>error abc</pre></td></tr>\n"
"</table>\n\n"
"Fedora Koji build was triggered by push "
"with sha ad0c308af91da45cf40b253cd82f07f63ea9cbbf."
"\n\nYou can retrigger the build by adding a comment "
Expand Down
15 changes: 11 additions & 4 deletions tests/integration/test_release_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -606,8 +606,12 @@ def test_dist_git_push_release_handle_all_failed(
for model in sorted(
propose_downstream_target_models, key=lambda model: model.branch
):
dashboard_url = get_propose_downstream_info_url(model.id)
table_content += (
f"| `{model.branch}` | See {get_propose_downstream_info_url(model.id)} |\n"
"<tr>"
f"<td><code>{model.branch}</code></td>"
f'<td>See <a href="{dashboard_url}">{dashboard_url}</a></td>'
"</tr>\n"
)
project = (
flexmock(
Expand All @@ -626,9 +630,12 @@ def test_dist_git_push_release_handle_all_failed(
title="[packit] Propose downstream failed for release 0.3.0",
body="Packit failed on creating pull-requests in dist-git "
"(https://src.fedoraproject.org/rpms/hello-world.git):\n\n"
"| dist-git branch | error |\n"
"| --------------- | ----- |\n"
f"{table_content}\n\n"
"<table>"
"<tr>"
"<th>dist-git branch</th>"
"<th>error</th>"
"</tr>"
f"{table_content}</table>\n\n\n"
"You can retrigger the update by adding a comment (`/packit propose-downstream`)"
" into this issue.\n",
)
Expand Down
7 changes: 4 additions & 3 deletions tests/unit/test_bodhi_update_error_msgs.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,10 @@ def test_pull_request_retrigger_bodhi_update_with_koji_data(
msg = (
"Packit failed on creating Bodhi update "
"in dist-git (an url):\n\n"
"| dist-git branch | error |\n"
"| --------------- | ----- |\n"
"| `f36` | ```error abc``` |\n\n"
"<table>"
"<tr><th>dist-git branch</th><th>error</th></tr>"
"<tr><td><code>f36</code></td><td><pre>error abc</pre></td></tr>\n"
"</table>\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`) "
"into this issue.\n\n---\n\n"
Expand Down

0 comments on commit dd7833e

Please sign in to comment.