Skip to content

Commit a571d52

Browse files
eakmanrqizeigerman
authored andcommitted
feat!: bot commands that run a single step raise on failure (#3195)
1 parent 3e89017 commit a571d52

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

sqlmesh/integrations/github/cicd/command.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,10 @@ def _check_required_approvers(controller: GithubController) -> bool:
5151
@cli_analytics
5252
def check_required_approvers(ctx: click.Context) -> None:
5353
"""Checks if a required approver has provided approval on the PR."""
54-
_check_required_approvers(ctx.obj["github"])
54+
if not _check_required_approvers(ctx.obj["github"]):
55+
raise CICDBotError(
56+
"Required approver has not approved the PR. See check status for more information."
57+
)
5558

5659

5760
def _run_tests(controller: GithubController) -> bool:
@@ -80,7 +83,8 @@ def _run_tests(controller: GithubController) -> bool:
8083
@cli_analytics
8184
def run_tests(ctx: click.Context) -> None:
8285
"""Runs the unit tests"""
83-
_run_tests(ctx.obj["github"])
86+
if not _run_tests(ctx.obj["github"]):
87+
raise CICDBotError("Failed to run tests. See check status for more information.")
8488

8589

8690
def _update_pr_environment(controller: GithubController) -> bool:
@@ -105,7 +109,10 @@ def _update_pr_environment(controller: GithubController) -> bool:
105109
@cli_analytics
106110
def update_pr_environment(ctx: click.Context) -> None:
107111
"""Creates or updates the PR environments"""
108-
_update_pr_environment(ctx.obj["github"])
112+
if not _update_pr_environment(ctx.obj["github"]):
113+
raise CICDBotError(
114+
"Failed to update PR environment. See check status for more information."
115+
)
109116

110117

111118
def _gen_prod_plan(controller: GithubController) -> bool:
@@ -134,7 +141,10 @@ def gen_prod_plan(ctx: click.Context) -> None:
134141
"""Generates the production plan"""
135142
controller = ctx.obj["github"]
136143
controller.update_prod_plan_preview_check(status=GithubCheckStatus.IN_PROGRESS)
137-
_gen_prod_plan(controller)
144+
if not _gen_prod_plan(controller):
145+
raise CICDBotError(
146+
"Failed to generate production plan. See check status for more information."
147+
)
138148

139149

140150
def _deploy_production(controller: GithubController) -> bool:
@@ -171,7 +181,8 @@ def _deploy_production(controller: GithubController) -> bool:
171181
@cli_analytics
172182
def deploy_production(ctx: click.Context) -> None:
173183
"""Deploys the production environment"""
174-
_deploy_production(ctx.obj["github"])
184+
if not _deploy_production(ctx.obj["github"]):
185+
raise CICDBotError("Failed to deploy to production. See check status for more information.")
175186

176187

177188
def _run_all(controller: GithubController) -> None:

0 commit comments

Comments
 (0)