chore: Update Dockerfiles, Makefile and documentation
- Updated Dockerfile.production - Updated Makefile - Updated deployment documentation - Updated docker/ci/Dockerfile, docker/php/Dockerfile, docker/worker/Dockerfile - Updated dependency scanning documentation - Added git-hooks documentation
This commit is contained in:
151
docs/contributing/git-hooks.md
Normal file
151
docs/contributing/git-hooks.md
Normal file
@@ -0,0 +1,151 @@
|
||||
# Git Hooks
|
||||
|
||||
Dieses Projekt verwendet Git Hooks, um Code-Quality und Commit-Standards automatisch zu ?berpr?fen.
|
||||
|
||||
## Aktivierte Hooks
|
||||
|
||||
### Pre-commit Hook
|
||||
**Zweck**: Schnelle Checks vor jedem Commit
|
||||
|
||||
**Pr?ft**:
|
||||
- ? PHP Code Style (PHP-CS-Fixer) f?r ge?nderte PHP-Dateien
|
||||
- ? JavaScript/TypeScript Linting (ESLint) f?r ge?nderte JS/TS-Dateien
|
||||
- ? Merge-Konflikt-Marker in staged Dateien
|
||||
|
||||
**?berspringen**: `git commit --no-verify`
|
||||
|
||||
**Beispiel-Fehler**:
|
||||
```
|
||||
? Code style issues found in src/MyClass.php
|
||||
?? Run: make cs-fix
|
||||
```
|
||||
|
||||
### Commit-msg Hook
|
||||
**Zweck**: Validierung der Commit-Message nach Conventional Commits
|
||||
|
||||
**Format**: `type(scope): subject`
|
||||
|
||||
**Erlaubte Types**:
|
||||
- `feat`: Neue Features
|
||||
- `fix`: Bugfixes
|
||||
- `docs`: Dokumentation
|
||||
- `style`: Code-Formatierung (ohne Funktions?nderung)
|
||||
- `refactor`: Code-Refactoring
|
||||
- `perf`: Performance-Verbesserungen
|
||||
- `test`: Tests hinzuf?gen/?ndern
|
||||
- `build`: Build-System/Abh?ngigkeiten
|
||||
- `ci`: CI/CD Konfiguration
|
||||
- `chore`: Sonstige ?nderungen
|
||||
- `revert`: Revert eines Commits
|
||||
|
||||
**Beispiele**:
|
||||
```bash
|
||||
feat: Add user authentication
|
||||
fix(api): Resolve 502 error in staging
|
||||
docs: Update README
|
||||
refactor(framework): Improve DI container
|
||||
```
|
||||
|
||||
**?berspringen**: `git commit --no-verify`
|
||||
|
||||
### Pre-push Hook
|
||||
**Zweck**: Langsamere Checks vor dem Push
|
||||
|
||||
**Pr?ft**:
|
||||
- ? PHPStan Static Analysis
|
||||
- ? Unit Tests (schneller Teil der Test-Suite)
|
||||
|
||||
**Hinweis**: Dieser Hook kann etwas l?nger dauern. Er fragt bei Fehlern, ob trotzdem gepusht werden soll.
|
||||
|
||||
**?berspringen**: `git push --no-verify`
|
||||
|
||||
## Hook deaktivieren
|
||||
|
||||
### Einzelnen Commit ?berspringen
|
||||
```bash
|
||||
git commit --no-verify
|
||||
```
|
||||
|
||||
### Einzelnen Push ?berspringen
|
||||
```bash
|
||||
git push --no-verify
|
||||
```
|
||||
|
||||
### Hooks komplett deaktivieren
|
||||
```bash
|
||||
# Tempor?r alle Hooks deaktivieren
|
||||
git config core.hooksPath /dev/null
|
||||
|
||||
# Wieder aktivieren
|
||||
git config --unset core.hooksPath
|
||||
```
|
||||
|
||||
## Hook manuell testen
|
||||
|
||||
```bash
|
||||
# Pre-commit Hook testen
|
||||
.git/hooks/pre-commit
|
||||
|
||||
# Commit-msg Hook testen
|
||||
echo "test: Test message" | .git/hooks/commit-msg /dev/stdin
|
||||
|
||||
# Pre-push Hook testen
|
||||
.git/hooks/pre-push
|
||||
```
|
||||
|
||||
## Hook anpassen
|
||||
|
||||
Die Hook-Dateien befinden sich in `.git/hooks/`:
|
||||
- `.git/hooks/pre-commit` - Pre-commit Checks
|
||||
- `.git/hooks/commit-msg` - Commit-Message Validierung
|
||||
- `.git/hooks/pre-push` - Pre-push Checks
|
||||
|
||||
**Wichtig**: Hook-Dateien werden nicht ins Repository committed (sie sind in `.git/hooks/`, nicht im Working Directory).
|
||||
|
||||
Um Hooks f?r das gesamte Team zu teilen, gibt es mehrere M?glichkeiten:
|
||||
1. **Husky** (npm package) - f?r Node.js-Projekte
|
||||
2. **CaptainHook** (PHP package) - f?r PHP-Projekte
|
||||
3. Manuelles Setup-Skript
|
||||
|
||||
## Best Practices
|
||||
|
||||
1. **Pre-commit**: Schnelle Checks (< 5 Sekunden)
|
||||
- Code Style
|
||||
- Syntax-Checks
|
||||
- Merge-Konflikt-Detection
|
||||
|
||||
2. **Pre-push**: Langsamere Checks (< 2 Minuten)
|
||||
- Static Analysis
|
||||
- Unit Tests
|
||||
- Integration Tests (optional)
|
||||
|
||||
3. **CI/CD**: Umfassende Checks
|
||||
- Alle Tests
|
||||
- Coverage Reports
|
||||
- Security Scans
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Hook wird nicht ausgef?hrt
|
||||
```bash
|
||||
# Pr?fe Berechtigungen
|
||||
ls -la .git/hooks/
|
||||
|
||||
# Mache Hook ausf?hrbar
|
||||
chmod +x .git/hooks/pre-commit
|
||||
```
|
||||
|
||||
### Hook ist zu langsam
|
||||
- Verringere die Anzahl der Checks im pre-commit Hook
|
||||
- Verschiebe langsamere Checks in den pre-push Hook
|
||||
- Nutze `--no-verify` f?r schnelle WIP-Commits
|
||||
|
||||
### Hook schl?gt im Docker fehl
|
||||
Die Hooks pr?fen automatisch, ob sie in Docker laufen und passen die Befehle entsprechend an.
|
||||
|
||||
## Weitere Hooks hinzuf?gen
|
||||
|
||||
Weitere n?tzliche Hooks:
|
||||
- `post-merge`: Automatische `composer install` nach `git pull`
|
||||
- `post-checkout`: Automatische Dependency-Updates
|
||||
- `prepare-commit-msg`: Automatische Ticket-Nummern in Commit-Messages
|
||||
@@ -201,14 +201,19 @@ Roave automatically blocks `composer install` or `composer update` if any instal
|
||||
|
||||
### Why Deferred?
|
||||
|
||||
Current project uses **PHP 8.5 RC2** (bleeding edge), which causes dependency resolution conflicts:
|
||||
Current project uses **PHP 8.5 RC3** (bleeding edge), which causes dependency resolution conflicts:
|
||||
```
|
||||
brianium/paratest v7.8.4 requires php ~8.2.0 || ~8.3.0 || ~8.4.0
|
||||
your php version (8.5.0RC2) does not satisfy that requirement
|
||||
your php version (8.5.0RC3) does not satisfy that requirement
|
||||
```
|
||||
|
||||
**Planned Integration:** When PHP 8.5 stable is released and all testing dependencies support it.
|
||||
|
||||
> ℹ️ **PHP Runtime Strategy:**
|
||||
> - Runtime container builds accept `--build-arg PHP_VERSION` (default `8.5.0RC3`) to keep PHP aligned with upstream RC tags.
|
||||
> - `.gitea/workflows/production-deploy.yml` sets the same version for CI rebuilds (`--pull` ensures fresh layers).
|
||||
> - We'll move to `8.5.0RC4` as soon as upstream publishes the image and switch to the latest stable PHP release at the end of November.
|
||||
|
||||
### Roave vs Composer Audit
|
||||
|
||||
| Feature | Roave Security Advisories | Composer Audit |
|
||||
|
||||
Reference in New Issue
Block a user