|
| 1 | +# Contributing to Core Web |
| 2 | + |
| 3 | +Thank you for your interest in contributing to Core Web! We welcome contributions from the community and are excited to work with you. |
| 4 | + |
| 5 | +## 📋 Code of Conduct |
| 6 | + |
| 7 | +Please note that this project is released with a [Contributor Code of Conduct](Code-of-Conduct.md). By participating in this project you agree to abide by its terms. |
| 8 | + |
| 9 | +## 🛡️ Security Contributions |
| 10 | + |
| 11 | +If you discover a security vulnerability, please follow our [Security Policy](Security.md) rather than submitting a public issue. We take security seriously and appreciate responsible disclosure. |
| 12 | + |
| 13 | +## 🎯 How to Contribute |
| 14 | + |
| 15 | +### Reporting Bugs |
| 16 | + |
| 17 | +If you find a bug, please open an issue on GitHub with: |
| 18 | + |
| 19 | +- A clear and descriptive title |
| 20 | +- A detailed description of the problem |
| 21 | +- Steps to reproduce the issue |
| 22 | +- Expected vs. actual behavior |
| 23 | +- Any relevant code snippets or error messages |
| 24 | +- Environment information (OS, Rust version, etc.) |
| 25 | + |
| 26 | +### Suggesting Enhancements |
| 27 | + |
| 28 | +We welcome ideas for new features or improvements. Please open an issue with: |
| 29 | + |
| 30 | +- A clear and descriptive title |
| 31 | +- A detailed explanation of the enhancement |
| 32 | +- The motivation for the change |
| 33 | +- Any implementation ideas you might have |
| 34 | +- Examples of how the feature would be used |
| 35 | + |
| 36 | +### Pull Requests |
| 37 | + |
| 38 | +1. Fork the repository |
| 39 | +2. Create a new branch for your feature or bug fix |
| 40 | +3. Make your changes |
| 41 | +4. Add tests if applicable |
| 42 | +5. Ensure all tests pass |
| 43 | +6. Update documentation as needed |
| 44 | +7. Submit a pull request |
| 45 | + |
| 46 | +#### Pull Request Guidelines |
| 47 | + |
| 48 | +- Keep changes focused and atomic |
| 49 | +- Write clear commit messages |
| 50 | +- Follow the existing code style |
| 51 | +- Include tests for new functionality |
| 52 | +- Update documentation when necessary |
| 53 | +- Reference any related issues in your PR description |
| 54 | + |
| 55 | +## 🛠️ Development Setup |
| 56 | + |
| 57 | +### Prerequisites |
| 58 | + |
| 59 | +Before you start contributing, ensure you have: |
| 60 | + |
| 61 | +- **Rust** (latest stable version) - [Install Rust](https://www.rust-lang.org/tools/install) |
| 62 | +- **Docker and Docker Compose** - [Install Docker](https://docs.docker.com/get-docker/) |
| 63 | +- **Git** - [Install Git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) |
| 64 | + |
| 65 | +### Cloning the Repository |
| 66 | + |
| 67 | +```bash |
| 68 | +git clone https://github.com/your-org/core-web.git |
| 69 | +cd core-web |
| 70 | +``` |
| 71 | + |
| 72 | +### Setting Up the Development Environment |
| 73 | + |
| 74 | +1. Start the development services: |
| 75 | + ```bash |
| 76 | + ./scripts/dev-up.sh |
| 77 | + ``` |
| 78 | + |
| 79 | +2. Build the project: |
| 80 | + ```bash |
| 81 | + cargo build |
| 82 | + ``` |
| 83 | + |
| 84 | +3. Run tests to ensure everything is working: |
| 85 | + ```bash |
| 86 | + cargo test |
| 87 | + ``` |
| 88 | + |
| 89 | +## 📝 Code Style |
| 90 | + |
| 91 | +We follow the Rust community's standard code style. Please ensure your code: |
| 92 | + |
| 93 | +- Passes `cargo fmt` for formatting |
| 94 | +- Passes `cargo clippy` for linting |
| 95 | +- Includes appropriate documentation comments |
| 96 | +- Follows Rust naming conventions |
| 97 | +- Uses meaningful variable and function names |
| 98 | + |
| 99 | +### Formatting |
| 100 | + |
| 101 | +Run the formatter before committing: |
| 102 | +```bash |
| 103 | +cargo fmt |
| 104 | +``` |
| 105 | + |
| 106 | +### Linting |
| 107 | + |
| 108 | +Check for linting issues: |
| 109 | +```bash |
| 110 | +cargo clippy --all-targets --all-features |
| 111 | +``` |
| 112 | + |
| 113 | +### Documentation |
| 114 | + |
| 115 | +- All public functions, structs, and traits should have documentation comments |
| 116 | +- Use examples in documentation when helpful |
| 117 | +- Keep documentation up to date with code changes |
| 118 | + |
| 119 | +## 🧪 Testing |
| 120 | + |
| 121 | +All contributions should include tests. We use: |
| 122 | + |
| 123 | +- **Unit tests** for individual functions and modules |
| 124 | +- **Integration tests** for larger components |
| 125 | +- **End-to-end tests** for critical user workflows |
| 126 | + |
| 127 | +### Running Tests |
| 128 | + |
| 129 | +Run all tests: |
| 130 | +```bash |
| 131 | +cargo test |
| 132 | +``` |
| 133 | + |
| 134 | +Run tests for a specific crate: |
| 135 | +```bash |
| 136 | +cd crates/core-analytics |
| 137 | +cargo test |
| 138 | +``` |
| 139 | + |
| 140 | +Run tests with specific features: |
| 141 | +```bash |
| 142 | +cargo test --features "http3,otel" |
| 143 | +``` |
| 144 | + |
| 145 | +### Writing Tests |
| 146 | + |
| 147 | +- Place unit tests in the same file as the code they test (in `#[cfg(test)]` modules) |
| 148 | +- Place integration tests in the `tests/` directory |
| 149 | +- Use `testcontainers` for database integration tests |
| 150 | +- Use `proptest` for property-based testing |
| 151 | +- Use `insta` for snapshot testing |
| 152 | + |
| 153 | +## 📚 Documentation |
| 154 | + |
| 155 | +### Updating Documentation |
| 156 | + |
| 157 | +When making changes that affect documentation: |
| 158 | + |
| 159 | +1. Update relevant Markdown files |
| 160 | +2. Update code comments and docstrings |
| 161 | +3. Update the wiki pages if necessary |
| 162 | +4. Ensure all links are still valid |
| 163 | + |
| 164 | +### Building Documentation |
| 165 | + |
| 166 | +Build the documentation locally: |
| 167 | +```bash |
| 168 | +cargo doc --no-deps --all-features |
| 169 | +``` |
| 170 | + |
| 171 | +Open the documentation: |
| 172 | +```bash |
| 173 | +cargo doc --no-deps --all-features --open |
| 174 | +``` |
| 175 | + |
| 176 | +## 🔧 Code Review Process |
| 177 | + |
| 178 | +All submissions, including submissions by project members, require review. We use GitHub pull requests for this purpose. |
| 179 | + |
| 180 | +### Review Process |
| 181 | + |
| 182 | +1. **Submission**: Create a pull request with your changes |
| 183 | +2. **Automated Checks**: CI pipeline runs tests and checks |
| 184 | +3. **Review**: Maintainers review the code |
| 185 | +4. **Feedback**: Address any feedback from reviewers |
| 186 | +5. **Approval**: PR is approved and merged |
| 187 | + |
| 188 | +### Code Review Guidelines |
| 189 | + |
| 190 | +- Reviewers should focus on code correctness, maintainability, and performance |
| 191 | +- Provide constructive feedback with explanations |
| 192 | +- Consider the broader impact of changes |
| 193 | +- Ensure tests and documentation are adequate |
| 194 | +- Check for security considerations |
| 195 | + |
| 196 | +## 🔄 Branch Protection |
| 197 | + |
| 198 | +The main branch is protected with required status checks and code reviews. For more information, see the [Branch Protection Guide](https://github.com/your-org/core-web/blob/main/docs/branch-protection-guide.md). |
| 199 | + |
| 200 | +## 📦 Dependency Management |
| 201 | + |
| 202 | +### Adding Dependencies |
| 203 | + |
| 204 | +When adding new dependencies: |
| 205 | + |
| 206 | +1. Choose well-maintained, popular crates when possible |
| 207 | +2. Check for security vulnerabilities |
| 208 | +3. Consider the license compatibility |
| 209 | +4. Update `Cargo.lock` by running `cargo update` |
| 210 | + |
| 211 | +### Updating Dependencies |
| 212 | + |
| 213 | +Regularly update dependencies to get security fixes and improvements: |
| 214 | + |
| 215 | +```bash |
| 216 | +cargo update |
| 217 | +``` |
| 218 | + |
| 219 | +Check for outdated dependencies: |
| 220 | +```bash |
| 221 | +cargo outdated |
| 222 | +``` |
| 223 | + |
| 224 | +## 🐛 Debugging |
| 225 | + |
| 226 | +### Logging |
| 227 | + |
| 228 | +Use the built-in logging system for debugging: |
| 229 | + |
| 230 | +```rust |
| 231 | +use tracing::{info, debug, warn, error}; |
| 232 | + |
| 233 | +info!("Processing user request"); |
| 234 | +debug!("User ID: {}", user_id); |
| 235 | +warn!("Deprecated API usage"); |
| 236 | +error!("Failed to process request: {}", error); |
| 237 | +``` |
| 238 | + |
| 239 | +### Profiling |
| 240 | + |
| 241 | +Enable profiling for performance analysis: |
| 242 | + |
| 243 | +```bash |
| 244 | +cargo run --features "pprof" |
| 245 | +``` |
| 246 | + |
| 247 | +## 📈 Performance Considerations |
| 248 | + |
| 249 | +When contributing performance-sensitive code: |
| 250 | + |
| 251 | +- Avoid unnecessary allocations |
| 252 | +- Use efficient data structures |
| 253 | +- Consider async/await for I/O-bound operations |
| 254 | +- Profile code to identify bottlenecks |
| 255 | +- Write benchmarks for critical paths |
| 256 | + |
| 257 | +## 🛡️ Security Considerations |
| 258 | + |
| 259 | +When contributing code, please consider: |
| 260 | + |
| 261 | +- Avoiding unsafe code unless absolutely necessary |
| 262 | +- Properly validating and sanitizing inputs |
| 263 | +- Following secure coding practices |
| 264 | +- Updating dependencies responsibly |
| 265 | +- Reporting security issues through proper channels |
| 266 | + |
| 267 | +## 🎨 User Experience |
| 268 | + |
| 269 | +Consider the user experience when making changes: |
| 270 | + |
| 271 | +- Maintain backward compatibility when possible |
| 272 | +- Provide clear error messages |
| 273 | +- Document breaking changes |
| 274 | +- Follow API design best practices |
| 275 | + |
| 276 | +## 📤 Submitting Changes |
| 277 | + |
| 278 | +### Commit Messages |
| 279 | + |
| 280 | +Follow conventional commit format: |
| 281 | + |
| 282 | +``` |
| 283 | +feat(auth): add JWT authentication support |
| 284 | +
|
| 285 | +Implement JWT-based authentication with automatic token refresh. |
| 286 | +Include middleware for protecting routes and extracting user context. |
| 287 | +
|
| 288 | +Closes #123 |
| 289 | +``` |
| 290 | + |
| 291 | +### Pull Request Descriptions |
| 292 | + |
| 293 | +Include in your PR description: |
| 294 | + |
| 295 | +- What changes are being made |
| 296 | +- Why these changes are being made |
| 297 | +- How to test the changes |
| 298 | +- Any breaking changes |
| 299 | +- Related issues or PRs |
| 300 | + |
| 301 | +## 🤝 Community |
| 302 | + |
| 303 | +### Communication |
| 304 | + |
| 305 | +- Join our [Discord](#) for real-time discussion (if applicable) |
| 306 | +- Participate in [GitHub Discussions](#) for longer-form conversations |
| 307 | +- Attend [community meetings](#) if available |
| 308 | + |
| 309 | +### Getting Help |
| 310 | + |
| 311 | +If you need help: |
| 312 | + |
| 313 | +1. Check the documentation |
| 314 | +2. Search existing issues |
| 315 | +3. Ask in GitHub Discussions |
| 316 | +4. Contact maintainers directly |
| 317 | + |
| 318 | +## 📚 Additional Resources |
| 319 | + |
| 320 | +- [Rust Book](https://doc.rust-lang.org/book/) |
| 321 | +- [Rust API Guidelines](https://rust-lang.github.io/api-guidelines/) |
| 322 | +- [GitHub Flow](https://guides.github.com/introduction/flow/) |
| 323 | +- [Conventional Commits](https://www.conventionalcommits.org/) |
| 324 | + |
| 325 | +## 🙏 Thank You |
| 326 | + |
| 327 | +Thank you for contributing to Core Web! Your efforts help make this project better for everyone. |
0 commit comments