|
| 1 | +# Contributing |
| 2 | + |
| 3 | +This is a personal project, but if you'd like to contribute, here's how to set up the development environment. |
| 4 | + |
| 5 | +## Development Setup |
| 6 | + |
| 7 | +```bash |
| 8 | +# Clone the repository |
| 9 | +git clone https://github.com/madebygps/second-brain.git |
| 10 | +cd second-brain |
| 11 | + |
| 12 | +# Install dependencies with uv |
| 13 | +uv sync |
| 14 | + |
| 15 | +# Install pre-commit hooks |
| 16 | +uv run pre-commit install |
| 17 | + |
| 18 | +# Configure your environment |
| 19 | +cp .env.example .env |
| 20 | +# Edit .env with your paths and Azure credentials |
| 21 | +``` |
| 22 | + |
| 23 | +## Making Changes |
| 24 | + |
| 25 | +1. **Create a branch** for your changes |
| 26 | + ```bash |
| 27 | + git checkout -b feature/your-feature-name |
| 28 | + ``` |
| 29 | + |
| 30 | +2. **Make your changes** - The pre-commit hooks will automatically: |
| 31 | + - Lint code with ruff (auto-fixes issues) |
| 32 | + - Format code with ruff-format |
| 33 | + - Run the 7 essential tests |
| 34 | + - Check file endings and whitespace |
| 35 | + |
| 36 | +3. **Run tests manually** if needed: |
| 37 | + ```bash |
| 38 | + uv run pytest tests/ -v |
| 39 | + uv run pytest tests/ --cov # with coverage |
| 40 | + ``` |
| 41 | + |
| 42 | +4. **Commit your changes** - Pre-commit hooks will run automatically: |
| 43 | + ```bash |
| 44 | + git add . |
| 45 | + git commit -m "Your descriptive commit message" |
| 46 | + ``` |
| 47 | + |
| 48 | +5. **Push and create a PR**: |
| 49 | + ```bash |
| 50 | + git push origin feature/your-feature-name |
| 51 | + ``` |
| 52 | + |
| 53 | +6. **pre-commit.ci will automatically**: |
| 54 | + - Run checks on your PR |
| 55 | + - Auto-fix any formatting/linting issues |
| 56 | + - Push fixes to your PR branch |
| 57 | + |
| 58 | +## Testing Philosophy |
| 59 | + |
| 60 | +This is a **personal project** with minimal tests focused on preventing data loss: |
| 61 | + |
| 62 | +- ✅ Configuration validation (missing paths) |
| 63 | +- ✅ File naming (reflection vs. plan entries) |
| 64 | +- ✅ Write/read cycles (data persistence) |
| 65 | +- ✅ Path separation (diary vs. planner) |
| 66 | + |
| 67 | +We don't test: |
| 68 | +- ❌ LLM responses (too variable) |
| 69 | +- ❌ CLI output formatting (not critical) |
| 70 | +- ❌ Template generation (easily tested manually) |
| 71 | +- ❌ Search functionality (depends on external Azure service) |
| 72 | + |
| 73 | +## Code Style |
| 74 | + |
| 75 | +- **Formatting**: Handled automatically by `ruff-format` (100 char line length) |
| 76 | +- **Type hints**: Use Python 3.13+ type hints on all functions |
| 77 | +- **Naming**: Clear, descriptive names (no abbreviations unless obvious) |
| 78 | +- **Comments**: Docstrings on all public functions |
| 79 | + |
| 80 | +## CI/CD |
| 81 | + |
| 82 | +**GitHub Actions** runs on push/PR: |
| 83 | +- Runs all 7 tests with coverage |
| 84 | +- Validates test count (ensures tests aren't accidentally deleted) |
| 85 | +- Checks Python 3.13 compatibility |
| 86 | + |
| 87 | +**[pre-commit.ci](https://pre-commit.ci)** (free for open source): |
| 88 | +- Auto-fixes PRs (formatting, imports, whitespace) |
| 89 | +- Weekly dependency updates via automated PRs |
| 90 | +- Faster than GitHub Actions for simple checks |
| 91 | +- Comment `pre-commit.ci run` to re-trigger |
| 92 | +- Skip with `[skip pre-commit.ci]` in commit message |
| 93 | + |
| 94 | +## Package Management |
| 95 | + |
| 96 | +**ALWAYS use `uv`, never `pip`**: |
| 97 | + |
| 98 | +```bash |
| 99 | +# Add a dependency |
| 100 | +uv add package-name |
| 101 | + |
| 102 | +# Add a dev dependency |
| 103 | +uv add --dev package-name |
| 104 | + |
| 105 | +# Update dependencies |
| 106 | +uv sync |
| 107 | + |
| 108 | +# Remove a dependency |
| 109 | +uv remove package-name |
| 110 | +``` |
| 111 | + |
| 112 | +## Questions? |
| 113 | + |
| 114 | +Open an issue or reach out to [@madebygps](https://github.com/madebygps). |
0 commit comments