Workflow Git MecaPy
Vue d’ensemble
Section intitulée « Vue d’ensemble »Ce document décrit le workflow Git recommandé pour le développement de MecaPy, incluant les conventions de commit, branching strategy, et processus de collaboration.
Architecture des dépôts
Section intitulée « Architecture des dépôts »Dépôt principal (mecapy)
Section intitulée « Dépôt principal (mecapy) »mecapy/├── repos/ # Sous-modules ou références aux repos│ ├── api/ # Lien vers repo API│ └── frontend/ # Lien vers repo Frontend├── docs/ # Documentation globale├── .claude/ # Configuration Claude└── scripts/ # Scripts de développementDépôts séparés
Section intitulée « Dépôts séparés »- mecapy-api : Backend FastAPI
- mecapy-frontend : Frontend Next.js
Branching Strategy
Section intitulée « Branching Strategy »Structure des branches
Section intitulée « Structure des branches »main (production)├── develop (intégration)│ ├── feat/oauth2-integration│ ├── feat/file-upload│ └── fix/memory-leak├── release/v1.0.0└── hotfix/critical-security-fixTypes de branches
Section intitulée « Types de branches »- Production ready code uniquement
- Toujours déployable
- Protégée : require PR + reviews
- Tagged pour releases (v1.0.0, v1.1.0, etc.)
develop (optionnel)
Section intitulée « develop (optionnel) »- Branche d’intégration
- Merge des features avant main
- Testing et validation
feat/feature-name
Section intitulée « feat/feature-name »- Nouvelles fonctionnalités
- Nommage :
feat/description-courte - Basée sur
mainoudevelop - Supprimée après merge
fix/bug-description
Section intitulée « fix/bug-description »- Corrections de bugs
- Nommage :
fix/description-courte - Basée sur
mainoudevelop
hotfix/critical-issue
Section intitulée « hotfix/critical-issue »- Corrections urgentes en production
- Basée sur
main - Merge vers
mainETdevelop
release/v1.0.0
Section intitulée « release/v1.0.0 »- Préparation release
- Freeze features, bug fixes uniquement
- Merge vers
mainet tag
Conventions de commit
Section intitulée « Conventions de commit »Structure Conventional Commits
Section intitulée « Structure Conventional Commits »<type>(<scope>): <description>
[optional body]
[optional footer]- feat : Nouvelle fonctionnalité
- fix : Correction de bug
- docs : Documentation
- style : Formatage (sans impact logique)
- refactor : Refactorisation
- test : Tests
- chore : Maintenance (deps, config)
- perf : Performance
- ci : CI/CD
- build : Build system
Scopes MecaPy
Section intitulée « Scopes MecaPy »- api : Backend FastAPI
- frontend : Application Next.js
- auth : Authentification
- db : Base de données
- docker : Containers
- docs : Documentation
- scripts : Scripts développement
Règles détaillées des commit messages
Section intitulée « Règles détaillées des commit messages »Bonnes pratiques :
- Utilisez l’impératif présent : “add” et non “added”
- Première ligne < 60 caractères
- Pas de point final dans le titre
- Description détaillée : optionnelle, uniquement si le titre ne suffit pas
- Séparez du titre par une ligne vide
- Limitez à 150 caractères
- Expliquez le “pourquoi” plus que le “quoi”
- Ajoutez
!après le type pour les breaking changes :feat!:
Exemples de commits
Section intitulée « Exemples de commits »# Featurefeat(auth): implement OAuth2 PKCE flow
Add OAuth2 authentication with PKCE for enhanced security.Integrates with Keycloak for user management.
Closes #123
# Bug fixfix(api): resolve memory leak in file upload
The file upload endpoint was not properly releasing memoryafter processing large files. Fixed by implementing properstream cleanup.
# Documentationdocs: update API deployment guide
# Breaking changefeat(api)!: change user model structure
BREAKING CHANGE: User.display_name is now required field
# Autres exemples spécifiques MecaPychore(docker): update PostgreSQL to v15perf(frontend): optimize bundle sizeci: add automated deployment pipelineWorkflow de développement
Section intitulée « Workflow de développement »1. Démarrer une nouvelle feature
Section intitulée « 1. Démarrer une nouvelle feature »# Mettre à jour maingit checkout maingit pull origin main
# Créer branche featuregit checkout -b feat/oauth2-integration
# Développer et committergit add .git commit -m "feat(auth): add OAuth2 client configuration"
# Push première foisgit push -u origin feat/oauth2-integration2. Développement continu
Section intitulée « 2. Développement continu »# Commits réguliersgit add src/auth/git commit -m "feat(auth): implement PKCE challenge generation"
git add tests/git commit -m "test(auth): add OAuth2 flow tests"
# Push des changementsgit push origin feat/oauth2-integration3. Mise à jour depuis main
Section intitulée « 3. Mise à jour depuis main »# Récupérer les derniers changementsgit checkout maingit pull origin main
# Rebaser la feature branchgit checkout feat/oauth2-integrationgit rebase main
# Résoudre conflits si nécessaire# git add <resolved-files># git rebase --continue
# Push force après rebasegit push --force-with-lease origin feat/oauth2-integration4. Pull Request
Section intitulée « 4. Pull Request »Création PR
Section intitulée « Création PR »# Via GitHub CLIgh pr create --title "feat(auth): implement OAuth2 PKCE flow" \ --body "Implements OAuth2 with PKCE for secure authentication"
# Ou via interface web GitHubTemplate PR
Section intitulée « Template PR »## DescriptionBrief description of changes
## Type of change- [ ] Bug fix- [x] New feature- [ ] Breaking change- [ ] Documentation update
## Testing- [x] Unit tests pass- [x] Integration tests pass- [ ] Manual testing completed
## Checklist- [x] Code follows style guidelines- [x] Self-review completed- [x] Documentation updated- [x] Tests added/updated5. Review et merge
Section intitulée « 5. Review et merge »Review checklist
Section intitulée « Review checklist »- Code quality et style
- Tests coverage
- Documentation à jour
- Pas de breaking changes non documentés
- Performance impact évalué
Merge strategies
Section intitulée « Merge strategies »# Squash merge (recommandé pour features)git checkout maingit merge --squash feat/oauth2-integrationgit commit -m "feat(auth): implement OAuth2 PKCE flow"
# Merge commit (pour releases)git merge --no-ff release/v1.0.0
# Rebase merge (pour hotfixes)git rebase feat/small-fixGestion des releases
Section intitulée « Gestion des releases »Semantic Versioning
Section intitulée « Semantic Versioning »- MAJOR : Breaking changes (v1.0.0 → v2.0.0)
- MINOR : New features (v1.0.0 → v1.1.0)
- PATCH : Bug fixes (v1.0.0 → v1.0.1)
Processus de release
Section intitulée « Processus de release »# 1. Créer branche releasegit checkout -b release/v1.1.0 develop
# 2. Bump versionecho "1.1.0" > VERSIONgit commit -m "chore: bump version to 1.1.0"
# 3. Tests finaux et bug fixesgit commit -m "fix: resolve last-minute bug"
# 4. Merge vers maingit checkout maingit merge --no-ff release/v1.1.0
# 5. Tag releasegit tag -a v1.1.0 -m "Release version 1.1.0"
# 6. Merge vers developgit checkout developgit merge main
# 7. Push toutgit push origin main develop --tags
# 8. Supprimer branche releasegit branch -d release/v1.1.0git push origin --delete release/v1.1.0Changelog automatique
Section intitulée « Changelog automatique »# Installationnpm install -g conventional-changelog-cli
# Génération changelogconventional-changelog -p angular -i CHANGELOG.md -s
# Commit changeloggit add CHANGELOG.mdgit commit -m "docs: update changelog for v1.1.0"Collaboration multi-dépôts
Section intitulée « Collaboration multi-dépôts »Synchronisation repos
Section intitulée « Synchronisation repos »# Dans le repo principal mecapycd repos/apigit pull origin main
cd ../frontendgit pull origin main
# Commit références mises à jourcd ../..git add repos/git commit -m "chore: update submodule references"Développement coordonné
Section intitulée « Développement coordonné »- API First : Développer API endpoints
- Frontend Integration : Intégrer avec API
- Documentation : Mettre à jour docs globales
- Testing : Tests end-to-end
Scripts utilitaires
Section intitulée « Scripts utilitaires »#!/bin/bashecho "Synchronizing all repositories..."
# APIcd repos/apigit checkout maingit pull origin mainecho "✅ API synchronized"
# Frontendcd ../frontendgit checkout maingit pull origin mainecho "✅ Frontend synchronized"
# Main repocd ../..git add repos/if ! git diff --cached --quiet; then git commit -m "chore: sync repository references" echo "✅ Main repo updated"fi
echo "🎉 All repositories synchronized!"Bonnes pratiques
Section intitulée « Bonnes pratiques »- Atomiques : Un commit = une modification logique
- Fréquents : Committer souvent, pusher régulièrement
- Descriptifs : Messages clairs et complets
- Testés : Chaque commit doit passer les tests
Branches
Section intitulée « Branches »- Courtes : Lifecycle court pour éviter conflicts
- Focalisées : Une branche = une fonctionnalité
- À jour : Rebase régulier depuis main
- Nettoyées : Supprimer après merge
- Constructives : Feedback pour améliorer
- Rapides : Reviews dans les 24h
- Complètes : Code, tests, docs
- Bienveillantes : Respecter l’auteur
- Planifiées : Roadmap et calendrier
- Testées : QA approfondie
- Documentées : Changelog et migration guide
- Sécurisées : Backup et rollback plan
Outils et intégrations
Section intitulée « Outils et intégrations »Git Hooks
Section intitulée « Git Hooks »#!/bin/bash# Linting et tests avant commit
# APIcd repos/apiuv run ruff check || exit 1uv run pytest || exit 1
# Frontendcd ../frontendpnpm lint || exit 1pnpm test || exit 1
echo "✅ Pre-commit checks passed"GitHub Actions
Section intitulée « GitHub Actions »name: CI/CD Pipeline
on: pull_request: branches: [main, develop] push: branches: [main]
jobs: test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Run tests run: | cd repos/api && uv run pytest cd ../frontend && pnpm test
deploy: if: github.ref == 'refs/heads/main' needs: test runs-on: ubuntu-latest steps: - name: Deploy to production run: echo "Deploying..."Outils CLI
Section intitulée « Outils CLI »# Installation des outilsnpm install -g commitizennpm install -g conventional-changelog-clipip install pre-commit
# Configuration commitizenecho '\{"path": "cz-conventional-changelog"\}' > .czrc
# Utilisationgit cz # Aide pour commits conventionalVersion : 1.0.0
Dernière mise à jour : 2024-01-15