mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-01-07 22:33:57 -05:00
fix(ci): Fix linter exit code on failure (#9777)
The linter currently exits with exit code 0 even if linting fails. This makes the CI linter permissive which isn't good. Changes: - Make linter exit with an error code if a linting step fails - Fix existing formatting issues
This commit is contained in:
committed by
GitHub
parent
91f62c47f9
commit
cb1a3703ad
@@ -1,10 +1,10 @@
|
||||
import logging
|
||||
|
||||
import sentry_sdk
|
||||
from sentry_sdk.integrations.anthropic import AnthropicIntegration
|
||||
from sentry_sdk.integrations.logging import LoggingIntegration
|
||||
|
||||
from backend.util.settings import Settings
|
||||
from sentry_sdk.integrations.anthropic import AnthropicIntegration
|
||||
from sentry_sdk.integrations.launchdarkly import LaunchDarklyIntegration
|
||||
from sentry_sdk.integrations.logging import LoggingIntegration
|
||||
|
||||
|
||||
def sentry_init():
|
||||
|
||||
@@ -21,18 +21,27 @@ def run(*command: str) -> None:
|
||||
)
|
||||
except subprocess.CalledProcessError as e:
|
||||
print(e.output.decode("utf-8"), file=sys.stderr)
|
||||
raise
|
||||
|
||||
|
||||
def lint():
|
||||
try:
|
||||
run("ruff", "check", *TARGET_DIRS, "--exit-zero")
|
||||
run("ruff", "format", "--diff", "--check", LIBS_DIR)
|
||||
run("isort", "--diff", "--check", "--profile", "black", BACKEND_DIR)
|
||||
run("black", "--diff", "--check", BACKEND_DIR)
|
||||
run("pyright", *TARGET_DIRS)
|
||||
except subprocess.CalledProcessError as e:
|
||||
print("Lint failed, try running `poetry run format` to fix the issues: ", e)
|
||||
raise e
|
||||
lint_step_args: list[list[str]] = [
|
||||
["ruff", "check", *TARGET_DIRS, "--exit-zero"],
|
||||
["ruff", "format", "--diff", "--check", LIBS_DIR],
|
||||
["isort", "--diff", "--check", "--profile", "black", BACKEND_DIR],
|
||||
["black", "--diff", "--check", BACKEND_DIR],
|
||||
["pyright", *TARGET_DIRS],
|
||||
]
|
||||
lint_error = None
|
||||
for args in lint_step_args:
|
||||
try:
|
||||
run(*args)
|
||||
except subprocess.CalledProcessError as e:
|
||||
lint_error = e
|
||||
|
||||
if lint_error:
|
||||
print("Lint failed, try running `poetry run format` to fix the issues")
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def format():
|
||||
|
||||
Reference in New Issue
Block a user