|
| 1 | +# Contributing |
| 2 | + |
| 3 | +Thank you for considering contributing! This document outlines the process for contributing to this project. |
| 4 | + |
| 5 | +When contributing to this repository, please first discuss the change you wish to make via issue, email, or any other method with the owners of this repository before making a change. |
| 6 | + |
| 7 | +Please note we have a [code of conduct](CODE_OF_CONDUCT.md), please follow it in all your interactions with the project. |
| 8 | + |
| 9 | +## Development Workflow |
| 10 | + |
| 11 | +We use [git-flow workflow](https://danielkummer.github.io/git-flow-cheatsheet/) and [conventional commits](https://www.conventionalcommits.org). |
| 12 | + |
| 13 | +### Branch Structure |
| 14 | +- `main` - Production-ready code |
| 15 | +- `develop` - Development branch |
| 16 | +- `feature/*` - New features |
| 17 | +- `bugfix/*` - Bug fixes |
| 18 | +- `hotfix/*` - Critical production fixes |
| 19 | + |
| 20 | +### Getting Started |
| 21 | + |
| 22 | +1. Fork the repository |
| 23 | +2. Clone your fork: `git clone https://github.com/your-username/wp-boot.git` |
| 24 | +3. Create a feature branch: `git checkout -b feature/your-feature-name` |
| 25 | +4. Install dependencies: `composer install` |
| 26 | +5. Make your changes |
| 27 | +6. Run tests: `composer test` |
| 28 | +7. Run quality checks: `composer qa` |
| 29 | +8. Commit using conventional commits |
| 30 | +9. Push and create a pull request |
| 31 | + |
| 32 | +## Development Setup |
| 33 | + |
| 34 | +### Requirements |
| 35 | +- PHP 8.0 or higher |
| 36 | +- Composer |
| 37 | +- Git |
| 38 | + |
| 39 | +### Installation |
| 40 | +```bash |
| 41 | +git clone https://github.com/wp-spaghetti/wp-boot.git |
| 42 | +cd wp-boot |
| 43 | +composer install |
| 44 | +``` |
| 45 | + |
| 46 | +### Running Tests |
| 47 | +```bash |
| 48 | +# Run all tests |
| 49 | +composer test |
| 50 | + |
| 51 | +# Run specific test suite |
| 52 | +vendor/bin/phpunit tests/FooTest.php |
| 53 | + |
| 54 | +# Run with coverage |
| 55 | +vendor/bin/phpunit --coverage-html coverage/ |
| 56 | +``` |
| 57 | + |
| 58 | +### Code Quality |
| 59 | +```bash |
| 60 | +# Run all quality checks |
| 61 | +composer quality |
| 62 | + |
| 63 | +# Individual tools |
| 64 | +composer lint # Linters |
| 65 | +composer analysis # Static analysis |
| 66 | +composer security # Security check |
| 67 | +composer quality # Code quality |
| 68 | +``` |
| 69 | + |
| 70 | +## Coding Standards |
| 71 | + |
| 72 | +### PHP Standards |
| 73 | +- Follow PSR-12 coding standard |
| 74 | +- Use strict typing: `declare(strict_types=1);` |
| 75 | +- Document all public methods with PHPDoc |
| 76 | +- Use meaningful variable and method names |
| 77 | + |
| 78 | +### Commit Messages |
| 79 | +We use [Conventional Commits](https://www.conventionalcommits.org/): |
| 80 | + |
| 81 | +``` |
| 82 | +type(scope): description |
| 83 | +
|
| 84 | +[optional body] |
| 85 | +
|
| 86 | +[optional footer] |
| 87 | +``` |
| 88 | + |
| 89 | +**Types:** |
| 90 | +- `feat:` New features |
| 91 | +- `fix:` Bug fixes |
| 92 | +- `docs:` Documentation changes |
| 93 | +- `style:` Code style changes (no logic changes) |
| 94 | +- `refactor:` Code refactoring |
| 95 | +- `test:` Adding or updating tests |
| 96 | +- `chore:` Maintenance tasks |
| 97 | + |
| 98 | +**Examples:** |
| 99 | +``` |
| 100 | +feat(environment): add support for custom environment detection |
| 101 | +fix(docker): improve container detection accuracy |
| 102 | +docs(readme): update installation instructions |
| 103 | +test(hooks): add comprehensive hook testing |
| 104 | +``` |
| 105 | + |
| 106 | +### Code Style |
| 107 | +```php |
| 108 | +<?php |
| 109 | + |
| 110 | +declare(strict_types=1); |
| 111 | + |
| 112 | +namespace WpSpaghetti\ExampleNamespace; |
| 113 | + |
| 114 | +/** |
| 115 | + * Class documentation. |
| 116 | + */ |
| 117 | +class ExampleClass |
| 118 | +{ |
| 119 | + /** |
| 120 | + * Method documentation. |
| 121 | + */ |
| 122 | + public function exampleMethod(string $param): bool |
| 123 | + { |
| 124 | + // Method implementation |
| 125 | + return true; |
| 126 | + } |
| 127 | +} |
| 128 | +``` |
| 129 | + |
| 130 | +## Testing Guidelines |
| 131 | + |
| 132 | +### Test Structure |
| 133 | +- Unit tests in `tests/` directory |
| 134 | +- Test files should end with `Test.php` |
| 135 | +- Use descriptive test method names |
| 136 | +- Include both positive and negative test cases |
| 137 | + |
| 138 | +### Test Example |
| 139 | +```php |
| 140 | +public function testMethodReturnsExpectedValue(): void |
| 141 | +{ |
| 142 | + $result = ExampleClass::get('TEST_VAR', 'default'); |
| 143 | + self::assertSame('expected', $result); |
| 144 | +} |
| 145 | +``` |
| 146 | + |
| 147 | +### Mock Data |
| 148 | +Use the provided mock functions for testing: |
| 149 | +- `set_mock_*()` |
| 150 | + |
| 151 | +## Documentation |
| 152 | + |
| 153 | +### Code Documentation |
| 154 | +- All public methods must have PHPDoc blocks |
| 155 | +- Include `@param` and `@return` annotations |
| 156 | +- Document complex logic with inline comments |
| 157 | +- Use clear, concise language |
| 158 | + |
| 159 | +### README Updates |
| 160 | +When adding new features: |
| 161 | +- Update the feature list |
| 162 | +- Add usage examples |
| 163 | +- Update the API reference if needed |
| 164 | + |
| 165 | +## Pull Request Process |
| 166 | + |
| 167 | +1. **Create Feature Branch** |
| 168 | + ```bash |
| 169 | + git checkout develop |
| 170 | + git checkout -b feature/your-feature |
| 171 | + ``` |
| 172 | + |
| 173 | +2. **Make Changes** |
| 174 | + - Write code following the standards above |
| 175 | + - Add/update tests for your changes |
| 176 | + - Update documentation if needed |
| 177 | + |
| 178 | +3. **Test Your Changes** |
| 179 | + ```bash |
| 180 | + composer quality # Run all quality checks |
| 181 | + composer test # Run all tests |
| 182 | + ``` |
| 183 | + |
| 184 | +4. **Commit Changes** |
| 185 | + ```bash |
| 186 | + git add . |
| 187 | + git commit -m "feat: add new feature description" |
| 188 | + ``` |
| 189 | + |
| 190 | +5. **Push and Create PR** |
| 191 | + ```bash |
| 192 | + git push origin feature/your-feature |
| 193 | + ``` |
| 194 | + Then create a pull request against the `develop` branch. |
| 195 | + |
| 196 | +### PR Requirements |
| 197 | +- All tests must pass |
| 198 | +- Code coverage should not decrease |
| 199 | +- Follow the PR template |
| 200 | +- Link to related issues |
| 201 | +- Use conventional commit messages |
| 202 | + |
| 203 | +## Release Process |
| 204 | + |
| 205 | +Releases are automated through GitHub Actions: |
| 206 | + |
| 207 | +1. Merge to `main` triggers release workflow |
| 208 | +2. Conventional commits determine version bump |
| 209 | +3. Changelog is automatically updated |
| 210 | +4. GitHub release is created |
| 211 | +5. Packagist is notified |
| 212 | + |
| 213 | +## Security |
| 214 | + |
| 215 | +If you discover a security vulnerability, please follow our [Security Policy](SECURITY.md). |
| 216 | + |
| 217 | +## Questions? |
| 218 | + |
| 219 | +- Create an issue for questions about usage |
| 220 | +- Join discussions for feature planning |
| 221 | +- Contact maintainers for sensitive issues |
| 222 | + |
| 223 | +## License |
| 224 | + |
| 225 | +By contributing, you agree that your contributions will be licensed under the GPL-3.0-or-later license. |
| 226 | + |
| 227 | +## Recognition |
| 228 | + |
| 229 | +Contributors will be recognized in: |
| 230 | +- GitHub contributors list |
| 231 | +- Release notes for significant contributions |
| 232 | +- README acknowledgments for major features |
| 233 | + |
| 234 | +Thank you for contributing! 🎉 |
0 commit comments