kicad-mcp/run_tests.py
Lauri Gates a67eb41523 feat: add comprehensive development infrastructure and CI/CD pipeline
- Add GitHub Actions CI/CD workflow with multi-OS testing (Ubuntu, macOS)
- Add pyproject.toml for modern Python packaging with hatchling
- Add pre-commit hooks for code quality (ruff, mypy, trailing whitespace)
- Add Makefile for common development tasks (install, test, lint, format, build)
- Add run_tests.py script for comprehensive test execution
- Update requirements.txt with development dependencies
- Update .gitignore for modern Python tooling (uv, ruff, pytest)
- Add KiCad-specific ignore patterns for backup files

This establishes a robust development workflow with:
- Automated testing on Python 3.10, 3.11, 3.12
- Code formatting and linting with ruff
- Type checking with mypy
- Coverage reporting with pytest-cov
- Package building with uv

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-17 20:29:27 +03:00

62 lines
1.5 KiB
Python

#!/usr/bin/env python3
"""
Test runner for KiCad MCP project.
"""
import subprocess
import sys
from pathlib import Path
def run_command(cmd: list[str], description: str) -> int:
"""Run a command and return the exit code."""
print(f"\n🔍 {description}")
print(f"Running: {' '.join(cmd)}")
try:
result = subprocess.run(cmd, check=False)
if result.returncode == 0:
print(f"{description} passed")
else:
print(f"{description} failed with exit code {result.returncode}")
return result.returncode
except FileNotFoundError:
print(f"❌ Command not found: {cmd[0]}")
return 1
def main():
"""Run all tests and checks."""
project_root = Path(__file__).parent
# Change to project directory
import os
os.chdir(project_root)
exit_code = 0
# Run linting
exit_code |= run_command(["uv", "run", "ruff", "check", "kicad_mcp/", "tests/"], "Lint check")
# Run formatting check
exit_code |= run_command(
["uv", "run", "ruff", "format", "--check", "kicad_mcp/", "tests/"], "Format check"
)
# Run type checking
exit_code |= run_command(["uv", "run", "mypy", "kicad_mcp/"], "Type check")
# Run tests
exit_code |= run_command(["uv", "run", "python", "-m", "pytest", "tests/", "-v"], "Unit tests")
if exit_code == 0:
print("\n🎉 All checks passed!")
else:
print(f"\n💥 Some checks failed (exit code: {exit_code})")
return exit_code
if __name__ == "__main__":
sys.exit(main())