From e76cb8cb68215f92f0b604ba18a4e6138b0d8ca1 Mon Sep 17 00:00:00 2001 From: Gary Snider <75227981+gsnider2195@users.noreply.github.com> Date: Tue, 3 Sep 2024 15:31:48 -0700 Subject: [PATCH] fix invoke ruff always exiting with zero status --- tasks.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tasks.py b/tasks.py index a772942..cf96000 100644 --- a/tasks.py +++ b/tasks.py @@ -156,7 +156,7 @@ def run_command(context, command, **kwargs): **kwargs.get("env", {}), **kwargs.pop("command_env"), } - context.run(command, **kwargs) + return context.run(command, **kwargs) else: # Check if nautobot is running, no need to start another nautobot container to run a command docker_compose_status = "ps --services --filter status=running" @@ -175,7 +175,7 @@ def run_command(context, command, **kwargs): pty = kwargs.pop("pty", True) - docker_compose(context, compose_command, pty=pty, **kwargs) + return docker_compose(context, compose_command, pty=pty, **kwargs) # ------------------------------------------------------------------------------ @@ -724,12 +724,15 @@ def ruff(context, action=None, target=None, fix=False, output_format="concise"): if not target: target = ["."] + exit_code = 0 + if "format" in action: command = "ruff format " if not fix: command += "--check " command += " ".join(target) - run_command(context, command, warn=True) + if not run_command(context, command, warn=True): + exit_code = 1 if "lint" in action: command = "ruff check " @@ -737,7 +740,10 @@ def ruff(context, action=None, target=None, fix=False, output_format="concise"): command += "--fix " command += f"--output-format {output_format} " command += " ".join(target) - run_command(context, command, warn=True) + if not run_command(context, command, warn=True): + exit_code = 1 + + raise Exit(code=exit_code) @task