|
| 1 | +# Contributing to Compass |
| 2 | + |
| 3 | +Thank you for your interest in contributing to Compass! This document provides guidelines for contributing to the project. |
| 4 | + |
| 5 | +## Table of Contents |
| 6 | + |
| 7 | +- [Code of Conduct](#code-of-conduct) |
| 8 | +- [Getting Started](#getting-started) |
| 9 | +- [Development Workflow](#development-workflow) |
| 10 | +- [Pull Request Guidelines](#pull-request-guidelines) |
| 11 | +- [Commit Message Guidelines](#commit-message-guidelines) |
| 12 | +- [Testing Requirements](#testing-requirements) |
| 13 | +- [Documentation](#documentation) |
| 14 | +- [Communication](#communication) |
| 15 | + |
| 16 | +## Code of Conduct |
| 17 | + |
| 18 | +This project follows standard open source community guidelines. Be respectful, inclusive, and constructive in all interactions. |
| 19 | + |
| 20 | +## Getting Started |
| 21 | + |
| 22 | +### Setting Up Your Development Environment |
| 23 | + |
| 24 | +1. **Fork the repository** to your own GitHub account |
| 25 | +2. **Clone your fork** locally: |
| 26 | + ```bash |
| 27 | + git clone https://github.com/YOUR_USERNAME/compass.git |
| 28 | + cd compass |
| 29 | + ``` |
| 30 | +3. **Add upstream remote**: |
| 31 | + ```bash |
| 32 | + git remote add upstream https://github.com/redhat-et/compass.git |
| 33 | + ``` |
| 34 | +4. **Follow the Quick Start guide** in the [README.md](README.md#quick-start) to set up your environment |
| 35 | + |
| 36 | +## Development Workflow |
| 37 | + |
| 38 | +### 1. Discuss Before You Code |
| 39 | + |
| 40 | +**For significant changes**, discuss your approach upfront: |
| 41 | +- Open an issue describing the problem and proposed solution |
| 42 | +- For substantial features or architectural changes, create a design document in `docs/` |
| 43 | +- Wait for feedback from maintainers before investing significant effort |
| 44 | +- Small bug fixes and typos don't require prior discussion |
| 45 | + |
| 46 | +### 2. Work in Your Fork |
| 47 | + |
| 48 | +- Develop all changes in your own fork |
| 49 | +- Create feature branches from `main`: |
| 50 | + ```bash |
| 51 | + git checkout -b feature/your-feature-name |
| 52 | + ``` |
| 53 | +- Keep your fork's `main` branch in sync with upstream: |
| 54 | + ```bash |
| 55 | + git fetch upstream |
| 56 | + git checkout main |
| 57 | + git merge upstream/main |
| 58 | + ``` |
| 59 | + |
| 60 | +### 3. Keep PRs Small and Targeted |
| 61 | + |
| 62 | +- **Aim for PRs under 500 lines** whenever possible (not counting auto-generated code) |
| 63 | +- Each PR should address a single concern or feature |
| 64 | +- Break large features into incremental PRs that preserve functionality |
| 65 | +- Incremental PRs should: |
| 66 | + - Build on each other logically |
| 67 | + - Keep the codebase in a working state after each merge |
| 68 | + - Include tests for new functionality |
| 69 | + - Update documentation as needed |
| 70 | + |
| 71 | +**Example of breaking up a large feature**: |
| 72 | +``` |
| 73 | +PR 1: Add database schema for new feature (no breaking changes) |
| 74 | +PR 2: Implement backend API endpoints with tests |
| 75 | +PR 3: Add UI components |
| 76 | +PR 4: Wire up UI to backend and add integration tests |
| 77 | +``` |
| 78 | + |
| 79 | +### 4. Coordinate Breaking Changes |
| 80 | + |
| 81 | +If a breaking change is unavoidable: |
| 82 | +- Discuss in an issue first with the "breaking-change" label |
| 83 | +- Document the migration path clearly |
| 84 | +- Consider deprecation warnings before removal |
| 85 | +- For very large refactors, consider working from a branch in the main repository |
| 86 | +- Provide upgrade instructions in the PR description |
| 87 | + |
| 88 | +## Pull Request Guidelines |
| 89 | + |
| 90 | +### Before Submitting |
| 91 | + |
| 92 | +1. **Rebase on upstream/main** to ensure clean integration: |
| 93 | + ```bash |
| 94 | + git fetch upstream |
| 95 | + git rebase upstream/main |
| 96 | + ``` |
| 97 | +2. **Run tests locally**: |
| 98 | + ```bash |
| 99 | + make test |
| 100 | + make lint |
| 101 | + ``` |
| 102 | +3. **Update documentation** if your changes affect user-facing behavior |
| 103 | +4. **Add tests** for new functionality or bug fixes |
| 104 | + |
| 105 | +### PR Requirements |
| 106 | + |
| 107 | +- **Title**: Clear, concise description of the change |
| 108 | + - Good: "Add support for INT8 quantization in model catalog" |
| 109 | + - Bad: "Fix stuff" |
| 110 | +- **Description**: Include: |
| 111 | + - What changed and why |
| 112 | + - Link to related issue(s) |
| 113 | + - Testing performed |
| 114 | + - Breaking changes (if any) |
| 115 | + - Screenshots for UI changes |
| 116 | +- **Size**: Keep PRs focused and reasonably sized |
| 117 | +- **Tests**: Include unit tests, integration tests where appropriate |
| 118 | +- **Documentation**: Update relevant docs in `docs/` and code comments |
| 119 | + |
| 120 | +### PR Template |
| 121 | + |
| 122 | +```markdown |
| 123 | +## Description |
| 124 | +[Brief description of changes] |
| 125 | + |
| 126 | +## Related Issue |
| 127 | +Fixes #[issue number] |
| 128 | + |
| 129 | +## Changes Made |
| 130 | +- [List key changes] |
| 131 | + |
| 132 | +## Testing |
| 133 | +- [ ] Unit tests pass (`make test-unit`) |
| 134 | +- [ ] Integration tests pass (`make test-integration`) |
| 135 | +- [ ] Manual testing performed |
| 136 | + |
| 137 | +## Documentation |
| 138 | +- [ ] Updated relevant documentation in `docs/` |
| 139 | +- [ ] Updated code comments where needed |
| 140 | +- [ ] Updated README if user-facing changes |
| 141 | + |
| 142 | +## Breaking Changes |
| 143 | +[Describe any breaking changes and migration path, or "None"] |
| 144 | +``` |
| 145 | + |
| 146 | +### Review Process |
| 147 | + |
| 148 | +- Maintainers will review PRs as time permits |
| 149 | +- Address review feedback promptly |
| 150 | +- Rebase and force-push if requested (don't create merge commits) |
| 151 | +- Be open to suggestions and iterate on your implementation |
| 152 | + |
| 153 | +## Commit Message Guidelines |
| 154 | + |
| 155 | +### Format |
| 156 | + |
| 157 | +Follow the [Conventional Commits](https://www.conventionalcommits.org/) style: |
| 158 | + |
| 159 | +``` |
| 160 | +<type>: <subject> |
| 161 | +
|
| 162 | +<body> |
| 163 | +
|
| 164 | +<footer> |
| 165 | +``` |
| 166 | + |
| 167 | +### Types |
| 168 | + |
| 169 | +- `feat`: New feature |
| 170 | +- `fix`: Bug fix |
| 171 | +- `docs`: Documentation changes |
| 172 | +- `refactor`: Code refactoring (no functional changes) |
| 173 | +- `test`: Adding or updating tests |
| 174 | +- `chore`: Maintenance tasks, dependency updates |
| 175 | + |
| 176 | +### Requirements |
| 177 | + |
| 178 | +- **Subject line**: 50 characters or less, imperative mood |
| 179 | + - Good: "Add GPU cost calculation for H100" |
| 180 | + - Bad: "Added GPU costs" or "This adds GPU cost calculation" |
| 181 | +- **Body**: Wrap at 72 characters, explain what and why (not how) |
| 182 | +- **Sign-off**: Include DCO sign-off with `-s` flag: |
| 183 | + ```bash |
| 184 | + git commit -s -m "feat: Add support for custom SLO templates" |
| 185 | + ``` |
| 186 | +- **AI Assistance**: Nontrivial and substantial AI-generated or AI-assisted content should be “marked”. Using the `Assisted-by:` tag is recommended as shown in the following example: |
| 187 | + |
| 188 | + ``` |
| 189 | + Assisted-by: Claude <noreply@anthropic.com> |
| 190 | + ``` |
| 191 | + |
| 192 | +### Example Commit Message |
| 193 | + |
| 194 | +``` |
| 195 | +feat: Add support for on-premise GPU cost models |
| 196 | +
|
| 197 | +Extends the cost calculation system to support user-provided pricing |
| 198 | +for on-premise and existing GPU infrastructure. Previously only cloud |
| 199 | +GPU rental pricing was supported. |
| 200 | +
|
| 201 | +Changes: |
| 202 | +- Add cost_model field to DeploymentIntent schema |
| 203 | +- Implement custom cost provider interface |
| 204 | +- Update UI to accept user cost parameters |
| 205 | +
|
| 206 | +Related to #42 |
| 207 | +
|
| 208 | +Signed-off-by: Your Name <your.email@example.com> |
| 209 | +``` |
| 210 | + |
| 211 | +## Testing Requirements |
| 212 | + |
| 213 | +### Test Coverage |
| 214 | + |
| 215 | +- **Unit tests**: Required for all new functionality |
| 216 | + - Located in `tests/` |
| 217 | + - Run with `make test-unit` |
| 218 | +- **Integration tests**: Required for API endpoints and workflows |
| 219 | + - Run with `make test-integration` |
| 220 | +- **End-to-end tests**: For critical user flows (optional for most PRs) |
| 221 | + - Run with `make test-e2e` |
| 222 | + |
| 223 | +### Running Tests |
| 224 | + |
| 225 | +```bash |
| 226 | +# Run all tests |
| 227 | +make test |
| 228 | + |
| 229 | +# Run specific test categories |
| 230 | +make test-unit |
| 231 | +make test-integration |
| 232 | +make test-e2e |
| 233 | + |
| 234 | +# Run tests in watch mode during development |
| 235 | +make test-watch |
| 236 | + |
| 237 | +# Run linters |
| 238 | +make lint |
| 239 | + |
| 240 | +# Auto-format code |
| 241 | +make format |
| 242 | +``` |
| 243 | + |
| 244 | +### Writing Tests |
| 245 | + |
| 246 | +- Test files should mirror source structure: `backend/src/foo/bar.py` → `tests/test_foo_bar.py` |
| 247 | +- Use descriptive test names: `test_plan_capacity_with_minimum_accuracy_threshold()` |
| 248 | +- Include both positive and negative test cases |
| 249 | +- Mock external dependencies (databases, APIs, LLM calls) |
| 250 | + |
| 251 | +## Documentation |
| 252 | + |
| 253 | +### What to Document |
| 254 | + |
| 255 | +- **User-facing changes**: Update `README.md` and relevant `docs/` files |
| 256 | +- **API changes**: Update docstrings and API documentation |
| 257 | +- **Architecture changes**: Update `docs/ARCHITECTURE.md` |
| 258 | +- **New features**: Add usage examples and guides |
| 259 | + |
| 260 | +### Documentation Style |
| 261 | + |
| 262 | +- Use clear, concise language |
| 263 | +- Include code examples where helpful |
| 264 | +- Keep `CLAUDE.md` updated with project context for AI assistance |
| 265 | +- Use Markdown formatting consistently |
| 266 | + |
| 267 | +## Communication |
| 268 | + |
| 269 | +### Stay in Touch |
| 270 | + |
| 271 | +- **Rebase often**: Keep your branch up-to-date with upstream/main |
| 272 | + ```bash |
| 273 | + git fetch upstream |
| 274 | + git rebase upstream/main |
| 275 | + ``` |
| 276 | +- **Communicate frequently**: |
| 277 | + - Comment on issues and PRs |
| 278 | + - Ask questions if requirements are unclear |
| 279 | + - Update PRs if you're blocked or need help |
| 280 | +- **Be responsive**: Address review feedback within a few days if possible |
| 281 | + |
| 282 | +### Getting Help |
| 283 | + |
| 284 | +- **Issues**: For bugs, feature requests, or questions |
| 285 | +- **Discussions**: For general questions and brainstorming |
| 286 | +- **Pull Requests**: For code review and technical discussion |
| 287 | + |
| 288 | +## License |
| 289 | + |
| 290 | +By contributing to Compass, you agree that your contributions will be licensed under the same license as the project (see [LICENSE](LICENSE)). |
| 291 | + |
| 292 | +## Questions? |
| 293 | + |
| 294 | +If you have questions not covered here, please: |
| 295 | +1. Check existing issues and documentation |
| 296 | +2. Open a new issue with the "question" label |
| 297 | +3. Reach out to maintainers |
| 298 | + |
| 299 | +Thank you for contributing to Compass! |
0 commit comments