Skip to content

Commit a17591f

Browse files
committed
feat: Initial project setup
0 parents  commit a17591f

21 files changed

+1369
-0
lines changed

.github/workflows/tests.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Code Quality Checks
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
checks:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v3
12+
13+
- name: Set up Python
14+
uses: actions/setup-python@v4
15+
with:
16+
python-version: '3.12'
17+
18+
- name: Install uv
19+
run: pip install uv
20+
21+
- name: Install dependencies
22+
run: |
23+
uv pip compile pyproject.toml -o requirements.txt
24+
uv pip compile pyproject.toml --extra dev -o requirements-dev.txt
25+
uv venv
26+
uv pip sync requirements.txt requirements-dev.txt
27+
28+
- name: Determine module name
29+
id: module
30+
run: |
31+
if [ -d "src" ]; then
32+
echo "name=src" >> $GITHUB_OUTPUT
33+
else
34+
MODULE_NAME=$(basename $(find . -maxdepth 1 -type d -not -path "*/\.*" -not -path "./tests" -not -path "./scripts" -not -path "./docker" -not -path "." | sort | head -1))
35+
echo "name=$MODULE_NAME" >> $GITHUB_OUTPUT
36+
fi
37+
38+
- name: Run Linter
39+
run: uv run -m ruff check --fix ${{ steps.module.outputs.name }}
40+
41+
- name: Run Formatter
42+
run: uv run -m ruff format ${{ steps.module.outputs.name }}
43+
44+
- name: Run Tests
45+
run: uv run -m pytest tests --cov=${{ steps.module.outputs.name }} --cov-report=term-missing --cov-report=xml
46+
47+
- name: Run MyPy
48+
run: uv run -m mypy ${{ steps.module.outputs.name }}
49+
50+
- name: Upload coverage to Codecov
51+
uses: codecov/codecov-action@v3
52+
continue-on-error: true
53+
with:
54+
files: coverage.xml
55+
fail_ci_if_error: false

.gitignore

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
.DS_Store
2+
.idea/
3+
.venv/
4+
_build/
5+
notebooks/
6+
setup
7+
conf.py
8+
index.rst
9+
.coverage
10+
*.pyc
11+
setup_mac.sh
12+
docker/.env
13+
.vs_code/*
14+
.mypy_cache/*
15+
.pytest_cache/*
16+
.ruff_cache/*
17+
.aider*
18+
CLAUDE.md

.pre-commit-config.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
repos:
2+
- repo: local
3+
hooks:
4+
- id: lint
5+
name: Run Linter
6+
entry: make lint
7+
language: system
8+
always_run: true
9+
pass_filenames: false
10+
- id: format
11+
name: Run Formatter
12+
entry: make format
13+
language: system
14+
always_run: true
15+
pass_filenames: false
16+
- id: test
17+
name: Run Tests
18+
entry: make test
19+
language: system
20+
always_run: true
21+
pass_filenames: false
22+
- id: mypy
23+
name: Run MyPy
24+
entry: make mypy
25+
language: system
26+
always_run: true
27+
pass_filenames: false

CHANGELOG.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [Unreleased]
9+
10+
### Added
11+
- Integration with uv for dependency management
12+
- Modern Python development tools:
13+
- ruff for linting and formatting
14+
- mypy for type checking
15+
- pytest with coverage reporting
16+
- GitHub Actions workflow for automated testing
17+
- Docker development environment improvements
18+
19+
### Changed
20+
- Switched from pip/venv to uv for environment management
21+
- Updated example code to pass mypy type checking
22+
- Modernized project structure and development workflow
23+
- Updated Python version to 3.12
24+
25+
### Removed
26+
- Legacy dependency management approach
27+
- Outdated Docker configuration elements
28+
29+
### Fixed
30+
- Type hints in example code to pass mypy checks
31+
- Docker environment management
32+
- Development workflow and quality checks
33+
34+
## [0.1.0] - 2024-04-14
35+
- Initial fork from eugeneyan/python-collab-template
36+
- Added Docker environment management
37+
- Setup package installation configuration

CONTRIBUTING.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Contributing to Python Collab Template
2+
3+
Thank you for your interest in contributing to this project!
4+
5+
## Getting Started
6+
7+
1. Fork the repository
8+
2. Clone your fork: `git clone [email protected]:your-username/python-collab-template.git`
9+
3. Create a new branch: `git checkout -b feature-name`
10+
4. Make your changes
11+
5. Run quality checks: `make check`
12+
6. Commit your changes: `git commit -m "Description of changes"`
13+
7. Push to your fork: `git push origin feature-name`
14+
8. Open a Pull Request
15+
16+
## Development Setup
17+
18+
```bash
19+
# Install dependencies and set up environment
20+
make setup
21+
22+
# Run all quality checks
23+
make check
24+
```
25+
26+
## Code Quality Standards
27+
28+
- All code must be typed with proper type hints
29+
- Tests must be included for new features
30+
- Documentation must be updated when necessary
31+
- All quality checks must pass (`make check`)
32+
33+
## Pull Request Process
34+
35+
1. Update the README.md with details of significant changes
36+
2. Update the CHANGELOG.md following the existing format
37+
3. The PR will be merged once you have the sign-off of at least one maintainer
38+
39+
## Questions?
40+
41+
Feel free to open an issue for any questions or concerns.

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 Alex Furrier
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Makefile

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
.PHONY: compile-deps setup clean-pyc clean-test clean-venv clean test mypy lint format check clean-example dev-env refresh-containers rebuild-images build-image push-image
2+
3+
# Module name - will be updated by init script
4+
MODULE_NAME := mcp_filesystem
5+
6+
# Development Setup
7+
#################
8+
compile-deps: # Compile dependencies from pyproject.toml
9+
uv pip compile pyproject.toml -o requirements.txt
10+
uv pip compile pyproject.toml --extra dev -o requirements-dev.txt
11+
12+
PYTHON_VERSION ?= 3.12
13+
14+
ensure-uv: # Install uv if not present
15+
@which uv > /dev/null || (curl -LsSf https://astral.sh/uv/install.sh | sh)
16+
17+
setup: ensure-uv compile-deps ensure-scripts # Install dependencies
18+
UV_PYTHON_VERSION=$(PYTHON_VERSION) uv venv
19+
UV_PYTHON_VERSION=$(PYTHON_VERSION) uv pip sync requirements.txt requirements-dev.txt
20+
$(MAKE) install-hooks
21+
22+
install-hooks: # Install pre-commit hooks if in a git repo with hooks configured
23+
@if [ -d .git ] && [ -f .pre-commit-config.yaml ]; then \
24+
echo "Installing pre-commit hooks..."; \
25+
uv run pre-commit install; \
26+
fi
27+
28+
ensure-scripts: # Ensure scripts directory exists and files are executable
29+
mkdir -p scripts
30+
chmod +x scripts/*.py
31+
32+
# Cleaning
33+
#########
34+
clean-pyc: # Remove Python compilation artifacts
35+
find . -name '*.pyc' -exec rm -f {} +
36+
find . -name '*.pyo' -exec rm -f {} +
37+
find . -name '*~' -exec rm -f {} +
38+
find . -name '__pycache__' -exec rm -fr {} +
39+
40+
clean-test: # Remove test and coverage artifacts
41+
rm -f .coverage
42+
rm -f .coverage.*
43+
44+
clean-venv: # Remove virtual environment
45+
rm -rf .venv
46+
47+
clean: clean-pyc clean-test clean-venv
48+
49+
# Testing and Quality Checks
50+
#########################
51+
test: setup # Run pytest with coverage
52+
uv run -m pytest tests --cov=$(MODULE_NAME) --cov-report=term-missing
53+
54+
mypy: setup # Run type checking
55+
uv run -m mypy $(MODULE_NAME)
56+
57+
lint: setup # Run ruff linter with auto-fix
58+
uv run -m ruff check --fix $(MODULE_NAME)
59+
60+
format: setup # Run ruff formatter
61+
uv run -m ruff format $(MODULE_NAME)
62+
63+
check: setup lint format test mypy # Run all quality checks
64+
65+
# Project Management
66+
##################
67+
clean-example: # Remove example code (use this to start your own project)
68+
rm -rf src/example.py tests/test_example.py
69+
touch src/__init__.py tests/__init__.py
70+
71+
init: setup # Initialize a new project
72+
uv run python scripts/init_project.py
73+
74+
# Docker
75+
########
76+
IMAGE_NAME = container-registry.io/python-collab-template
77+
IMAGE_TAG = latest
78+
79+
dev-env: refresh-containers
80+
@echo "Spinning up a dev environment ."
81+
@docker compose -f docker/docker-compose.yml down
82+
@docker compose -f docker/docker-compose.yml up -d dev
83+
@docker exec -ti composed_dev /bin/bash
84+
85+
refresh-containers:
86+
@echo "Rebuilding containers..."
87+
@docker compose -f docker/docker-compose.yml build
88+
89+
rebuild-images:
90+
@echo "Rebuilding images with the --no-cache flag..."
91+
@docker compose -f docker/docker-compose.yml build --no-cache
92+
93+
build-image:
94+
@echo Building dev image and tagging as ${IMAGE_NAME}:${IMAGE_TAG}
95+
@docker compose -f docker/docker-compose.yml down
96+
@docker compose -f docker/docker-compose.yml up -d dev
97+
@docker tag dev ${IMAGE_NAME}:${IMAGE_TAG}
98+
99+
push-image: build-image
100+
@echo Pushing image to container registry
101+
@docker push ${IMAGE_NAME}:${IMAGE_TAG}

0 commit comments

Comments
 (0)