From d23834b0e54b6af34d42f2aecac6a82074a2a947 Mon Sep 17 00:00:00 2001 From: Erin Drummond Date: Thu, 24 Jul 2025 00:50:16 +0000 Subject: [PATCH] Fix(cicd_bot): Include namespace in deploy command hint --- .../integrations/github/cicd/controller.py | 5 +-- .../github/cicd/test_github_controller.py | 38 +++++++++++++++++++ 2 files changed, 40 insertions(+), 3 deletions(-) diff --git a/sqlmesh/integrations/github/cicd/controller.py b/sqlmesh/integrations/github/cicd/controller.py index 48ec7ee32e..cc1131deff 100644 --- a/sqlmesh/integrations/github/cicd/controller.py +++ b/sqlmesh/integrations/github/cicd/controller.py @@ -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, diff --git a/tests/integrations/github/cicd/test_github_controller.py b/tests/integrations/github/cicd/test_github_controller.py index 099ed6d9ef..f1be97ee20 100644 --- a/tests/integrations/github/cicd/test_github_controller.py +++ b/tests/integrations/github/cicd/test_github_controller.py @@ -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