diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index 4ba731c..1b5ea9a 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -4,11 +4,10 @@ on: push: branches: - main - - dev jobs: # ───────────────────────────────────────────── - # BUILD — commun aux deux branches + # COMPILATION — commun aux deux branches # ───────────────────────────────────────────── build: name: Build & Push Docker Image @@ -20,17 +19,11 @@ jobs: # Le tag d'image dépend de la branche : # main → webzine:latest - # dev → webzine:dev - name: Set image tag id: vars run: | - if [ "${{ gitea.ref_name }}" = "main" ]; then - echo "IMAGE_TAG=latest" >> $GITHUB_OUTPUT - echo "ENV_LABEL=production" >> $GITHUB_OUTPUT - else - echo "IMAGE_TAG=dev" >> $GITHUB_OUTPUT - echo "ENV_LABEL=development" >> $GITHUB_OUTPUT - fi + echo "IMAGE_TAG=latest" >> $GITHUB_OUTPUT + echo "ENV_LABEL=production" >> $GITHUB_OUTPUT - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 @@ -43,6 +36,7 @@ jobs: username: ${{ secrets.REGISTRY_USERNAME }} password: ${{ secrets.REGISTRY_PASSWORD }} + # Construction et publication de l'image Docker - name: Build and push Docker image uses: docker/build-push-action@v5 with: @@ -58,12 +52,11 @@ jobs: env_label: ${{ steps.vars.outputs.ENV_LABEL }} # ───────────────────────────────────────────── - # DEPLOY — Machine de PRODUCTION (branche main) + # DÉPLOIEMENT — Serveur de PRODUCTION (branche main) # ───────────────────────────────────────────── deploy-production: name: Deploy to Production needs: build - if: gitea.ref_name == 'main' runs-on: ubuntu-latest steps: @@ -77,18 +70,18 @@ jobs: script: | set -e - echo "=== [PROD] Pulling image ===" + echo "=== [PROD] Récupération de l'image ===" docker login ${{ vars.REGISTRY_URL }} \ -u ${{ secrets.REGISTRY_USERNAME }} \ -p ${{ secrets.REGISTRY_PASSWORD }} docker pull ${{ vars.REGISTRY_URL }}/webzine/webzine:latest - echo "=== [PROD] Stopping old container ===" + echo "=== [PROD] Arrêt de l'ancien conteneur ===" docker stop webzine-prod 2>/dev/null || true docker rm webzine-prod 2>/dev/null || true - echo "=== [PROD] Starting new container ===" + echo "=== [PROD] Démarrage du nouveau conteneur ===" docker run -d \ --name webzine-prod \ --restart unless-stopped \ @@ -99,53 +92,7 @@ jobs: -e ASPNETCORE_ENVIRONMENT=Production \ ${{ vars.REGISTRY_URL }}/webzine/webzine:latest - echo "=== [PROD] Cleaning up old images ===" + echo "=== [PROD] Nettoyage des anciennes images ===" docker image prune -f - echo "=== [PROD] Deployment complete ===" - - # ───────────────────────────────────────────── - # DEPLOY — Machine de DÉVELOPPEMENT (branche dev) - # ───────────────────────────────────────────── - deploy-development: - name: Deploy to Development - needs: build - if: gitea.ref_name == 'dev' - runs-on: ubuntu-latest - - steps: - - name: Deploy via SSH to DEVELOPMENT server - uses: appleboy/ssh-action@v1.0.3 - with: - host: ${{ secrets.DEV_SSH_HOST }} - username: ${{ secrets.DEV_SSH_USER }} - key: ${{ secrets.DEV_SSH_KEY }} - port: ${{ secrets.DEV_SSH_PORT || 22 }} - script: | - set -e - - echo "=== [DEV] Pulling image ===" - docker login ${{ vars.REGISTRY_URL }} \ - -u ${{ secrets.REGISTRY_USERNAME }} \ - -p ${{ secrets.REGISTRY_PASSWORD }} - - docker pull ${{ vars.REGISTRY_URL }}/webzine/webzine:dev - - echo "=== [DEV] Stopping old container ===" - docker stop webzine-dev 2>/dev/null || true - docker rm webzine-dev 2>/dev/null || true - - echo "=== [DEV] Starting new container ===" - docker run -d \ - --name webzine-dev \ - --restart unless-stopped \ - -p 8080:8080 \ - -v /opt/webzine/dev/data:/app/Data \ - -v /opt/webzine/dev/logs:/Logs \ - -e ASPNETCORE_ENVIRONMENT=Development \ - ${{ vars.REGISTRY_URL }}/webzine/webzine:dev - - echo "=== [DEV] Cleaning up old images ===" - docker image prune -f - - echo "=== [DEV] Deployment complete ===" \ No newline at end of file + echo "=== [PROD] Déploiement terminé ===" \ No newline at end of file diff --git a/.gitea/workflows/pr-endpoint-check.yml b/.gitea/workflows/pr-endpoint-check.yml index c0936d2..c67fab3 100644 --- a/.gitea/workflows/pr-endpoint-check.yml +++ b/.gitea/workflows/pr-endpoint-check.yml @@ -14,13 +14,13 @@ jobs: steps: # ───────────────────────────────────────────── - # 1. Checkout code + # Récupération du code source # ───────────────────────────────────────────── - name: Checkout PR branch uses: actions/checkout@v4 # ───────────────────────────────────────────── - # 2. Setup .NET 10 + # Installation de .NET 10 # ───────────────────────────────────────────── - name: Setup .NET 10 uses: actions/setup-dotnet@v4 @@ -28,7 +28,7 @@ jobs: dotnet-version: "10.0.x" # ───────────────────────────────────────────── - # 3. Restore & Build + # Restauration des dépendances et compilation # ───────────────────────────────────────────── - name: Restore dependencies run: dotnet restore Webzine.sln @@ -37,7 +37,7 @@ jobs: run: dotnet build Webzine.sln --no-restore --configuration Release # ───────────────────────────────────────────── - # 4. Run unit tests (entity tests) + # Exécution des tests unitaires (entités) # ───────────────────────────────────────────── - name: Run unit tests run: | @@ -47,7 +47,7 @@ jobs: --logger "console;verbosity=normal" # ───────────────────────────────────────────── - # 5. Start the web application in background + # Démarrage de l'application web en arrière-plan # ───────────────────────────────────────────── - name: Start Webzine application run: | @@ -57,16 +57,16 @@ jobs: --no-build \ -- --urls "http://localhost:5038" & - echo "Waiting for application to start..." + echo "Attente du démarrage de l'application..." timeout 60 bash -c ' until curl -sf http://localhost:5038 > /dev/null 2>&1; do sleep 1 done ' - echo "Application is ready!" + echo "Application prête !" # ───────────────────────────────────────────── - # 6. Run endpoint performance tests + # Exécution des tests de performance des endpoints # ───────────────────────────────────────────── - name: Test endpoint response times id: perf_test @@ -77,7 +77,7 @@ jobs: echo "failed=$FAIL_COUNT" >> "$GITHUB_OUTPUT" # ───────────────────────────────────────────── - # 7. Post report as PR comment + # Publication du rapport en commentaire de PR # ───────────────────────────────────────────── - name: Post performance report as PR comment if: always() @@ -87,15 +87,15 @@ jobs: REPO: ${{ gitea.repository }} PR_NUMBER: ${{ gitea.event.pull_request.number }} run: | - REPORT_CONTENT=$(cat /tmp/webzine_endpoint_report.txt 2>/dev/null || echo "No report generated.") + REPORT_CONTENT=$(cat /tmp/webzine_endpoint_report.txt 2>/dev/null || echo "Aucun rapport généré.") FAILED_COUNT="${{ steps.perf_test.outputs.failed }}" if [ "${FAILED_COUNT:-0}" -gt 0 ]; then - HEADER="## ❌ Performance Check FAILED" - INTRO="${FAILED_COUNT} endpoint(s) exceeded 1 second or returned a server error." + HEADER="## ❌ Vérification des performances ÉCHOUÉE" + INTRO="${FAILED_COUNT} endpoint(s) ont dépassé 1 seconde ou retourné une erreur serveur." else - HEADER="## ✅ Performance Check PASSED" - INTRO="All endpoints responded in under 1 second." + HEADER="## ✅ Vérification des performances RÉUSSIE" + INTRO="Tous les endpoints ont répondu en moins d'une seconde." fi BODY=$(cat < Threshold: **1000ms** | Checked by the **PR Endpoint Performance** workflow. + > Seuil : **1000ms** | Vérifié par le workflow **PR Endpoint Performance**. EOF ) @@ -118,15 +118,15 @@ jobs: "$GITEA_SERVER_URL/api/v1/repos/$REPO/issues/$PR_NUMBER/comments" # ───────────────────────────────────────────── - # 8. Fail the job if any endpoint failed + # Blocage de la PR si un endpoint a échoué # ───────────────────────────────────────────── - name: Enforce performance gate run: | FAILED="${{ steps.perf_test.outputs.failed }}" if [ "${FAILED:-0}" -gt 0 ]; then - echo "❌ PR REJECTED: ${FAILED} endpoint(s) failed the 1-second threshold." - echo " Fix the slow/failing endpoints listed above before merging." + echo "❌ PR REJETÉE : ${FAILED} endpoint(s) n'ont pas respecté le seuil d'une seconde." + echo " Corrigez les endpoints lents ou en erreur avant de fusionner." exit 1 else - echo "✅ All endpoints passed the performance gate." + echo "✅ Tous les endpoints ont passé le contrôle de performance." fi \ No newline at end of file