Skip to content
New issue

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

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

Already on GitHub? # to your account

Add CONTRIBUTING.md #376

Merged
merged 4 commits into from
Nov 17, 2024
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
10 changes: 10 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Contributing to magentic

1. Fork and clone the repository
2. [Install uv](https://docs.astral.sh/uv/getting-started/installation/)
3. [Install pre-commit](https://pre-commit.com/#install)
4. Run `make install` to install dependencies
5. Run `make test` to run unit tests
6. Run `make format` to format code
7. Run `make lint` to lint code
8. run `make docs` to build docs and `make docs-serve` to serve docs locally
50 changes: 50 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Adapted from https://github.com/pydantic/logfire/blob/main/Makefile

.DEFAULT_GOAL := all

.PHONY: .uv # Check that uv is installed
.uv:
@uv --version || echo 'Please install uv: https://docs.astral.sh/uv/getting-started/installation/'

.PHONY: .pre-commit # Check that pre-commit is installed
.pre-commit:
@pre-commit -V || echo 'Please install pre-commit: https://pre-commit.com/'

.PHONY: install # Install the package, dependencies, and pre-commit for local development
install: .uv .pre-commit
uv sync --frozen
pre-commit install --install-hooks

.PHONY: format # Format the code
format:
uv run ruff format
uv run ruff check --fix

.PHONY: lint # Lint the code
lint:
uv run ruff check
uv run ruff format --check --diff

.PHONY: typecheck # Typecheck the code
typecheck:
uv run mypy .

.PHONY: test # Run the tests
test:
uv run pytest -vv

.PHONY: testcov # Run tests and generate a coverage report
testcov: test
@echo "building coverage html"
uv run coverage html --show-contexts

.PHONY: docs # Build the documentation
docs:
uv run mkdocs build

.PHONY: docs-serve # Build and serve the documentation
docs-serve:
uv run mkdocs serve

.PHONY: all
all: format lint test
7 changes: 6 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ dev = [
"python-dotenv>=1.0.1",
"ruff>=0.3",
"pytest-recording>=0.13.2",
"coverage>=7.6.4",
]
docs = [
"blacken-docs>=1.16.0",
Expand All @@ -44,6 +45,10 @@ docs = [
]
examples = ["ghapi>=1.0.5", "jupyter", "pandas>=2.2.1"]

[tool.coverage.report]
skip_covered = "true"
show_missing = "true"

[tool.mypy]
check_untyped_defs = true
disable_error_code = ["empty-body"]
Expand All @@ -65,7 +70,7 @@ venvPath = "."
venv = ".venv"

[tool.pytest.ini_options]
addopts = "--cov=magentic --cov-report=term-missing --block-network"
addopts = "--block-network --cov-report=html --cov-report=term --cov=magentic"
asyncio_default_fixture_loop_scope = "function"
asyncio_mode = "auto"
markers = [
Expand Down
2 changes: 2 additions & 0 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.