|
| 1 | +# Contributing |
| 2 | + |
| 3 | +## Setup |
| 4 | + |
| 5 | +```bash |
| 6 | +# Install all dependency groups (dev, docs, test) |
| 7 | +uv sync |
| 8 | + |
| 9 | +# Install pre-commit hooks |
| 10 | +uv run pre-commit install --hook-type pre-commit --hook-type commit-msg |
| 11 | +``` |
| 12 | + |
| 13 | +## Development workflow |
| 14 | + |
| 15 | +```bash |
| 16 | +# Run tests |
| 17 | +uv run pytest |
| 18 | + |
| 19 | +# Run a single test file |
| 20 | +uv run pytest tests/test__decorator.py |
| 21 | + |
| 22 | +# Type checking |
| 23 | +uv run mypy cachium |
| 24 | + |
| 25 | +# Run coverage |
| 26 | +uv run coverage run -m pytest && uv run coverage report |
| 27 | + |
| 28 | +# Lint and format manually (pre-commit also runs these) |
| 29 | +uv run ruff check --fix cachium tests |
| 30 | +uv run ruff format cachium tests |
| 31 | +``` |
| 32 | + |
| 33 | +## Commit messages |
| 34 | + |
| 35 | +This project uses [Conventional Commits](https://www.conventionalcommits.org/). The `commit-msg` pre-commit hook enforces this automatically. |
| 36 | + |
| 37 | +Format: `<type>(<optional scope>): <description>` |
| 38 | + |
| 39 | +Allowed types: `build`, `chore`, `ci`, `docs`, `feat`, `fix`, `perf`, `refactor`, `revert`, `style`, `test` |
| 40 | + |
| 41 | +Examples: |
| 42 | +``` |
| 43 | +feat: add Redis storage backend |
| 44 | +fix: prevent dog-pile under high concurrency |
| 45 | +docs: add CacheWith usage example |
| 46 | +chore: bump ruff to v0.16 |
| 47 | +``` |
| 48 | + |
| 49 | +Breaking changes: append `!` after the type or add `BREAKING CHANGE:` in the footer. |
| 50 | + |
| 51 | +## Pre-commit hooks |
| 52 | + |
| 53 | +The following hooks run on every commit: |
| 54 | + |
| 55 | +| Hook | Purpose | |
| 56 | +|------|---------| |
| 57 | +| `check-added-large-files` | Prevent accidental large file commits | |
| 58 | +| `check-json`, `check-yaml`, `check-toml` | Validate config files | |
| 59 | +| `check-merge-conflict` | Catch unresolved merge conflict markers | |
| 60 | +| `detect-private-key` | Block accidental secret commits | |
| 61 | +| `end-of-file-fixer`, `trailing-whitespace` | Normalize whitespace | |
| 62 | +| `no-commit-to-branch` | Block direct commits to `master` | |
| 63 | +| `add-trailing-comma` | Enforce trailing commas | |
| 64 | +| `ruff` | Lint and auto-fix Python code (includes import sorting) | |
| 65 | +| `ruff-format` | Format Python code | |
| 66 | +| `toml-sort` | Keep `pyproject.toml` keys sorted | |
| 67 | +| `conventional-pre-commit` | Enforce conventional commit message format (commit-msg stage) | |
| 68 | + |
| 69 | +## Pull requests |
| 70 | + |
| 71 | +- Direct pushes to `master` are blocked; open a PR instead. |
| 72 | +- PRs should be small and focused. One logical change per PR. |
| 73 | +- All CI checks (tests, type checking, pre-commit) must pass before merging. |
| 74 | + |
| 75 | +## Extending the library |
| 76 | + |
| 77 | +See [CLAUDE.md](CLAUDE.md) / [AGENTS.md](AGENTS.md) for the architecture overview and guidance on adding new storage backends, serializers, and key builders. |
0 commit comments