Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix invoke ruff always exiting with zero status #43

Merged
merged 1 commit into from
Sep 13, 2024
Merged
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
14 changes: 10 additions & 4 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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)


# ------------------------------------------------------------------------------
Expand Down Expand Up @@ -724,20 +724,26 @@ 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 "
if fix:
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)
smk4664 marked this conversation as resolved.
Show resolved Hide resolved


@task
Expand Down
Loading