fix: 10 пунктов ревью — /run (кортеж store.add), валидация limit/offset в панели, close() соединений SQLite, троттлинг под локом, read-only бот без OMNI_BOT_OWNERS, eviction JOBS, push_new отдаёт свежие записи, ai.py не спит после последней попытки, дедуп реестра, подключён abuse-реестр (+191 источник); tests/test_regress.py 16 проверок + CI py3.10-3.12
This commit is contained in:
@@ -8,6 +8,7 @@ from __future__ import annotations
|
||||
import json
|
||||
import os
|
||||
import py_compile
|
||||
import subprocess
|
||||
import sqlite3
|
||||
import sys
|
||||
import time
|
||||
@@ -35,6 +36,17 @@ def one(con, sql, args=(), default=0):
|
||||
return r[0][0] if r and r[0][0] is not None else default
|
||||
|
||||
|
||||
def run_tests():
|
||||
"""Тесты — часть самоаудита: без них «работает» держится на памяти."""
|
||||
try:
|
||||
r = subprocess.run([sys.executable, "-m", "pytest", "tests", "-q"],
|
||||
cwd=str(ROOT), capture_output=True, text=True, timeout=300)
|
||||
except Exception as e:
|
||||
return {"ok": False, "note": type(e).__name__}
|
||||
tail = (r.stdout or "").strip().splitlines()
|
||||
return {"ok": r.returncode == 0, "note": tail[-1][:120] if tail else ""}
|
||||
|
||||
|
||||
def compile_all():
|
||||
bad = []
|
||||
for p in sorted((ROOT / "omni").glob("*.py")):
|
||||
@@ -48,6 +60,7 @@ def compile_all():
|
||||
def collect():
|
||||
st: dict = {"ts": datetime.now(timezone.utc).isoformat(timespec="seconds")}
|
||||
st["compile_errors"] = compile_all()
|
||||
st["tests"] = run_tests()
|
||||
|
||||
from omni import sources, taxonomy # noqa: E402
|
||||
|
||||
@@ -93,6 +106,8 @@ def collect():
|
||||
problems = []
|
||||
if st["compile_errors"]:
|
||||
problems.append(f"compile: {len(st['compile_errors'])} файлов")
|
||||
if not (st.get("tests") or {}).get("ok"):
|
||||
problems.append(f"тесты: {(st.get('tests') or {}).get('note', 'fail')}")
|
||||
if not st["has_types_col"]:
|
||||
problems.append("нет колонки items.types")
|
||||
if st["items"] and st["typed"] < st["items"] * 0.95:
|
||||
@@ -131,6 +146,7 @@ _обновлено {st['ts']}_
|
||||
|---|---|
|
||||
{rows}
|
||||
|
||||
тесты: {(st.get('tests') or {}).get('note') or '-'}
|
||||
самоаудит: {'OK' if not problems else '; '.join(problems)}
|
||||
<!-- STATS:END -->"""
|
||||
return block
|
||||
@@ -165,7 +181,8 @@ def main():
|
||||
print(json.dumps(st, ensure_ascii=False, indent=1))
|
||||
else:
|
||||
print(f"items={st.get('items')} typed={st.get('typed')} sources={st.get('sources')} "
|
||||
f"priced={st.get('priced')} runs={st.get('runs')} problems={st.get('problems') or 'OK'}")
|
||||
f"priced={st.get('priced')} runs={st.get('runs')} "
|
||||
f"tests={(st.get('tests') or {}).get('ok')} problems={st.get('problems') or 'OK'}")
|
||||
return 0
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user