198 lines
5.2 KiB
Markdown
198 lines
5.2 KiB
Markdown
# Contributing to AniWorld
|
|
|
|
Thank you for considering contributing to AniWorld! This document provides guidelines and instructions for contributing to the project.
|
|
|
|
## Code of Conduct
|
|
|
|
This project and everyone participating in it is governed by our Code of Conduct. By participating, you are expected to uphold this code.
|
|
|
|
## How Can I Contribute?
|
|
|
|
### Reporting Bugs
|
|
|
|
Before creating bug reports, please check the existing issues to avoid duplicates. When you are creating a bug report, please include as many details as possible:
|
|
|
|
- Use a clear and descriptive title
|
|
- Describe the exact steps which reproduce the problem
|
|
- Provide specific examples to demonstrate the steps
|
|
- Describe the behavior you observed after following the steps
|
|
- Explain which behavior you expected to see instead and why
|
|
- Include screenshots if applicable
|
|
|
|
### Suggesting Enhancements
|
|
|
|
Enhancement suggestions are tracked as GitHub issues. When creating an enhancement suggestion, please include:
|
|
|
|
- Use a clear and descriptive title
|
|
- Provide a step-by-step description of the suggested enhancement
|
|
- Provide specific examples to demonstrate the steps
|
|
- Describe the current behavior and explain which behavior you expected to see instead
|
|
- Explain why this enhancement would be useful
|
|
|
|
### Pull Requests
|
|
|
|
1. Fork the repo and create your branch from `main`
|
|
2. If you've added code that should be tested, add tests
|
|
3. If you've changed APIs, update the documentation
|
|
4. Ensure the test suite passes
|
|
5. Make sure your code lints
|
|
6. Issue that pull request!
|
|
|
|
## Development Process
|
|
|
|
### Setting Up Development Environment
|
|
|
|
1. Clone the repository:
|
|
```bash
|
|
git clone https://github.com/yourusername/aniworld.git
|
|
cd aniworld
|
|
```
|
|
|
|
2. Create and activate virtual environment:
|
|
```bash
|
|
python -m venv aniworld
|
|
source aniworld/bin/activate # On Windows: aniworld\Scripts\activate
|
|
```
|
|
|
|
3. Install development dependencies:
|
|
```bash
|
|
pip install -r requirements-dev.txt
|
|
```
|
|
|
|
4. Install pre-commit hooks:
|
|
```bash
|
|
pre-commit install
|
|
```
|
|
|
|
5. Set up environment variables:
|
|
```bash
|
|
cp src/server/.env.example src/server/.env
|
|
# Edit .env file with your configuration
|
|
```
|
|
|
|
### Running Tests
|
|
|
|
Run the full test suite:
|
|
```bash
|
|
pytest
|
|
```
|
|
|
|
Run specific test categories:
|
|
```bash
|
|
pytest tests/unit/ # Unit tests only
|
|
pytest tests/integration/ # Integration tests only
|
|
pytest tests/e2e/ # End-to-end tests only
|
|
```
|
|
|
|
Run with coverage:
|
|
```bash
|
|
pytest --cov=src --cov-report=html
|
|
```
|
|
|
|
### Code Quality
|
|
|
|
We use several tools to maintain code quality:
|
|
|
|
- **Black** for code formatting
|
|
- **isort** for import sorting
|
|
- **flake8** for linting
|
|
- **mypy** for type checking
|
|
- **bandit** for security scanning
|
|
|
|
Run all checks:
|
|
```bash
|
|
# Format code
|
|
black src tests
|
|
isort src tests
|
|
|
|
# Lint code
|
|
flake8 src tests
|
|
mypy src
|
|
|
|
# Security scan
|
|
bandit -r src
|
|
```
|
|
|
|
### Architecture Guidelines
|
|
|
|
This project follows Clean Architecture principles:
|
|
|
|
- **Core Layer**: Domain entities, use cases, interfaces, exceptions
|
|
- **Application Layer**: Application services, DTOs, validators, mappers
|
|
- **Infrastructure Layer**: External concerns (database, providers, file system, etc.)
|
|
- **Web Layer**: Controllers, middleware, templates, static assets
|
|
- **Shared Layer**: Utilities, constants, decorators used across layers
|
|
|
|
#### Dependency Rules
|
|
|
|
- Dependencies should point inward toward the core
|
|
- Core layer should have no dependencies on outer layers
|
|
- Use dependency injection for external dependencies
|
|
- Use interfaces/protocols to define contracts
|
|
|
|
#### File Organization
|
|
|
|
- Group related functionality in modules
|
|
- Use clear, descriptive names
|
|
- Keep files focused and cohesive
|
|
- Follow Python package conventions
|
|
|
|
### Commit Guidelines
|
|
|
|
We follow conventional commits:
|
|
|
|
- `feat`: A new feature
|
|
- `fix`: A bug fix
|
|
- `docs`: Documentation only changes
|
|
- `style`: Changes that do not affect the meaning of the code
|
|
- `refactor`: A code change that neither fixes a bug nor adds a feature
|
|
- `test`: Adding missing tests or correcting existing tests
|
|
- `chore`: Changes to the build process or auxiliary tools
|
|
|
|
Example:
|
|
```
|
|
feat(api): add anime search endpoint
|
|
|
|
- Implement search functionality in anime controller
|
|
- Add search validation and error handling
|
|
- Include unit tests for search features
|
|
```
|
|
|
|
### Documentation
|
|
|
|
- Update README.md if you change functionality
|
|
- Add docstrings to all public functions and classes
|
|
- Update API documentation for any API changes
|
|
- Include examples in docstrings where helpful
|
|
|
|
### Performance Considerations
|
|
|
|
- Profile code changes for performance impact
|
|
- Minimize database queries
|
|
- Use caching appropriately
|
|
- Consider memory usage for large operations
|
|
- Test with realistic data sizes
|
|
|
|
### Security Guidelines
|
|
|
|
- Validate all user input
|
|
- Use parameterized queries for database access
|
|
- Implement proper authentication and authorization
|
|
- Keep dependencies up to date
|
|
- Run security scans regularly
|
|
|
|
## Release Process
|
|
|
|
1. Update version in `pyproject.toml`
|
|
2. Update `CHANGELOG.md`
|
|
3. Create release branch
|
|
4. Run full test suite
|
|
5. Update documentation
|
|
6. Create pull request for review
|
|
7. Merge to main after approval
|
|
8. Tag release
|
|
9. Deploy to production
|
|
|
|
## Questions?
|
|
|
|
Feel free to open an issue for any questions about contributing! |