name: CI
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main ]
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v4
with:
version: "latest"
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
uv pip install --system -e ".[dev,http]"
uv pip install --system pytest-cov pytest-xdist coverage[toml]
- name: Run linting
run: |
uv run ruff check src/
uv run black --check src/ tests/
- name: Run type checking
run: |
uv run mypy src/berry_mcp/
- name: Run tests with coverage
run: |
timeout 300 pytest tests/ --cov=berry_mcp --cov-report=xml --cov-report=term-missing -v
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
file: ./coverage.xml
flags: unittests
name: codecov-umbrella
fail_ci_if_error: false
token: ${{ secrets.CODECOV_TOKEN }}
integration-test:
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v4
with:
version: "latest"
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install dependencies
run: |
uv pip install --system -e ".[dev,http]"
- name: Test server startup (stdio)
run: |
timeout 10s uv run python -m berry_mcp --help || true
- name: Test tool registry functionality
run: |
uv run python -c "
from berry_mcp.core.registry import ToolRegistry
from berry_mcp.tools import pdf_tools
registry = ToolRegistry()
registry.auto_discover_tools(pdf_tools)
tools = registry.list_tools()
print(f'Loaded {len(tools)} PDF tools: {tools}')
assert len(tools) >= 2, f'Expected at least 2 tools, got {len(tools)}'
"
- name: Test HTTP server startup
run: |
echo "Testing HTTP server startup..."
# Start server in background with timeout
timeout 10s uv run python -m berry_mcp --transport http --port 9999 > server.log 2>&1 &
SERVER_PID=$!
sleep 3
# Test if server is responding
if curl -f http://localhost:9999/ -o /dev/null -s; then
echo "HTTP server is responding correctly"
else
echo "HTTP server test skipped (FastAPI may not be available)"
fi
# Clean up
kill $SERVER_PID 2>/dev/null || true
wait $SERVER_PID 2>/dev/null || true