name: CI
on:
push:
branches: [main, develop]
pull_request:
branches: [main]
workflow_dispatch:
env:
PYTHON_VERSION_DEFAULT: "3.11"
jobs:
lint:
name: Lint Code
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION_DEFAULT }}
- name: Install uv
run: curl -LsSf https://astral.sh/uv/install.sh | sh
- name: Install dependencies
run: |
uv pip install --system ruff black mypy
uv pip install --system -e ".[dev]"
- name: Run Ruff
run: ruff check src/ tests/
- name: Check Black formatting
run: black --check src/ tests/
- name: Run MyPy
run: mypy src/
test:
name: Test Python ${{ matrix.python-version }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
os: [ubuntu-latest, windows-latest, macos-latest]
exclude:
# Skip some combinations to save CI time
- os: windows-latest
python-version: "3.8"
- os: windows-latest
python-version: "3.9"
- os: macos-latest
python-version: "3.8"
- os: macos-latest
python-version: "3.9"
steps:
- uses: actions/checkout@v4
- name: Install OpenSCAD (Ubuntu)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y openscad xvfb
- name: Install OpenSCAD (macOS)
if: runner.os == 'macOS'
run: |
brew update
brew install --cask openscad
- name: Install OpenSCAD (Windows)
if: runner.os == 'Windows'
run: |
choco install openscad -y
echo "C:\Program Files\OpenSCAD" >> $env:GITHUB_PATH
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install uv
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh
shell: bash
- name: Install package with test dependencies
run: |
uv pip install --system -e ".[test]"
- name: Run tests with coverage (Linux)
if: runner.os == 'Linux'
run: |
xvfb-run -a pytest tests/ --cov=openscad_mcp --cov-report=xml --cov-report=term
- name: Run tests with coverage (Windows/macOS)
if: runner.os != 'Linux'
run: |
pytest tests/ --cov=openscad_mcp --cov-report=xml --cov-report=term
- name: Upload coverage to Codecov
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11'
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.xml
fail_ci_if_error: false
integration-test:
name: MCP Integration Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install OpenSCAD
run: |
sudo apt-get update
sudo apt-get install -y openscad xvfb
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION_DEFAULT }}
- name: Install uv
run: curl -LsSf https://astral.sh/uv/install.sh | sh
- name: Install package
run: |
uv pip install --system -e .
- name: Test MCP server startup
run: |
timeout 5 python -m openscad_mcp --help || true
- name: Test basic render
run: |
xvfb-run -a python -c "
import asyncio
from openscad_mcp.server import mcp
async def test():
# Basic smoke test
tools = mcp.list_tools()
assert 'render_single' in [t.name for t in tools]
assert 'check_openscad' in [t.name for t in tools]
print('MCP server initialized successfully')
asyncio.run(test())
"
security-scan:
name: Security Scan
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION_DEFAULT }}
- name: Install dependencies
run: |
pip install safety bandit pip-audit
- name: Run Safety check
run: safety check --json --continue-on-error
continue-on-error: true
- name: Run Bandit security scan
run: bandit -r src/ -f json -o bandit-report.json
continue-on-error: true
- name: Run pip-audit
run: pip-audit --desc
continue-on-error: true
build:
name: Build Distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION_DEFAULT }}
- name: Install uv and build tools
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh
uv pip install --system build twine
- name: Build package
run: python -m build
- name: Check distribution
run: |
twine check dist/*
ls -lh dist/
- name: Test installation from wheel
run: |
uv pip install --system dist/*.whl
python -m openscad_mcp --help || true
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/
retention-days: 7
test-uv-install:
name: Test uv Installation
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v4
- name: Install uv
run: curl -LsSf https://astral.sh/uv/install.sh | sh
- name: Test local installation with uv
run: |
# Test installing from local path
uv pip install --system .
# Test that the command is available
which openscad-mcp || echo "Command not in PATH"
python -m openscad_mcp --help || true
- name: Test uvx execution
run: |
# This would work once published to PyPI
# For now, test with local path
echo "uvx execution will work after PyPI publication"
echo "Command: uvx --from openscad-mcp openscad-mcp"