Skip to content

Commit

Permalink
Dagger: Return true on valid exit in Dagger Commands (airbytehq#25333)
Browse files Browse the repository at this point in the history
* Return true on valid exit

* Update return type to bool
  • Loading branch information
bnchrch authored and btkcodedev committed Apr 26, 2023
1 parent 919a1bc commit 5b397f7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ def metadata(ctx: click.Context):
@metadata.command(cls=DaggerPipelineCommand, help="Commands related to validating the metadata files.")
@click.option("--modified-only/--all", default=True)
@click.pass_context
def validate(ctx: click.Context, modified_only: bool):
def validate(ctx: click.Context, modified_only: bool) -> bool:
if modified_only:
modified_files = ctx.obj["modified_files_in_branch"]
metadata_to_validate = get_modified_metadata_files(modified_files)
if not metadata_to_validate:
click.secho("No modified metadata found. Skipping metadata validation.")
return
return True
else:
click.secho("Will run metadata validation on all the metadata files found in the repo.")
metadata_to_validate = get_all_metadata_files()
Expand Down Expand Up @@ -69,16 +69,16 @@ def validate(ctx: click.Context, modified_only: bool):
)
@click.option("--modified-only/--all", default=True)
@click.pass_context
def upload(ctx: click.Context, gcs_bucket_name: str, gcs_credentials: str, modified_only: bool):
def upload(ctx: click.Context, gcs_bucket_name: str, gcs_credentials: str, modified_only: bool) -> bool:
if modified_only:
if ctx.obj["ci_context"] is not CIContext.MASTER and ctx.obj["git_branch"] != "master":
click.secho("Not on the master branch. Skipping metadata upload.")
return
return True
modified_files = ctx.obj["modified_files_in_commit"]
metadata_to_upload = get_modified_metadata_files(modified_files)
if not metadata_to_upload:
click.secho("No modified metadata found. Skipping metadata upload.")
return
return True
else:
metadata_to_upload = get_all_metadata_files()

Expand Down Expand Up @@ -109,7 +109,7 @@ def deploy(ctx: click.Context):

@deploy.command(cls=DaggerPipelineCommand, name="orchestrator", help="Deploy the metadata service orchestrator to production")
@click.pass_context
def deploy_orchestrator(ctx: click.Context):
def deploy_orchestrator(ctx: click.Context) -> bool:
return anyio.run(
run_metadata_orchestrator_deploy_pipeline,
ctx.obj["is_local"],
Expand All @@ -132,7 +132,7 @@ def test(ctx: click.Context):

@test.command(cls=DaggerPipelineCommand, name="lib", help="Run tests for the metadata service library.")
@click.pass_context
def test_lib(ctx: click.Context):
def test_lib(ctx: click.Context) -> bool:
return anyio.run(
run_metadata_lib_test_pipeline,
ctx.obj["is_local"],
Expand All @@ -146,7 +146,7 @@ def test_lib(ctx: click.Context):

@test.command(cls=DaggerPipelineCommand, name="orchestrator", help="Run tests for the metadata service orchestrator.")
@click.pass_context
def test_orchestrator(ctx: click.Context):
def test_orchestrator(ctx: click.Context) -> bool:
return anyio.run(
run_metadata_orchestrator_test_pipeline,
ctx.obj["is_local"],
Expand Down
4 changes: 2 additions & 2 deletions tools/ci_connector_ops/ci_connector_ops/pipelines/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,11 +291,11 @@ def invoke(self, ctx: click.Context) -> Any:
Any: The invocation return value.
"""
command_name = self.name
click.secho(f"Running {command_name}...")
click.secho(f"Running Dagger Command {command_name}...")
try:
pipeline_success = super().invoke(ctx)
if not pipeline_success:
raise DaggerError(f"{command_name} failed.")
raise DaggerError(f"Dagger Command {command_name} failed.")
except DaggerError as e:
click.secho(str(e), err=True, fg="red")
return sys.exit(1)
Expand Down

0 comments on commit 5b397f7

Please sign in to comment.