Skip to content
Open
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: 5 additions & 0 deletions sqlmesh/integrations/github/cicd/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,11 @@ def deploy_to_prod(self) -> None:
"PR is already merged and this event was triggered prior to the merge."
)
merge_status = self._get_merge_state_status()
if merge_status.is_blocked:
raise CICDBotError(
"Merge commit cannot be cleanly created. Likely missing CODEOWNERS approval. "
"Please check PR and resolve any issues."
)
if merge_status.is_dirty:
raise CICDBotError(
"Merge commit cannot be cleanly created. Likely from a merge conflict. "
Expand Down
20 changes: 19 additions & 1 deletion tests/integrations/github/cicd/test_github_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,21 @@ def test_deploy_to_prod_merge_error(github_client, make_controller):
controller.deploy_to_prod()


def test_deploy_to_prod_blocked_pr(github_client, make_controller):
mock_pull_request = github_client.get_repo().get_pull()
mock_pull_request.merged = False
controller = make_controller(
"tests/fixtures/github/pull_request_synchronized.json",
github_client,
merge_state_status=MergeStateStatus.BLOCKED,
)
with pytest.raises(
Exception,
match=r"^Merge commit cannot be cleanly created. Likely missing CODEOWNERS approval.*",
):
controller.deploy_to_prod()


def test_deploy_to_prod_dirty_pr(github_client, make_controller):
mock_pull_request = github_client.get_repo().get_pull()
mock_pull_request.merged = False
Expand All @@ -468,7 +483,10 @@ def test_deploy_to_prod_dirty_pr(github_client, make_controller):
github_client,
merge_state_status=MergeStateStatus.DIRTY,
)
with pytest.raises(Exception, match=r"^Merge commit cannot be cleanly created.*"):
with pytest.raises(
Exception,
match=r"^Merge commit cannot be cleanly created. Likely from a merge conflict.*",
):
controller.deploy_to_prod()


Expand Down