Files
my-pal-mcp-server/code_quality_checks.sh
Beehive Innovations 4151c3c3a5 Migration from Docker to Standalone Python Server (#73)
* Migration from docker to standalone server
Migration handling
Fixed tests
Use simpler in-memory storage
Support for concurrent logging to disk
Simplified direct connections to localhost

* Migration from docker / redis to standalone script
Updated tests
Updated run script
Fixed requirements
Use dotenv
Ask if user would like to install MCP in Claude Desktop once
Updated docs

* More cleanup and references to docker removed

* Cleanup

* Comments

* Fixed tests

* Fix GitHub Actions workflow for standalone Python architecture

- Install requirements-dev.txt for pytest and testing dependencies
- Remove Docker setup from simulation tests (now standalone)
- Simplify linting job to use requirements-dev.txt
- Update simulation tests to run directly without Docker

Fixes unit test failures in CI due to missing pytest dependency.

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

Co-Authored-By: Claude <noreply@anthropic.com>

* Remove simulation tests from GitHub Actions

- Removed simulation-tests job that makes real API calls
- Keep only unit tests (mocked, no API costs) and linting
- Simulation tests should be run manually with real API keys
- Reduces CI costs and complexity

GitHub Actions now only runs:
- Unit tests (569 tests, all mocked)
- Code quality checks (ruff, black)

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

Co-Authored-By: Claude <noreply@anthropic.com>

* Fixed tests

* Fixed tests

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-06-18 23:41:22 +04:00

103 lines
2.8 KiB
Bash
Executable File

#!/bin/bash
# Zen MCP Server - Code Quality Checks
# This script runs all required linting and testing checks before committing changes.
# ALL checks must pass 100% for CI/CD to succeed.
set -e # Exit on any error
echo "🔍 Running Code Quality Checks for Zen MCP Server"
echo "================================================="
# Determine Python command
if [[ -f ".zen_venv/bin/python" ]]; then
PYTHON_CMD=".zen_venv/bin/python"
PIP_CMD=".zen_venv/bin/pip"
echo "✅ Using venv"
elif [[ -n "$VIRTUAL_ENV" ]]; then
PYTHON_CMD="python"
PIP_CMD="pip"
echo "✅ Using activated virtual environment: $VIRTUAL_ENV"
else
echo "❌ No virtual environment found!"
echo "Please run: ./run-server.sh first to set up the environment"
exit 1
fi
echo ""
# Check and install dev dependencies if needed
echo "🔍 Checking development dependencies..."
DEV_DEPS_NEEDED=false
# Check each dev dependency
for tool in ruff black isort pytest; do
# Check if tool exists in venv or in PATH
if [[ -f ".zen_venv/bin/$tool" ]] || command -v $tool &> /dev/null; then
continue
else
DEV_DEPS_NEEDED=true
break
fi
done
if [ "$DEV_DEPS_NEEDED" = true ]; then
echo "📦 Installing development dependencies..."
$PIP_CMD install -q -r requirements-dev.txt
echo "✅ Development dependencies installed"
else
echo "✅ Development dependencies already installed"
fi
# Set tool paths
if [[ -f ".zen_venv/bin/ruff" ]]; then
RUFF=".zen_venv/bin/ruff"
BLACK=".zen_venv/bin/black"
ISORT=".zen_venv/bin/isort"
PYTEST=".zen_venv/bin/pytest"
else
RUFF="ruff"
BLACK="black"
ISORT="isort"
PYTEST="pytest"
fi
echo ""
# Step 1: Linting and Formatting
echo "📋 Step 1: Running Linting and Formatting Checks"
echo "--------------------------------------------------"
echo "🔧 Running ruff linting with auto-fix..."
$RUFF check --fix
echo "🎨 Running black code formatting..."
$BLACK .
echo "📦 Running import sorting with isort..."
$ISORT . --skip-glob=".zen_venv/*"
echo "✅ Verifying all linting passes..."
$RUFF check
echo "✅ Step 1 Complete: All linting and formatting checks passed!"
echo ""
# Step 2: Unit Tests
echo "🧪 Step 2: Running Complete Unit Test Suite"
echo "---------------------------------------------"
echo "🏃 Running all unit tests..."
$PYTHON_CMD -m pytest tests/ -v -x
echo "✅ Step 2 Complete: All unit tests passed!"
echo ""
# Step 3: Final Summary
echo "🎉 All Code Quality Checks Passed!"
echo "=================================="
echo "✅ Linting (ruff): PASSED"
echo "✅ Formatting (black): PASSED"
echo "✅ Import sorting (isort): PASSED"
echo "✅ Unit tests: PASSED"
echo ""
echo "🚀 Your code is ready for commit and GitHub Actions!"
echo "💡 Remember to add simulator tests if you modified tools"