fix: Fixed some of the broken stuff added in the last commit, everything should more or less run now
This commit is contained in:
+162
-28
@@ -1,17 +1,19 @@
|
||||
import nox
|
||||
|
||||
# Configuration for optimized performance
|
||||
PY_VERSIONS = ["3.13"]
|
||||
DEFAULT_PYTHON = "3.13"
|
||||
|
||||
|
||||
@nox.session(python=PY_VERSIONS)
|
||||
def behave(session):
|
||||
"""Run all behaviour scenarios."""
|
||||
session.install("-e", ".[dev]")
|
||||
session.run("behave", "-q", *session.posargs)
|
||||
# Configure nox to use UV backend for 10-100x faster package resolution
|
||||
nox.options.default_venv_backend = "uv"
|
||||
|
||||
|
||||
@nox.session(python=DEFAULT_PYTHON)
|
||||
# =============================================================================
|
||||
# LIGHTWEIGHT SESSIONS (Fast - No ML Dependencies)
|
||||
# =============================================================================
|
||||
|
||||
|
||||
@nox.session(python=DEFAULT_PYTHON, reuse_venv=True, venv_backend="uv")
|
||||
def lint(session):
|
||||
"""Run linting with ruff."""
|
||||
session.install("ruff")
|
||||
@@ -19,7 +21,7 @@ def lint(session):
|
||||
session.run("ruff", "check", ".")
|
||||
|
||||
|
||||
@nox.session(python=DEFAULT_PYTHON)
|
||||
@nox.session(python=DEFAULT_PYTHON, reuse_venv=True, venv_backend="uv")
|
||||
def format(session):
|
||||
"""Format code with ruff."""
|
||||
session.install("ruff")
|
||||
@@ -27,34 +29,166 @@ def format(session):
|
||||
session.run("ruff", "check", "--fix", ".")
|
||||
|
||||
|
||||
@nox.session(python=DEFAULT_PYTHON)
|
||||
@nox.session(python=DEFAULT_PYTHON, reuse_venv=True, venv_backend="uv")
|
||||
def typecheck(session):
|
||||
"""Run type checking with pyright."""
|
||||
session.install("-e", ".[dev]")
|
||||
session.install("pyright")
|
||||
session.install("-e", ".[dev]") # Only dev dependencies, no heavy ML packages
|
||||
session.run("pyright")
|
||||
|
||||
|
||||
@nox.session(python=DEFAULT_PYTHON)
|
||||
def docs(session):
|
||||
"""Build documentation."""
|
||||
session.install("-e", ".[dev]")
|
||||
session.run("mkdocs", "build")
|
||||
@nox.session(python=DEFAULT_PYTHON, reuse_venv=True, venv_backend="uv")
|
||||
def security_tests(session):
|
||||
"""Run security and vulnerability tests."""
|
||||
session.install("-e", ".[dev]") # Removed redundant manual installations
|
||||
session.run("bandit", "-r", "src/", "-f", "json", "-o", "security-report.json")
|
||||
session.run("safety", "check", "--json", "--output", "safety-report.json")
|
||||
session.run("semgrep", "--config=python", "src/", "--json", "--output=semgrep-report.json")
|
||||
|
||||
|
||||
@nox.session(python=DEFAULT_PYTHON)
|
||||
def serve_docs(session):
|
||||
"""Serve documentation locally."""
|
||||
session.install("-e", ".[dev]")
|
||||
session.run("mkdocs", "serve")
|
||||
|
||||
|
||||
# Don't run serve_docs by default
|
||||
nox.options.sessions = ["behave", "lint", "format", "typecheck", "docs", "build"]
|
||||
|
||||
|
||||
@nox.session(python=DEFAULT_PYTHON)
|
||||
@nox.session(python=DEFAULT_PYTHON, reuse_venv=True, venv_backend="uv")
|
||||
def build(session):
|
||||
"""Build distribution packages."""
|
||||
session.install("build")
|
||||
session.run("python", "-m", "build", "--wheel")
|
||||
|
||||
|
||||
@nox.session(python=DEFAULT_PYTHON, reuse_venv=True, venv_backend="uv")
|
||||
def docs(session):
|
||||
"""Build documentation."""
|
||||
session.install("-e", ".[dev]") # Only dev dependencies needed for docs
|
||||
session.run("mkdocs", "build")
|
||||
|
||||
|
||||
@nox.session(python=DEFAULT_PYTHON, reuse_venv=True, venv_backend="uv")
|
||||
def serve_docs(session):
|
||||
"""Serve documentation locally."""
|
||||
session.install("-e", ".[dev]") # Only dev dependencies needed for docs
|
||||
session.run("mkdocs", "serve")
|
||||
|
||||
|
||||
# =============================================================================
|
||||
# BDD/BEHAVE SESSIONS (Medium - Core dependencies only)
|
||||
# =============================================================================
|
||||
|
||||
|
||||
@nox.session(python=PY_VERSIONS, reuse_venv=True, venv_backend="uv")
|
||||
def behave(session):
|
||||
"""Run all behaviour scenarios."""
|
||||
session.install("-e", ".[dev]") # Removed [all] extras - only install core dependencies
|
||||
session.run("behave", "-q", *session.posargs)
|
||||
|
||||
|
||||
@nox.session(python=DEFAULT_PYTHON, reuse_venv=True, venv_backend="uv")
|
||||
def bdd_smoke(session):
|
||||
"""Run BDD smoke tests only."""
|
||||
session.install("-e", ".[dev]") # Removed [all] extras
|
||||
session.run("behave", "-t", "@smoke", "-v", *session.posargs)
|
||||
|
||||
|
||||
@nox.session(python=DEFAULT_PYTHON, reuse_venv=True, venv_backend="uv")
|
||||
def bdd_hypothesis(session):
|
||||
"""Run BDD property-based tests."""
|
||||
session.install("-e", ".[dev]") # Removed [all] extras
|
||||
session.run("behave", "-t", "@hypothesis", "-v", *session.posargs)
|
||||
|
||||
|
||||
# =============================================================================
|
||||
# ML/HEAVY SESSIONS (Slow - Only when ML functionality needed)
|
||||
# =============================================================================
|
||||
|
||||
|
||||
@nox.session(python=DEFAULT_PYTHON, reuse_venv=True, venv_backend="uv")
|
||||
def ml_tests(session):
|
||||
"""Run tests that require ML dependencies (sentence-transformers, torch, etc)."""
|
||||
session.install("-e", ".[dev,all]") # Include ML dependencies only when needed
|
||||
session.run("behave", "-t", "@ml", "-v", *session.posargs)
|
||||
|
||||
|
||||
@nox.session(python=DEFAULT_PYTHON, reuse_venv=True, venv_backend="uv")
|
||||
def performance_tests(session):
|
||||
"""Run performance and memory tests."""
|
||||
session.install("-e", ".[dev,all,performance,monitoring]") # Keep all extras for performance tests
|
||||
session.run("behave", "-t", "@performance", "-v", *session.posargs)
|
||||
|
||||
|
||||
# =============================================================================
|
||||
# LEGACY PYTEST SESSIONS (For compatibility - tests/ directory was removed)
|
||||
# =============================================================================
|
||||
|
||||
|
||||
@nox.session(python=DEFAULT_PYTHON, reuse_venv=True, venv_backend="uv")
|
||||
def unit_tests(session):
|
||||
"""Run unit tests with pytest (legacy - tests migrated to Behave)."""
|
||||
session.install("-e", ".[dev]") # Removed [all] extras and redundant manual installations
|
||||
session.notify("behave") # Delegate to Behave tests
|
||||
session.warn("unit_tests session is deprecated - tests migrated to Behave. Use 'nox -s behave' instead.")
|
||||
|
||||
|
||||
@nox.session(python=DEFAULT_PYTHON, reuse_venv=True, venv_backend="uv")
|
||||
def integration_tests(session):
|
||||
"""Run integration tests (legacy - tests migrated to Behave)."""
|
||||
session.install("-e", ".[dev]") # Removed [all] extras and redundant manual installations
|
||||
session.notify("behave") # Delegate to Behave tests
|
||||
session.warn("integration_tests session is deprecated - tests migrated to Behave. Use 'nox -s behave' instead.")
|
||||
|
||||
|
||||
# =============================================================================
|
||||
# COMPREHENSIVE SESSIONS
|
||||
# =============================================================================
|
||||
|
||||
|
||||
@nox.session(python=DEFAULT_PYTHON, reuse_venv=True, venv_backend="uv")
|
||||
def test_all(session):
|
||||
"""Run comprehensive test suite (optimized for speed)."""
|
||||
session.install("-e", ".[dev]") # Start with lightweight dependencies
|
||||
|
||||
# Run lightweight tests first
|
||||
session.run("behave", "-t", "@smoke", "-q")
|
||||
session.run("behave", "-t", "@hypothesis", "-q")
|
||||
|
||||
# Notify heavy tests to run separately with their own environment
|
||||
session.notify("ml_tests")
|
||||
session.notify("performance_tests")
|
||||
|
||||
|
||||
@nox.session(python=DEFAULT_PYTHON, reuse_venv=True, venv_backend="uv")
|
||||
def coverage_report(session):
|
||||
"""Generate coverage report from Behave tests."""
|
||||
session.install("-e", ".[dev]")
|
||||
session.install("coverage[toml]")
|
||||
|
||||
# Clean up any existing coverage data
|
||||
session.run("coverage", "erase")
|
||||
|
||||
# Run Behave tests with coverage
|
||||
session.run("coverage", "run", "--source=src", "-m", "behave", "features/", "-q")
|
||||
|
||||
# Generate and display coverage reports
|
||||
session.run("coverage", "report", "--show-missing")
|
||||
session.run("coverage", "html")
|
||||
session.run("coverage", "xml")
|
||||
|
||||
session.log("Coverage report generated in htmlcov/ directory")
|
||||
session.log("XML coverage report saved as coverage.xml")
|
||||
session.log("Run 'python -m http.server 8000 --directory htmlcov' to view HTML report")
|
||||
|
||||
|
||||
# =============================================================================
|
||||
# CONFIGURATION
|
||||
# =============================================================================
|
||||
|
||||
# Optimized default sessions - prioritize fast feedback
|
||||
nox.options.sessions = [
|
||||
"lint", # ~5-10 seconds
|
||||
"format", # ~5-10 seconds
|
||||
"typecheck", # ~15-30 seconds
|
||||
"behave", # ~30-60 seconds (without ML deps)
|
||||
"docs", # ~10-20 seconds
|
||||
"build", # ~10-20 seconds
|
||||
"coverage_report", # ~30-60 seconds (without ML deps)
|
||||
]
|
||||
|
||||
# Heavy sessions excluded from default run - run explicitly when needed:
|
||||
# nox -s ml_tests
|
||||
# nox -s performance_tests
|
||||
# nox -s test_all
|
||||
|
||||
Reference in New Issue
Block a user