Skip to content

Commit 0604267

Browse files
runningcodeclaude
authored andcommitted
feat(preprod): Add settings link to build distribution PR comments (#112366)
Build distribution PR comments now include a footer link to the project's mobile builds settings page, matching the pattern already used in size analysis PR comments. <img width="901" height="302" alt="image" src="https://github.com/user-attachments/assets/e07867f3-2538-49cd-8a1e-5c5b29b73fa1" /> Refs EME-1015 --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent e2002bf commit 0604267

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

src/sentry/preprod/vcs/pr_comments/tasks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ def create_preprod_pr_comment_task(
130130
return
131131

132132
existing_comment_id = _find_existing_comment_id(all_for_pr)
133-
comment_body = format_pr_comment(installable_siblings)
133+
comment_body = format_pr_comment(installable_siblings, project=artifact.project)
134134

135135
try:
136136
if existing_comment_id:

src/sentry/preprod/vcs/pr_comments/templates.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
from __future__ import annotations
22

3+
from sentry.models.project import Project
34
from sentry.preprod.models import PreprodArtifact
45
from sentry.preprod.url_utils import get_preprod_artifact_url
56

67

7-
def format_pr_comment(artifacts: list[PreprodArtifact]) -> str:
8+
def format_pr_comment(artifacts: list[PreprodArtifact], project: Project) -> str:
89
if not artifacts:
910
raise ValueError("No installable artifacts to format")
1011

@@ -46,4 +47,9 @@ def format_pr_comment(artifacts: list[PreprodArtifact]) -> str:
4647
else:
4748
sections.append(f"{header}\n{separator}\n" + "\n".join(android_rows))
4849

50+
settings_url = project.organization.absolute_url(
51+
f"/settings/projects/{project.slug}/mobile-builds/", query="tab=distribution"
52+
)
53+
sections.append(f"[Configure {project.name} build distribution settings]({settings_url})")
54+
4955
return "\n\n".join(sections)

tests/sentry/preprod/vcs/pr_comments/test_templates.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def _create_artifact(
5656
def test_single_ios_artifact(self) -> None:
5757
artifact = self._create_artifact()
5858

59-
result = format_pr_comment([artifact])
59+
result = format_pr_comment([artifact], project=self.project)
6060

6161
assert "## Sentry Build Distribution" in result
6262
assert "| App Name | App ID | Version | Configuration | Install Page |" in result
@@ -74,7 +74,7 @@ def test_single_android_artifact(self) -> None:
7474
app_name="AndroidApp",
7575
)
7676

77-
result = format_pr_comment([artifact])
77+
result = format_pr_comment([artifact], project=self.project)
7878

7979
assert "AndroidApp" in result
8080
assert "### Android" not in result
@@ -87,13 +87,21 @@ def test_multiple_platforms_shows_subheaders(self) -> None:
8787
app_name="AndroidApp",
8888
)
8989

90-
result = format_pr_comment([ios_artifact, android_artifact])
90+
result = format_pr_comment([ios_artifact, android_artifact], project=self.project)
9191

9292
assert "### iOS" in result
9393
assert "### Android" in result
9494
assert "iOSApp" in result
9595
assert "AndroidApp" in result
9696

97+
def test_settings_link(self) -> None:
98+
artifact = self._create_artifact()
99+
100+
result = format_pr_comment([artifact], project=self.project)
101+
102+
assert f"[Configure {self.project.name} build distribution settings](" in result
103+
assert f"/settings/projects/{self.project.slug}/mobile-builds/?tab=distribution" in result
104+
97105
def test_empty_list_raises(self) -> None:
98106
with pytest.raises(ValueError, match="No installable artifacts"):
99-
format_pr_comment([])
107+
format_pr_comment([], project=self.project)

0 commit comments

Comments
 (0)