Skip to content

Build fixes and general repo improvements #37

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Apr 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
open-pull-requests-limit: 10
labels:
- "dependencies"
- "github-actions"

- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "weekly"
open-pull-requests-limit: 10
labels:
- "dependencies"
- "python"
87 changes: 87 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: CI

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
ruff:
name: Ruff
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v5
with:
version: "0.6.12"
enable-cache: true
cache-dependency-glob: "uv.lock"

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version-file: ".python-version"

- name: Install dependencies
run: uv sync --all-extras --dev

- name: Lint with Ruff
run: uv run ruff check .

mypy:
name: MyPy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v5
with:
version: "0.6.12"
enable-cache: true
cache-dependency-glob: "uv.lock"

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version-file: ".python-version"

- name: Install dependencies
run: uv sync --all-extras --dev

- name: Type check with MyPy
run: uv run mypy .

test:
name: Test Python ${{ matrix.python-version }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v5
with:
version: "0.6.12"
python-version: ${{ matrix.python-version }}
enable-cache: true
cache-dependency-glob: "uv.lock"

- name: Install dependencies
run: uv sync --all-extras --dev

- name: Run tests
run: uv run pytest --cov=fastapi_mcp --cov-report=xml

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: false
38 changes: 38 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Release

on:
release:
types: [created]

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Install uv
uses: astral-sh/setup-uv@v5
with:
version: "0.6.12"
enable-cache: true

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version-file: ".python-version"

- name: Install build dependencies
run: |
uv sync --all-extras --dev
uv pip install build twine

- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
uv run python -m build
uv run twine check dist/*
uv run twine upload dist/*
24 changes: 0 additions & 24 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -82,30 +82,6 @@ target/
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
.pdm.toml
.pdm-python
.pdm-build/

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

Expand Down
14 changes: 14 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: check-yaml
- id: check-added-large-files

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.9.10
hooks:
- id: ruff
args: [--fix]
- id: ruff-format
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12
122 changes: 83 additions & 39 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,67 +1,114 @@
# Contributing to FastAPI-MCP

First off, thank you for considering contributing to FastAPI-MCP!
First off, thank you for considering contributing to FastAPI-MCP!

## Development Setup

1. Make sure you have Python 3.10+ installed
2. Install [uv](https://docs.astral.sh/uv/getting-started/installation/) (recommended) or pip
3. Fork the repository
4. Clone your fork
1. Make sure you have Python 3.10+ installed
2. Install [uv](https://docs.astral.sh/uv/getting-started/installation/) package manager
3. Fork the repository
4. Clone your fork

```bash
# Clone your fork
git clone https://github.com/YOUR-USERNAME/fastapi_mcp.git
cd fastapi-mcp
```bash
git clone https://github.com/YOUR-USERNAME/fastapi_mcp.git
cd fastapi-mcp

# Add the upstream remote
git remote add upstream https://github.com/tadata-org/fastapi_mcp.git
```
# Add the upstream remote
git remote add upstream https://github.com/tadata-org/fastapi_mcp.git
```

5. Set up the development environment:
5. Set up the development environment:

```bash
# Create a virtual environment with uv (recommended)
uv venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
```bash
uv sync
```

# Install development dependencies with uv
uv sync --extra dev
That's it! The `uv sync` command will automatically create and use a virtual environment.

# Alternatively, using pip
# python -m venv venv
# source venv/bin/activate # On Windows: venv\Scripts\activate
# pip install -e ".[dev]"
```
6. Install pre-commit hooks:

```bash
uv run pre-commit install
uv run pre-commit run
```

Pre-commit hooks will automatically run checks (like ruff, formatting, etc.) when you make a commit, ensuring your code follows our style guidelines.

### Running Commands

You have two options for running commands:

1. **With the virtual environment activated**:
```bash
source .venv/bin/activate # On Windows: .venv\Scripts\activate

# Then run commands directly
pytest
mypy .
ruff check .
```

2. **Without activating the virtual environment**:
```bash
# Use uv run prefix for all commands
uv run pytest
uv run mypy .
uv run ruff check .
```

Both approaches work - use whichever is more convenient for you.

> **Note:** For simplicity, commands in this guide are mostly written **without** the `uv run` prefix. If you haven't activated your virtual environment, remember to prepend `uv run` to all python-related commands and tools.

### Adding Dependencies

When adding new dependencies to the library:

1. **Runtime dependencies** - packages needed to run the application:
```bash
uv add new-package
```

2. **Development dependencies** - packages needed for development, testing, or CI:
```bash
uv add --group dev new-package
```

After adding dependencies, make sure to:
1. Test that everything works with the new package
2. Commit both `pyproject.toml` and `uv.lock` files:
```bash
git add pyproject.toml uv.lock
git commit -m "Add new-package dependency"
```

## Development Process

1. Fork the repository and set the upstream remote
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
3. Make your changes
4. Run type checking (`uv run mypy .`)
5. Run the tests (`uv run pytest`)
6. Format your code (`uv run ruff check .` and `uv run ruff format .`)
4. Run type checking (`mypy .`)
5. Run the tests (`pytest`)
6. Format your code (`ruff check .` and `ruff format .`). Not needed if pre-commit is installed, as it will run it for you.
7. Commit your changes (`git commit -m 'Add some amazing feature'`)
8. Push to the branch (`git push origin feature/amazing-feature`)
9. Open a Pull Request on [the project repository](https://github.com/tadata-org/fastapi_mcp/)
9. Open a Pull Request. Make sure the Pull Request's base branch is [the original repository's](https://github.com/tadata-org/fastapi_mcp/) `main` branch.

## Code Style

We use the following tools to ensure code quality:

- **ruff** for linting
- **ruff** for linting and formatting
- **mypy** for type checking

Please make sure your code passes all checks before submitting a pull request:

```bash
# Using uv
uv run ruff check .
uv run mypy .

# Or directly if tools are installed
# Check code formatting and style
ruff check .
ruff format .

# Check types
mypy .
```

Expand All @@ -70,10 +117,7 @@ mypy .
We use pytest for testing. Please write tests for any new features and ensure all tests pass:

```bash
# Using uv
uv run pytest

# Or directly
# Run all tests
pytest
```

Expand All @@ -96,4 +140,4 @@ Please note we have a code of conduct, please follow it in all your interactions

## Questions?

Don't hesitate to open an issue if you have any questions about contributing to FastAPI-MCP.
Don't hesitate to open an issue if you have any questions about contributing to FastAPI-MCP.
Loading