feat(ci): Add syntax guard to prevent broken Python from reaching main
Some checks failed
Forge CI / smoke-and-build (pull_request) Failing after 2s

- scripts/syntax_guard.py runs py_compile on all .py files
- Integrated into Forge CI workflow before green-path E2E
- Catches syntax errors that could kill the consciousness loop

Closes #82
This commit is contained in:
2026-04-07 02:17:01 +00:00
parent 97f63a0d89
commit 4f72bf2a48
2 changed files with 25 additions and 0 deletions

20
scripts/syntax_guard.py Executable file
View File

@@ -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")