name: CI
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main ]
permissions:
contents: read
packages: write
jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v6
with:
enable-cache: true
cache-dependency-glob: "**/pyproject.toml"
- name: Set up Python ${{ matrix.python-version }}
run: uv python install ${{ matrix.python-version }}
- name: Install dependencies
run: |
uv sync --all-extras --dev
- name: Lint with ruff
run: |
uv run ruff check
uv run ruff format --check
- name: Type check with mypy
run: |
uv run mypy src/
- name: Test with pytest
run: |
uv run pytest -v --cov=src/mcp_coroot --cov-report=xml --cov-report=term
- name: Upload coverage to Codecov
if: matrix.python-version == '3.12'
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: jamesbrink/mcp-coroot
files: ./coverage.xml
flags: unittests
name: codecov-umbrella
fail_ci_if_error: false
build:
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v6
- name: Set up Python
run: uv python install 3.12
- name: Build package
run: |
uv build
- name: Check package
run: |
uv run twine check dist/*
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: dist-packages
path: dist/
docker:
runs-on: ubuntu-latest
needs: test
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/'))
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: jamesbrink/mcp-coroot
tags: |
# Rolling latest tag on main branch
type=raw,value=latest,enable={{is_default_branch}}
# Version tags on git tags
type=ref,event=tag
# SHA commit tags
type=sha,prefix={{branch}}-,format=short
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/amd64,linux/arm64