|
| 1 | +# Contributing |
| 2 | + |
| 3 | +Thank you for your interest in contributing to redis_func_cache! This document provides guidelines and information to help you contribute effectively to the project. |
| 4 | + |
| 5 | +## Code of Conduct |
| 6 | + |
| 7 | +By participating in this project, you are expected to uphold our Code of Conduct, which promotes a welcoming and inclusive environment for all contributors. |
| 8 | + |
| 9 | +## How to Contribute |
| 10 | + |
| 11 | +### Reporting Bugs |
| 12 | + |
| 13 | +Before reporting a bug, please check the existing issues to see if it has been reported. If not, create a new issue with: |
| 14 | + |
| 15 | +- A clear and descriptive title |
| 16 | +- A detailed description of the problem |
| 17 | +- Steps to reproduce the issue |
| 18 | +- Expected vs. actual behavior |
| 19 | +- Your environment information (Python version, Redis version, OS, etc.) |
| 20 | + |
| 21 | +### Suggesting Enhancements |
| 22 | + |
| 23 | +We welcome feature requests and suggestions. To propose an enhancement: |
| 24 | + |
| 25 | +1. Check existing issues to avoid duplicates |
| 26 | +2. Create a new issue with a clear title and detailed description |
| 27 | +3. Explain why this enhancement would be useful |
| 28 | +4. If possible, provide examples of how the feature would be used |
| 29 | + |
| 30 | +### Code Contributions |
| 31 | + |
| 32 | +#### Development Setup |
| 33 | + |
| 34 | +1. Fork the repository |
| 35 | +2. Clone your fork: |
| 36 | + ```bash |
| 37 | + git clone https://github.com/your-username/redis_func_cache.git |
| 38 | + cd redis_func_cache |
| 39 | + ``` |
| 40 | +3. Install [uv](https://docs.astral.sh/uv/) if you haven't already: |
| 41 | + ```bash |
| 42 | + # On macOS and Linux |
| 43 | + curl -LsSf https://astral.sh/uv/install.sh | sh |
| 44 | + |
| 45 | + # On Windows |
| 46 | + powershell -c "irm https://astral.sh/uv/install.ps1 | iex" |
| 47 | + |
| 48 | + # Or using pip |
| 49 | + pip install uv |
| 50 | + ``` |
| 51 | +4. Create a virtual environment and install dependencies: |
| 52 | + ```bash |
| 53 | + uv venv |
| 54 | + uv sync --all-extras --dev |
| 55 | + source .venv/bin/activate # On Windows: .venv\Scripts\activate |
| 56 | + ``` |
| 57 | + |
| 58 | +#### Running Tests |
| 59 | + |
| 60 | +Before submitting changes, ensure all tests pass: |
| 61 | + |
| 62 | +```bash |
| 63 | +# Run all tests |
| 64 | +uv run pytest |
| 65 | + |
| 66 | +# Run tests with coverage |
| 67 | +uv run pytest --cov=src |
| 68 | + |
| 69 | +# Run specific test categories |
| 70 | +uv run pytest tests/test_basic.py |
| 71 | +``` |
| 72 | + |
| 73 | +#### Code Style |
| 74 | + |
| 75 | +We use several tools to maintain code quality: |
| 76 | + |
| 77 | +- **Ruff**: For linting and formatting. Check <https://docs.astral.sh/ruff/> for more details. |
| 78 | +- **MyPy**: For static type checking. Check <https://mypy.readthedocs.io/en/stable/> for more details. |
| 79 | +- **Pre-commit hooks**: To automatically check code before committing. Check <https://pre-commit.com/> for more details. |
| 80 | + |
| 81 | +You should install them before making changes. |
| 82 | + |
| 83 | +To run checks manually: |
| 84 | + |
| 85 | +```bash |
| 86 | +# Run all pre-commit checks |
| 87 | +uv run pre-commit run --all-files |
| 88 | + |
| 89 | +# Run specific checks |
| 90 | +uv run ruff check . |
| 91 | +uv run ruff format . |
| 92 | +uv run mypy src |
| 93 | +``` |
| 94 | + |
| 95 | +#### Making Changes |
| 96 | + |
| 97 | +1. Create a new branch for your feature or bugfix: |
| 98 | + ```bash |
| 99 | + git checkout -b feature/your-feature-name |
| 100 | + ``` |
| 101 | +2. Make your changes, following the code style guidelines |
| 102 | + |
| 103 | +3. Add tests for new functionality |
| 104 | + |
| 105 | +4. Ensure all tests pass (you shall run redis server on localhost:6379 before running tests): |
| 106 | + |
| 107 | + ```bash |
| 108 | + uv run pytest |
| 109 | + ``` |
| 110 | + |
| 111 | + If the changes are concerned with Redis cluster, it is recommended to run the tests against a Redis cluster by docker compose: |
| 112 | + |
| 113 | + ```bash |
| 114 | + cd docker |
| 115 | + docker compose up |
| 116 | + ``` |
| 117 | + |
| 118 | + If you have standalone Redis server(s) running, you can run the tests against it/them by setting the environment variables |
| 119 | + |
| 120 | + - `REDIS_URL`: url for the single Redis server |
| 121 | + - `REDIS_CLUSTER_NODES`: `":"` split list of Redis cluster nodes |
| 122 | + |
| 123 | + A `.env` file can be used to set the environment variables. |
| 124 | + |
| 125 | +5. Commit your changes with a clear, descriptive commit message |
| 126 | + |
| 127 | +6. Push to your fork and submit a pull request |
| 128 | + |
| 129 | +### Pull Request Guidelines |
| 130 | + |
| 131 | +When submitting a pull request: |
| 132 | + |
| 133 | +1. Provide a clear title and description |
| 134 | +2. Reference any related issues |
| 135 | +3. Ensure your code follows the project's style guidelines |
| 136 | +4. Include tests for new functionality |
| 137 | +5. Update documentation as needed |
| 138 | +6. Keep pull requests focused on a single feature or bugfix |
| 139 | + |
| 140 | +### Documentation |
| 141 | + |
| 142 | +Improvements to documentation are always welcome. This includes: |
| 143 | + |
| 144 | +- Updates to README.md |
| 145 | +- Docstring improvements |
| 146 | +- Examples and tutorials |
| 147 | +- Comments in code |
| 148 | + |
| 149 | +## Development Practices |
| 150 | + |
| 151 | +### Lua Scripts |
| 152 | + |
| 153 | +This project uses Redis Lua scripts for atomic operations. When modifying Lua scripts: |
| 154 | + |
| 155 | +1. Ensure scripts remain atomic and efficient |
| 156 | +2. Test with various Redis versions |
| 157 | +3. Keep scripts readable and well-commented |
| 158 | +4. Follow existing patterns in the codebase |
| 159 | + |
| 160 | +### Testing |
| 161 | + |
| 162 | +We maintain high test coverage and follow these practices: |
| 163 | + |
| 164 | +1. Write unit tests for new functionality |
| 165 | +2. Test both synchronous and asynchronous code paths |
| 166 | +3. Include edge cases and error conditions |
| 167 | +4. Test with different cache policies |
| 168 | +5. Use appropriate mocking when needed |
| 169 | + |
| 170 | +### Versioning |
| 171 | + |
| 172 | +We follow [Semantic Versioning](https://semver.org/). Changes are categorized as: |
| 173 | + |
| 174 | +- **Major**: Breaking changes |
| 175 | +- **Minor**: New features (backward compatible) |
| 176 | +- **Patch**: Bug fixes (backward compatible) |
| 177 | + |
| 178 | +## Getting Help |
| 179 | + |
| 180 | +If you need help with your contribution: |
| 181 | + |
| 182 | +1. Check the documentation and existing issues |
| 183 | +2. Join our community discussions |
| 184 | +3. Contact the maintainers directly |
| 185 | + |
| 186 | +## License |
| 187 | + |
| 188 | +By contributing to redis_func_cache, you agree that your contributions will be licensed under the BSD 3-Clause License. |
0 commit comments