Update Development

2025-11-12 15:58:33 +00:00
parent acdca2c3fd
commit 0cbf7b5fc1

@@ -1,15 +1,15 @@
# Development
### Development Environment Setup
## Development Environment Setup
#### Prerequisites
### Prerequisites
- **Python**: 3.9, 3.10, or 3.11
- **Git**: For version control
- **Docker**: (Optional) For containerized testing
- **IDE**: VS Code, PyCharm, or similar with Python support
#### Initial Setup
### Initial Setup
1. **Clone the repository:**
```bash
@@ -44,7 +44,7 @@
# Edit config.ini with your development credentials
```
### Project Structure
## Project Structure
```
pterodactyl-discord-bot/
@@ -74,9 +74,9 @@ pterodactyl-discord-bot/
└── LICENSE # GPL-3.0 License
```
### Development Workflow
## Development Workflow
#### 1. Feature Development
### 1. Feature Development
```bash
# Create feature branch
@@ -98,7 +98,7 @@ git commit -m "feat: add your feature description"
git push origin feature/your-feature-name
```
#### 2. Bug Fixes
### 2. Bug Fixes
```bash
# Create bugfix branch
@@ -124,7 +124,7 @@ git add .
git commit -m "fix: resolve bug description"
```
#### 3. Testing Changes
### 3. Testing Changes
```bash
# Run all tests
@@ -143,9 +143,9 @@ make test-quick
make watch
```
### Testing Infrastructure
## Testing Infrastructure
#### Test Suite Organization
### Test Suite Organization
```python
# test_pterodisbot.py structure
@@ -196,7 +196,7 @@ make watch
└── test_metrics_collection
```
#### Running Tests Locally
### Running Tests Locally
```bash
# Using Makefile (recommended)
@@ -218,7 +218,7 @@ pytest -m "not slow" -v # Skip slow tests
pytest --lf # Run last failed tests only
```
#### Coverage Goals
### Coverage Goals
- **Minimum**: 70% overall coverage
- **Target**: 85% overall coverage
@@ -227,7 +227,7 @@ pytest --lf # Run last failed tests only
- Pterodactyl API client
- Metrics tracking system
#### Viewing Coverage Reports
### Viewing Coverage Reports
```bash
# Generate HTML report
@@ -241,9 +241,9 @@ python -m http.server --directory htmlcov 8000
pytest --cov=pterodisbot --cov-report=term-missing
```
### Code Quality Standards
## Code Quality Standards
#### Linting and Formatting
### Linting and Formatting
```bash
# Check all quality standards
@@ -259,7 +259,7 @@ black --check --line-length=120 pterodisbot.py
isort --check-only --profile black pterodisbot.py
```
#### Style Guidelines
### Style Guidelines
**PEP 8 Compliance:**
- Maximum line length: 120 characters
@@ -303,9 +303,9 @@ def complex_function(arg1: str, arg2: int) -> dict:
- Complex algorithms should have explanatory comments
- TODO comments should include ticket references
### Security Best Practices
## Security Best Practices
#### Running Security Scans
### Running Security Scans
```bash
# All security checks
@@ -317,7 +317,7 @@ safety check # Dependency vulnerabilities
pip-audit # Package auditing
```
#### Security Checklist
### Security Checklist
- [ ] No hardcoded credentials in code
- [ ] API keys stored in config.ini (gitignored)
@@ -327,9 +327,9 @@ pip-audit # Package auditing
- [ ] Error messages don't leak sensitive info
- [ ] Logs don't contain API keys or tokens
### Debugging Tips
## Debugging Tips
#### Logging Levels
### Logging Levels
```python
# Add debug logging
@@ -345,7 +345,7 @@ logger.warning(f"API rate limit approaching")
logger.error(f"Failed to update embed: {str(e)}")
```
#### Common Debugging Commands
### Common Debugging Commands
```bash
# View logs in real-time
@@ -362,7 +362,7 @@ pytest test_pterodisbot.py::test_name --pdb # Drop into debugger on failure
pytest test_pterodisbot.py -vv --showlocals # Show local variables
```
#### VS Code Launch Configuration
### VS Code Launch Configuration
```json
{
@@ -393,9 +393,9 @@ pytest test_pterodisbot.py -vv --showlocals # Show local variables
}
```
### CI/CD Integration
## CI/CD Integration
#### Automated Workflows
### Automated Workflows
The project uses Gitea Actions for continuous integration and deployment:
@@ -409,7 +409,7 @@ The project uses Gitea Actions for continuous integration and deployment:
- Steps: Test → Build Docker → Push Registry → Report
- Features: Multi-arch builds, automatic versioning
#### Local CI Simulation
### Local CI Simulation
```bash
# Run full CI pipeline locally
@@ -424,7 +424,7 @@ make ci
# 6. Generate reports
```
#### Branch Protection Rules
### Branch Protection Rules
Recommended settings for `main` branch:
- ✅ Require status checks to pass
@@ -435,7 +435,7 @@ Recommended settings for `main` branch:
- ✅ Require pull request reviews (1+ approvals)
- ✅ Dismiss stale reviews on new commits
### Performance Testing
## Performance Testing
```bash
# Profile the application
@@ -451,9 +451,9 @@ pip install memory_profiler
python -m memory_profiler pterodisbot.py
```
### Documentation
## Documentation
#### Generating API Documentation
### Generating API Documentation
```bash
# Install documentation tools
@@ -466,7 +466,7 @@ pdoc --html --output-dir docs pterodisbot.py server_metrics_graphs.py
python -m http.server --directory docs 8080
```
#### Updating Documentation
### Updating Documentation
When adding new features:
1. Update inline code comments