Skip to content

Commit fef3600

Browse files
authored
Merge pull request #37 from tadata-org/build-fixes
Build fixes and general repo improvements
2 parents 8d96dd0 + 7e3ed3b commit fef3600

File tree

14 files changed

+397
-116
lines changed

14 files changed

+397
-116
lines changed

.github/dependabot.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"
7+
open-pull-requests-limit: 10
8+
labels:
9+
- "dependencies"
10+
- "github-actions"
11+
12+
- package-ecosystem: "pip"
13+
directory: "/"
14+
schedule:
15+
interval: "weekly"
16+
open-pull-requests-limit: 10
17+
labels:
18+
- "dependencies"
19+
- "python"

.github/workflows/ci.yml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
ruff:
11+
name: Ruff
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- name: Install uv
17+
uses: astral-sh/setup-uv@v5
18+
with:
19+
version: "0.6.12"
20+
enable-cache: true
21+
cache-dependency-glob: "uv.lock"
22+
23+
- name: Set up Python
24+
uses: actions/setup-python@v5
25+
with:
26+
python-version-file: ".python-version"
27+
28+
- name: Install dependencies
29+
run: uv sync --all-extras --dev
30+
31+
- name: Lint with Ruff
32+
run: uv run ruff check .
33+
34+
mypy:
35+
name: MyPy
36+
runs-on: ubuntu-latest
37+
steps:
38+
- uses: actions/checkout@v4
39+
40+
- name: Install uv
41+
uses: astral-sh/setup-uv@v5
42+
with:
43+
version: "0.6.12"
44+
enable-cache: true
45+
cache-dependency-glob: "uv.lock"
46+
47+
- name: Set up Python
48+
uses: actions/setup-python@v5
49+
with:
50+
python-version-file: ".python-version"
51+
52+
- name: Install dependencies
53+
run: uv sync --all-extras --dev
54+
55+
- name: Type check with MyPy
56+
run: uv run mypy .
57+
58+
test:
59+
name: Test Python ${{ matrix.python-version }}
60+
runs-on: ubuntu-latest
61+
strategy:
62+
fail-fast: false
63+
matrix:
64+
python-version: ["3.10", "3.11", "3.12"]
65+
66+
steps:
67+
- uses: actions/checkout@v4
68+
69+
- name: Install uv
70+
uses: astral-sh/setup-uv@v5
71+
with:
72+
version: "0.6.12"
73+
python-version: ${{ matrix.python-version }}
74+
enable-cache: true
75+
cache-dependency-glob: "uv.lock"
76+
77+
- name: Install dependencies
78+
run: uv sync --all-extras --dev
79+
80+
- name: Run tests
81+
run: uv run pytest --cov=fastapi_mcp --cov-report=xml
82+
83+
- name: Upload coverage to Codecov
84+
uses: codecov/codecov-action@v5
85+
with:
86+
token: ${{ secrets.CODECOV_TOKEN }}
87+
fail_ci_if_error: false

.github/workflows/release.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Release
2+
3+
on:
4+
release:
5+
types: [created]
6+
7+
jobs:
8+
deploy:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v4
12+
with:
13+
fetch-depth: 0
14+
15+
- name: Install uv
16+
uses: astral-sh/setup-uv@v5
17+
with:
18+
version: "0.6.12"
19+
enable-cache: true
20+
21+
- name: Set up Python
22+
uses: actions/setup-python@v5
23+
with:
24+
python-version-file: ".python-version"
25+
26+
- name: Install build dependencies
27+
run: |
28+
uv sync --all-extras --dev
29+
uv pip install build twine
30+
31+
- name: Build and publish
32+
env:
33+
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
34+
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
35+
run: |
36+
uv run python -m build
37+
uv run twine check dist/*
38+
uv run twine upload dist/*

.gitignore

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -82,30 +82,6 @@ target/
8282
profile_default/
8383
ipython_config.py
8484

85-
# pyenv
86-
# For a library or package, you might want to ignore these files since the code is
87-
# intended to run in multiple environments; otherwise, check them in:
88-
.python-version
89-
90-
# pipenv
91-
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92-
# However, in case of collaboration, if having platform-specific dependencies or dependencies
93-
# having no cross-platform support, pipenv may install dependencies that don't work, or not
94-
# install all needed dependencies.
95-
Pipfile.lock
96-
97-
# poetry
98-
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
99-
# This is especially recommended for binary packages to ensure reproducibility, and is more
100-
# commonly ignored for libraries.
101-
poetry.lock
102-
103-
# pdm
104-
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
105-
.pdm.toml
106-
.pdm-python
107-
.pdm-build/
108-
10985
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
11086
__pypackages__/
11187

.pre-commit-config.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v5.0.0
4+
hooks:
5+
- id: trailing-whitespace
6+
- id: check-yaml
7+
- id: check-added-large-files
8+
9+
- repo: https://github.com/astral-sh/ruff-pre-commit
10+
rev: v0.9.10
11+
hooks:
12+
- id: ruff
13+
args: [--fix]
14+
- id: ruff-format

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.12

CONTRIBUTING.md

Lines changed: 83 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,114 @@
11
# Contributing to FastAPI-MCP
22

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

55
## Development Setup
66

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

12-
```bash
13-
# Clone your fork
14-
git clone https://github.com/YOUR-USERNAME/fastapi_mcp.git
15-
cd fastapi-mcp
12+
```bash
13+
git clone https://github.com/YOUR-USERNAME/fastapi_mcp.git
14+
cd fastapi-mcp
1615

17-
# Add the upstream remote
18-
git remote add upstream https://github.com/tadata-org/fastapi_mcp.git
19-
```
16+
# Add the upstream remote
17+
git remote add upstream https://github.com/tadata-org/fastapi_mcp.git
18+
```
2019

21-
5. Set up the development environment:
20+
5. Set up the development environment:
2221

23-
```bash
24-
# Create a virtual environment with uv (recommended)
25-
uv venv
26-
source .venv/bin/activate # On Windows: .venv\Scripts\activate
22+
```bash
23+
uv sync
24+
```
2725

28-
# Install development dependencies with uv
29-
uv sync --extra dev
26+
That's it! The `uv sync` command will automatically create and use a virtual environment.
3027
31-
# Alternatively, using pip
32-
# python -m venv venv
33-
# source venv/bin/activate # On Windows: venv\Scripts\activate
34-
# pip install -e ".[dev]"
35-
```
28+
6. Install pre-commit hooks:
29+
30+
```bash
31+
uv run pre-commit install
32+
uv run pre-commit run
33+
```
34+
35+
Pre-commit hooks will automatically run checks (like ruff, formatting, etc.) when you make a commit, ensuring your code follows our style guidelines.
36+
37+
### Running Commands
38+
39+
You have two options for running commands:
40+
41+
1. **With the virtual environment activated**:
42+
```bash
43+
source .venv/bin/activate # On Windows: .venv\Scripts\activate
44+
45+
# Then run commands directly
46+
pytest
47+
mypy .
48+
ruff check .
49+
```
50+
51+
2. **Without activating the virtual environment**:
52+
```bash
53+
# Use uv run prefix for all commands
54+
uv run pytest
55+
uv run mypy .
56+
uv run ruff check .
57+
```
58+
59+
Both approaches work - use whichever is more convenient for you.
60+
61+
> **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.
62+
63+
### Adding Dependencies
64+
65+
When adding new dependencies to the library:
66+
67+
1. **Runtime dependencies** - packages needed to run the application:
68+
```bash
69+
uv add new-package
70+
```
71+
72+
2. **Development dependencies** - packages needed for development, testing, or CI:
73+
```bash
74+
uv add --group dev new-package
75+
```
76+
77+
After adding dependencies, make sure to:
78+
1. Test that everything works with the new package
79+
2. Commit both `pyproject.toml` and `uv.lock` files:
80+
```bash
81+
git add pyproject.toml uv.lock
82+
git commit -m "Add new-package dependency"
83+
```
3684

3785
## Development Process
3886

3987
1. Fork the repository and set the upstream remote
4088
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
4189
3. Make your changes
42-
4. Run type checking (`uv run mypy .`)
43-
5. Run the tests (`uv run pytest`)
44-
6. Format your code (`uv run ruff check .` and `uv run ruff format .`)
90+
4. Run type checking (`mypy .`)
91+
5. Run the tests (`pytest`)
92+
6. Format your code (`ruff check .` and `ruff format .`). Not needed if pre-commit is installed, as it will run it for you.
4593
7. Commit your changes (`git commit -m 'Add some amazing feature'`)
4694
8. Push to the branch (`git push origin feature/amazing-feature`)
47-
9. Open a Pull Request on [the project repository](https://github.com/tadata-org/fastapi_mcp/)
95+
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.
4896

4997
## Code Style
5098

5199
We use the following tools to ensure code quality:
52100

53-
- **ruff** for linting
101+
- **ruff** for linting and formatting
54102
- **mypy** for type checking
55103

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

58106
```bash
59-
# Using uv
60-
uv run ruff check .
61-
uv run mypy .
62-
63-
# Or directly if tools are installed
107+
# Check code formatting and style
64108
ruff check .
109+
ruff format .
110+
111+
# Check types
65112
mypy .
66113
```
67114

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

72119
```bash
73-
# Using uv
74-
uv run pytest
75-
76-
# Or directly
120+
# Run all tests
77121
pytest
78122
```
79123

@@ -96,4 +140,4 @@ Please note we have a code of conduct, please follow it in all your interactions
96140
97141
## Questions?
98142
99-
Don't hesitate to open an issue if you have any questions about contributing to FastAPI-MCP.
143+
Don't hesitate to open an issue if you have any questions about contributing to FastAPI-MCP.

0 commit comments

Comments
 (0)