Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions sqlmesh/integrations/github/cicd/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -751,9 +751,8 @@ def update_pr_environment(self) -> None:
vde_title = "- :eyes: To **review** this PR's changes, use virtual data environment:"
comment_value = f"{vde_title}\n - `{self.pr_environment_name}`"
if self.bot_config.enable_deploy_command:
comment_value += (
"\n- :arrow_forward: To **apply** this PR's plan to prod, comment:\n - `/deploy`"
)
full_command = f"{self.bot_config.command_namespace or ''}/deploy"
comment_value += f"\n- :arrow_forward: To **apply** this PR's plan to prod, comment:\n - `{full_command}`"
dedup_regex = vde_title.replace("*", r"\*") + r".*"
updated_comment, _ = self.update_sqlmesh_comment_info(
value=comment_value,
Expand Down
38 changes: 38 additions & 0 deletions tests/integrations/github/cicd/test_github_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -697,3 +697,41 @@ def test_get_pr_environment_summary_includes_warnings_and_errors(
)
assert "> [!WARNING]\n>\n> Warning 1\n" in error_summary
assert "> [!CAUTION]\n>\n> Error 1" in error_summary


def test_pr_comment_deploy_indicator_includes_command_namespace(
mocker: MockerFixture,
github_client,
make_mock_issue_comment,
make_controller: t.Callable[..., GithubController],
):
mock_repo = github_client.get_repo()

created_comments = []
mock_issue = mock_repo.get_issue()
mock_issue.create_comment = mocker.MagicMock(
side_effect=lambda comment: make_mock_issue_comment(
comment=comment, created_comments=created_comments
)
)
mock_issue.get_comments = mocker.MagicMock(side_effect=lambda: created_comments)

controller = make_controller(
"tests/fixtures/github/pull_request_synchronized.json",
github_client,
mock_out_context=False,
bot_config=GithubCICDBotConfig(
enable_deploy_command=True,
merge_method=MergeMethod.SQUASH,
command_namespace="#SQLMesh",
),
)

_update_pr_environment(controller)

assert len(created_comments) > 0

comment = created_comments[0].body

assert "To **apply** this PR's plan to prod, comment:\n - `/deploy`" not in comment
assert "To **apply** this PR's plan to prod, comment:\n - `#SQLMesh/deploy`" in comment
Loading