diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 0179967de..082b4f997 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -39,6 +39,11 @@ jobs: OPENAI_API_KEY: "" NOUS_API_KEY: "" + - name: Syntax guard + run: | + source .venv/bin/activate + python scripts/syntax_guard.py + - name: Green-path E2E run: | source .venv/bin/activate diff --git a/scripts/syntax_guard.py b/scripts/syntax_guard.py new file mode 100755 index 000000000..7c41dc9b4 --- /dev/null +++ b/scripts/syntax_guard.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python3 +"""Syntax guard — compile all Python files to catch syntax errors before merge.""" +import py_compile +import sys +from pathlib import Path + +errors = [] +for p in Path(".").rglob("*.py"): + if ".venv" in p.parts or "__pycache__" in p.parts: + continue + try: + py_compile.compile(str(p), doraise=True) + except py_compile.PyCompileError as e: + errors.append(f"{p}: {e}") + print(f"SYNTAX ERROR: {p}: {e}", file=sys.stderr) + +if errors: + print(f"\n{len(errors)} file(s) with syntax errors", file=sys.stderr) + sys.exit(1) +print("All Python files compile successfully")