|
| 1 | +# Contributing to tldns |
| 2 | + |
| 3 | +Thank you for your interest in contributing to tldns! This document provides guidelines for contributing to the project. |
| 4 | + |
| 5 | +## Development Setup |
| 6 | + |
| 7 | +1. **Clone the repository**: |
| 8 | + ```bash |
| 9 | + git clone https://github.com/yourusername/tldns.git |
| 10 | + cd tldns |
| 11 | + ``` |
| 12 | + |
| 13 | +2. **Install uv** (if not already installed): |
| 14 | + ```bash |
| 15 | + curl -LsSf https://astral.sh/uv/install.sh | sh |
| 16 | + ``` |
| 17 | + |
| 18 | +3. **Set up development environment**: |
| 19 | + ```bash |
| 20 | + uv sync |
| 21 | + uv pip install -e ".[test]" |
| 22 | + ``` |
| 23 | + |
| 24 | +4. **Generate test certificates**: |
| 25 | + ```bash |
| 26 | + ./generate_cert.sh |
| 27 | + ``` |
| 28 | + |
| 29 | +## Development Workflow |
| 30 | + |
| 31 | +### Running Tests |
| 32 | + |
| 33 | +```bash |
| 34 | +# Run all tests |
| 35 | +uv run python -m pytest |
| 36 | + |
| 37 | +# Run with coverage |
| 38 | +uv run python -m pytest --cov=tldns |
| 39 | + |
| 40 | +# Run specific test categories |
| 41 | +uv run python -m pytest -m unit |
| 42 | +uv run python -m pytest -m integration |
| 43 | +uv run python -m pytest -m "not slow" |
| 44 | + |
| 45 | +# Run tests in verbose mode |
| 46 | +uv run python -m pytest -v |
| 47 | + |
| 48 | +# Add test dependencies if needed |
| 49 | +uv add --dev pytest pytest-cov pytest-asyncio |
| 50 | +``` |
| 51 | + |
| 52 | +### Code Quality |
| 53 | + |
| 54 | +```bash |
| 55 | +# Format code (if using ruff) |
| 56 | +uv add --dev ruff |
| 57 | +uv run ruff format . |
| 58 | + |
| 59 | +# Lint code (if using ruff) |
| 60 | +uv run ruff check . |
| 61 | + |
| 62 | +# Type checking (if using mypy) |
| 63 | +uv add --dev mypy |
| 64 | +uv run mypy tldns/ |
| 65 | +``` |
| 66 | + |
| 67 | +### Building the Package |
| 68 | + |
| 69 | +```bash |
| 70 | +# Build source and wheel distributions |
| 71 | +uv build |
| 72 | + |
| 73 | +# Check the built package |
| 74 | +uv add --dev twine |
| 75 | +uv run python -m twine check dist/* |
| 76 | +``` |
| 77 | + |
| 78 | +### Testing the CLI |
| 79 | + |
| 80 | +```bash |
| 81 | +# Test CLI functionality |
| 82 | +uv run tldns --help |
| 83 | +uv run tldns start --help |
| 84 | + |
| 85 | +# Test with custom parameters |
| 86 | +uv run tldns --port 8853 --log_level DEBUG start |
| 87 | +``` |
| 88 | + |
| 89 | +## Contributing Guidelines |
| 90 | + |
| 91 | +### Code Style |
| 92 | + |
| 93 | +- Follow PEP 8 style guidelines |
| 94 | +- Use type hints for all function parameters and return values |
| 95 | +- Write descriptive docstrings for classes and functions |
| 96 | +- Keep functions focused and single-purpose |
| 97 | +- Use meaningful variable and function names |
| 98 | + |
| 99 | +### Testing |
| 100 | + |
| 101 | +- Write tests for all new functionality |
| 102 | +- Maintain or improve test coverage (currently 96%) |
| 103 | +- Include both unit tests and integration tests |
| 104 | +- Test error conditions and edge cases |
| 105 | +- Use descriptive test names that explain what is being tested |
| 106 | + |
| 107 | +### Documentation |
| 108 | + |
| 109 | +- Update README.md for user-facing changes |
| 110 | +- Update CHANGELOG.md following Keep a Changelog format |
| 111 | +- Add docstrings to new classes and functions |
| 112 | +- Update type hints when modifying function signatures |
| 113 | + |
| 114 | +### Commit Messages |
| 115 | + |
| 116 | +Use clear, descriptive commit messages: |
| 117 | + |
| 118 | +``` |
| 119 | +feat: add support for custom DNS record types |
| 120 | +fix: handle SSL handshake failures gracefully |
| 121 | +docs: update installation instructions |
| 122 | +test: add performance tests for concurrent clients |
| 123 | +``` |
| 124 | + |
| 125 | +### Pull Request Process |
| 126 | + |
| 127 | +1. **Fork the repository** and create a feature branch: |
| 128 | + ```bash |
| 129 | + git checkout -b feature/your-feature-name |
| 130 | + ``` |
| 131 | + |
| 132 | +2. **Make your changes** following the guidelines above |
| 133 | + |
| 134 | +3. **Run tests** to ensure everything works: |
| 135 | + ```bash |
| 136 | + uv run python -m pytest |
| 137 | + ``` |
| 138 | + |
| 139 | +4. **Update documentation** as needed |
| 140 | + |
| 141 | +5. **Commit your changes** with descriptive messages |
| 142 | + |
| 143 | +6. **Push to your fork** and create a pull request |
| 144 | + |
| 145 | +7. **Ensure CI passes** - all GitHub Actions workflows must pass |
| 146 | + |
| 147 | +### Pull Request Checklist |
| 148 | + |
| 149 | +- [ ] Tests pass locally and in CI |
| 150 | +- [ ] Code follows project style guidelines |
| 151 | +- [ ] Documentation is updated (if applicable) |
| 152 | +- [ ] CHANGELOG.md is updated (for significant changes) |
| 153 | +- [ ] Type hints are included for new code |
| 154 | +- [ ] Test coverage is maintained or improved |
| 155 | + |
| 156 | +## Reporting Issues |
| 157 | + |
| 158 | +When reporting issues, please include: |
| 159 | + |
| 160 | +- Python version and operating system |
| 161 | +- Steps to reproduce the issue |
| 162 | +- Expected vs actual behavior |
| 163 | +- Relevant log output (with `--log_level DEBUG`) |
| 164 | +- Configuration details (host, port, certificates, etc.) |
| 165 | + |
| 166 | +## Feature Requests |
| 167 | + |
| 168 | +For feature requests, please: |
| 169 | + |
| 170 | +- Check existing issues to avoid duplicates |
| 171 | +- Describe the use case and motivation |
| 172 | +- Provide examples of how the feature would be used |
| 173 | +- Consider implementation complexity and maintenance burden |
| 174 | + |
| 175 | +## Release Process |
| 176 | + |
| 177 | +Releases are automated through GitHub Actions: |
| 178 | + |
| 179 | +1. Update version in `pyproject.toml` |
| 180 | +2. Update `CHANGELOG.md` with release notes |
| 181 | +3. Commit changes and push to main |
| 182 | +4. Create and push a version tag: |
| 183 | + ```bash |
| 184 | + git tag v0.1.1 |
| 185 | + git push origin v0.1.1 |
| 186 | + ``` |
| 187 | +5. GitHub Actions will automatically: |
| 188 | + - Run tests |
| 189 | + - Build packages |
| 190 | + - Create GitHub release |
| 191 | + - Publish to PyPI |
| 192 | + |
| 193 | +## Getting Help |
| 194 | + |
| 195 | +- Check the README.md for usage instructions |
| 196 | +- Look at existing tests for examples |
| 197 | +- Review the GitHub Actions workflows for CI/CD details |
| 198 | +- Open an issue for questions or problems |
| 199 | + |
| 200 | +Thank you for contributing to tldns! |
0 commit comments