Skip to content

AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.

fix(ci): Fix linter exit code on failure (#9777)

Reinier van der Leercb1a3703ad33
diff --git a/autogpt_platform/backend/backend/util/metrics.py b/autogpt_platform/backend/backend/util/metrics.py
index 4ff7cfe687..f6a2ab5676 100644
--- a/autogpt_platform/backend/backend/util/metrics.py
+++ b/autogpt_platform/backend/backend/util/metrics.py
@@ -1,11 +1,11 @@
import logging
-import sentry_sdk
-from backend.util.settings import Settings
+import sentry_sdk
from sentry_sdk.integrations.anthropic import AnthropicIntegration
-from sentry_sdk.integrations.launchdarkly import LaunchDarklyIntegration
from sentry_sdk.integrations.logging import LoggingIntegration
+from backend.util.settings import Settings
+
def sentry_init():
sentry_dsn = Settings().secrets.sentry_dsn
diff --git a/autogpt_platform/backend/linter.py b/autogpt_platform/backend/linter.py
index d508bb1c5c..a86e6761f7 100644
--- a/autogpt_platform/backend/linter.py
+++ b/autogpt_platform/backend/linter.py
@@ -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():