Skip to content

Commit 2953942

Browse files
authored
Fix(cicd_bot): Include namespace in deploy command hint (#5006)
1 parent 47706cf commit 2953942

File tree

2 files changed

+40
-3
lines changed

2 files changed

+40
-3
lines changed

sqlmesh/integrations/github/cicd/controller.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -751,9 +751,8 @@ def update_pr_environment(self) -> None:
751751
vde_title = "- :eyes: To **review** this PR's changes, use virtual data environment:"
752752
comment_value = f"{vde_title}\n - `{self.pr_environment_name}`"
753753
if self.bot_config.enable_deploy_command:
754-
comment_value += (
755-
"\n- :arrow_forward: To **apply** this PR's plan to prod, comment:\n - `/deploy`"
756-
)
754+
full_command = f"{self.bot_config.command_namespace or ''}/deploy"
755+
comment_value += f"\n- :arrow_forward: To **apply** this PR's plan to prod, comment:\n - `{full_command}`"
757756
dedup_regex = vde_title.replace("*", r"\*") + r".*"
758757
updated_comment, _ = self.update_sqlmesh_comment_info(
759758
value=comment_value,

tests/integrations/github/cicd/test_github_controller.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -697,3 +697,41 @@ def test_get_pr_environment_summary_includes_warnings_and_errors(
697697
)
698698
assert "> [!WARNING]\n>\n> Warning 1\n" in error_summary
699699
assert "> [!CAUTION]\n>\n> Error 1" in error_summary
700+
701+
702+
def test_pr_comment_deploy_indicator_includes_command_namespace(
703+
mocker: MockerFixture,
704+
github_client,
705+
make_mock_issue_comment,
706+
make_controller: t.Callable[..., GithubController],
707+
):
708+
mock_repo = github_client.get_repo()
709+
710+
created_comments = []
711+
mock_issue = mock_repo.get_issue()
712+
mock_issue.create_comment = mocker.MagicMock(
713+
side_effect=lambda comment: make_mock_issue_comment(
714+
comment=comment, created_comments=created_comments
715+
)
716+
)
717+
mock_issue.get_comments = mocker.MagicMock(side_effect=lambda: created_comments)
718+
719+
controller = make_controller(
720+
"tests/fixtures/github/pull_request_synchronized.json",
721+
github_client,
722+
mock_out_context=False,
723+
bot_config=GithubCICDBotConfig(
724+
enable_deploy_command=True,
725+
merge_method=MergeMethod.SQUASH,
726+
command_namespace="#SQLMesh",
727+
),
728+
)
729+
730+
_update_pr_environment(controller)
731+
732+
assert len(created_comments) > 0
733+
734+
comment = created_comments[0].body
735+
736+
assert "To **apply** this PR's plan to prod, comment:\n - `/deploy`" not in comment
737+
assert "To **apply** this PR's plan to prod, comment:\n - `#SQLMesh/deploy`" in comment

0 commit comments

Comments
 (0)