diff --git a/app/services/github_notifier.py b/app/services/github_notifier.py index f8f08c7..d623cec 100644 --- a/app/services/github_notifier.py +++ b/app/services/github_notifier.py @@ -21,6 +21,9 @@ class GitHubNotifier: def __init__(self, flat_manager_client: FlatManagerClient | None = None): self.flat_manager = flat_manager_client + def _get_flathub_build_url(self, pipeline: Pipeline) -> str: + return f"https://flathub.org/en/builds/{pipeline.id}" + async def notify_build_status( self, pipeline: Pipeline, @@ -212,15 +215,14 @@ async def notify_pr_build_complete( arch_info_comment = f"\n\n*Built for {arch_text} architecture{plural}.*" if status == "committed": + build_url = self._get_flathub_build_url(pipeline) if pipeline.build_id and self.flat_manager: download_url = self.flat_manager.get_flatpakref_url( pipeline.build_id, pipeline.app_id ) - comment = f"✅ [Test build succeeded]({log_url}). To test this build, install it from the testing repository:\n\n```\nflatpak install --user {download_url}\n```{arch_info_comment}" + comment = f"✅ [Test build succeeded]({log_url}). [Build page]({build_url}). To test this build, install it from the testing repository:\n\n```\nflatpak install --user {download_url}\n```{arch_info_comment}" else: - comment = ( - f"✅ [Test build succeeded]({log_url}).{arch_info_comment}" - ) + comment = f"✅ [Test build succeeded]({log_url}). [Build page]({build_url}).{arch_info_comment}" if linter_warnings: warnings_text = "\n".join(f"- {w.strip()}" for w in linter_warnings) comment += ( @@ -229,9 +231,9 @@ async def notify_pr_build_complete( f"{warnings_text}" ) elif status == "failure": - comment = f"❌ [Test build]({log_url}) failed.\n\n{footnote}" + comment = f"❌ [Test build]({log_url}) failed. [Build page]({self._get_flathub_build_url(pipeline)}).\n\n{footnote}" elif status == "cancelled": - comment = f"❌ [Test build]({log_url}) was cancelled.\n\n{footnote}" + comment = f"❌ [Test build]({log_url}) was cancelled. [Build page]({self._get_flathub_build_url(pipeline)}).\n\n{footnote}" elif status == "commit_failure": status = "failure" comment = ( diff --git a/tests/test_github_notifier.py b/tests/test_github_notifier.py index 0c427c1..cabf525 100644 --- a/tests/test_github_notifier.py +++ b/tests/test_github_notifier.py @@ -279,8 +279,10 @@ async def test_notify_pr_build_complete_failure( ): await github_notifier.notify_pr_build_complete(mock_pipeline, "failure") + build_url = f"https://flathub.org/en/builds/{mock_pipeline.id}" expected_comment = ( - "❌ [Test build](https://example.com/logs/123) failed.\n\n" + "❌ [Test build](https://example.com/logs/123) failed. " + f"[Build page]({build_url}).\n\n" "
Help\n\n" "- bot, build - Restart the test build\n" ) @@ -325,8 +327,10 @@ async def test_notify_pr_build_complete_committed_with_download( ): await github_notifier.notify_pr_build_complete(mock_pipeline, "committed") + build_url = f"https://flathub.org/en/builds/{mock_pipeline.id}" expected_comment = ( "✅ [Test build succeeded](https://example.com/logs/123). " + f"[Build page]({build_url}). " "To test this build, install it from the testing repository:\n\n" "```\nflatpak install --user " "https://dl.flathub.org/build-repo/123/org.test.App.flatpakref\n```" @@ -356,10 +360,15 @@ async def test_notify_pr_build_complete_committed_no_build_id( ): await github_notifier.notify_pr_build_complete(mock_pipeline, "committed") + build_url = f"https://flathub.org/en/builds/{mock_pipeline.id}" mock_comment.assert_called_once_with( git_repo="flathub/org.test.App", pr_number=42, - comment="✅ [Test build succeeded](https://example.com/logs/123).\n\n*Built for x86_64 architecture.*", + comment=( + "✅ [Test build succeeded](https://example.com/logs/123). " + f"[Build page]({build_url}).\n\n" + "*Built for x86_64 architecture.*" + ), ) @@ -374,11 +383,13 @@ async def test_notify_pr_build_complete_cancelled(github_notifier, mock_pipeline ): await github_notifier.notify_pr_build_complete(mock_pipeline, "cancelled") + build_url = f"https://flathub.org/en/builds/{mock_pipeline.id}" mock_comment.assert_called_once_with( git_repo="flathub/org.test.App", pr_number=42, comment=( - "❌ [Test build](https://example.com/logs/123) was cancelled.\n\n" + "❌ [Test build](https://example.com/logs/123) was cancelled. " + f"[Build page]({build_url}).\n\n" "
Help\n\n" "- bot, build - Restart the test build\n" "- bot, ping admins - Contact Flathub admins\n"