Merge remote-tracking branch 'origin/dev' into j2/ajout_repo

This commit is contained in:
Loic Masi
2026-03-26 15:55:56 +01:00
18 changed files with 564 additions and 91 deletions

View File

@@ -18,7 +18,7 @@
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
LICENSE

View File

@@ -0,0 +1,99 @@
name: Deploy Webzine
on:
push:
branches:
- main
- dev
jobs:
# ─────────────────────────────────────────────
# COMPILATION — commun aux deux branches
# ─────────────────────────────────────────────
build:
name: Build & Push Docker Image
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
# Le tag d'image dépend de la branche :
# main → webzine:latest
- name: Set image tag
id: vars
run: |
echo "IMAGE_TAG=latest" >> $GITHUB_OUTPUT
echo "ENV_LABEL=production" >> $GITHUB_OUTPUT
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# Connexion au registry Gitea intégré
- name: Log in to Gitea Container Registry
uses: docker/login-action@v3
with:
registry: ${{ vars.REGISTRY_URL }}
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:
context: .
file: ./Webzine.WebApplication/Dockerfile
push: true
tags: ${{ vars.REGISTRY_URL }}/webzine/webzine:${{ steps.vars.outputs.IMAGE_TAG }}
cache-from: type=registry,ref=${{ vars.REGISTRY_URL }}/webzine/webzine:buildcache-${{ steps.vars.outputs.IMAGE_TAG }}
cache-to: type=registry,ref=${{ vars.REGISTRY_URL }}/webzine/webzine:buildcache-${{ steps.vars.outputs.IMAGE_TAG }},mode=max
outputs:
image_tag: ${{ steps.vars.outputs.IMAGE_TAG }}
env_label: ${{ steps.vars.outputs.ENV_LABEL }}
# ─────────────────────────────────────────────
# DÉPLOIEMENT — Serveur de PRODUCTION (branche main)
# ─────────────────────────────────────────────
deploy-production:
name: Deploy to Production
needs: build
runs-on: ubuntu-latest
steps:
- name: Deploy via SSH to PRODUCTION server
uses: appleboy/ssh-action@v1.0.3
with:
host: ${{ secrets.PROD_HOST }}
username: ${{ secrets.PROD_USER }}
key: ${{ secrets.PROD_SSH_KEY }}
port: ${{ secrets.PROD_SSH_PORT || 22 }}
script: |
set -e
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] Arrêt de l'ancien conteneur ==="
docker stop webzine-prod 2>/dev/null || true
docker rm webzine-prod 2>/dev/null || true
echo "=== [PROD] Démarrage du nouveau conteneur ==="
docker run -d \
--name webzine-prod \
--restart unless-stopped \
-p 80:8080 \
-p 443:8081 \
-v /opt/webzine/prod/data:/app/Data \
-v /opt/webzine/prod/logs:/Logs \
-e ASPNETCORE_ENVIRONMENT=Production \
${{ vars.REGISTRY_URL }}/webzine/webzine:latest
echo "=== [PROD] Nettoyage des anciennes images ==="
docker image prune -f
echo "=== [PROD] Déploiement terminé ==="

View File

@@ -0,0 +1,132 @@
name: PR Endpoint Performance Check
on:
pull_request:
branches:
- main
- master
- develop
jobs:
endpoint-performance-check:
name: Test All Endpoints (< 1s)
runs-on: ubuntu-latest
steps:
# ─────────────────────────────────────────────
# Récupération du code source
# ─────────────────────────────────────────────
- name: Checkout PR branch
uses: actions/checkout@v4
# ─────────────────────────────────────────────
# Installation de .NET 10
# ─────────────────────────────────────────────
- name: Setup .NET 10
uses: actions/setup-dotnet@v4
with:
dotnet-version: "10.0.x"
# ─────────────────────────────────────────────
# Restauration des dépendances et compilation
# ─────────────────────────────────────────────
- name: Restore dependencies
run: dotnet restore Webzine.sln
- name: Build solution
run: dotnet build Webzine.sln --no-restore --configuration Release
# ─────────────────────────────────────────────
# Exécution des tests unitaires (entités)
# ─────────────────────────────────────────────
- name: Run unit tests
run: |
dotnet test Webzine.Entity.Tests/Webzine.Entity.Tests.csproj \
--no-build \
--configuration Release \
--logger "console;verbosity=normal"
# ─────────────────────────────────────────────
# Démarrage de l'application web en arrière-plan
# ─────────────────────────────────────────────
- name: Start Webzine application
run: |
dotnet run \
--project Webzine.WebApplication/Webzine.WebApplication.csproj \
--configuration Release \
--no-build \
-- --urls "http://localhost:5038" &
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 prête !"
# ─────────────────────────────────────────────
# Exécution des tests de performance des endpoints
# ─────────────────────────────────────────────
- name: Test endpoint response times
id: perf_test
run: |
chmod +x scripts/test-endpoints.sh
bash scripts/test-endpoints.sh http://localhost:5038 1000 || true
FAIL_COUNT=$(grep -c "^\[FAIL\]\|^\[SLOW\]" /tmp/webzine_endpoint_report.txt || echo 0)
echo "failed=$FAIL_COUNT" >> "$GITHUB_OUTPUT"
# ─────────────────────────────────────────────
# Publication du rapport en commentaire de PR
# ─────────────────────────────────────────────
- name: Post performance report as PR comment
if: always()
env:
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
GITEA_SERVER_URL: ${{ gitea.server_url }}
REPO: ${{ gitea.repository }}
PR_NUMBER: ${{ gitea.event.pull_request.number }}
run: |
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="## ❌ Vérification des performances ÉCHOUÉE"
INTRO="${FAILED_COUNT} endpoint(s) ont dépassé 1 seconde ou retourné une erreur serveur."
else
HEADER="## ✅ Vérification des performances RÉUSSIE"
INTRO="Tous les endpoints ont répondu en moins d'une seconde."
fi
BODY=$(cat <<EOF
$HEADER
$INTRO
\`\`\`
$REPORT_CONTENT
\`\`\`
> Seuil : **1000ms** | Vérifié par le workflow **PR Endpoint Performance**.
EOF
)
curl -s -X POST \
-H "Authorization: token $GITEA_TOKEN" \
-H "Content-Type: application/json" \
-d "$(jq -n --arg body "$BODY" '{body: $body}')" \
"$GITEA_SERVER_URL/api/v1/repos/$REPO/issues/$PR_NUMBER/comments"
# ─────────────────────────────────────────────
# 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 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 "✅ Tous les endpoints ont passé le contrôle de performance."
fi

View File

@@ -16,7 +16,7 @@
<thead class="table-active">
<tr>
<th scope="col" class="p-2">Nom</th>
<th scope="col" class="text-center p-2" style="width: 100px;">Actions</th>
<th scope="col" class="text-center p-2">Actions</th>
</tr>
</thead>
<tbody>

View File

@@ -2,7 +2,7 @@
<div class="container">
<!-- ARTISTE -->
<div class="row mb-3 align-items-center">
<div class="row mb-3">
<label class="col-md-3 col-form-label">Nom de l'artiste<span class="text-danger">*</span></label>
<div class="col-md-9">
<input asp-for="Nom" class="form-control" />
@@ -10,14 +10,15 @@
</div>
<!-- BIOGRAPHIE -->
<div class="row mb-3 align-items-center">
<label class="col-md-3 col-form-label">Biographie<span class="text-danger">*</span></label>
<div class="row mb-3">
<label class="col-md-3 col-form-label">Biographie</label>
<div class="col-md-9">
<input asp-for="Biographie" class="form-control"/>
<textarea asp-for="Biographie" class="form-control" rows="5"></textarea>
</div>
</div>
<!-- BOUTONS -->
<div class="row mt-4">
<div class="col-md-9 offset-md-3">

View File

@@ -14,10 +14,10 @@
<thead class="table-active">
<tr>
<th scope="col">Titre</th>
<th scope="col">Auteur</th>
<th scope="col">Nom</th>
<th scope="col">Commentaire</th>
<th scope="col">Date de création</th>
<th scope="col" class="text-center p-2" style="width: 100px" ;>Actions</th>
<th scope="col" class="text-center p-2">Actions</th>
</tr>
</thead>
<tbody>
@@ -25,7 +25,9 @@
{
<tr class="align-middle">
<td>
@commentaire.Titre.Libelle
<a asp-action="Details" asp-controller="Titre" asp-route-id="@commentaire.Titre.IdTitre">
@commentaire.Titre.Libelle
</a>
</td>
<td>
@commentaire.Auteur

View File

@@ -12,19 +12,19 @@
<div class="col-md-4">
<a asp-area="Administration"
asp-controller="Artiste">
<div class="ratio ratio-4x3">
<div class="card shadow-sm p-4 bg-light h-100 dashboard-card">
<i class="fa fa-users fa-3x text-primary mb-3"></i>
<div class="py-5 bg-light rounded-3 d-flex flex-column justify-content-center align-items-center text-primary">
<i class="fa fa-users fa-5x text-primary mb-3"></i>
<h3>
@Model.NombreArtistes
</h3>
<p>
artistes
</p>
<h2>
@Model.NombreArtistes
</h2>
<p>
artistes
</p>
</div>
</div>
</a>
</div>
@@ -33,17 +33,17 @@
<a asp-area=""
asp-controller="Artiste"
asp-route-nom="@Model.ArtisteLePlusChronique">
<div class="ratio ratio-4x3">
<div class="py-5 bg-light rounded-3 d-flex flex-column justify-content-center align-items-center text-primary">
<i class="fa fa-user fa-5x text-primary mb-3"></i>
<div class="card shadow-sm p-4 bg-light h-100 dashboard-card">
<i class="fa fa-user fa-3x text-primary mb-3"></i>
<h2>
@Model.ArtisteLePlusChronique
</h2>
<h3>
@Model.ArtisteLePlusChronique
</h3>
<p>artiste le plus chroniqué</p>
<p>artiste le plus chroniqué</p>
</div>
</div>
</a>
</div>
@@ -52,19 +52,20 @@
<a asp-area=""
asp-controller="Artiste"
asp-route-nom="@Model.AlbumLePlusChronique">
<div class="ratio ratio-4x3">
<div class="card shadow-sm p-4 bg-light h-100 dashboard-card">
<i class="fa fa-trophy fa-3x text-primary mb-3"></i>
<div class="py-5 bg-light rounded-3 d-flex flex-column justify-content-center align-items-center text-primary">
<i class="fa fa-trophy fa-5x text-primary mb-3"></i>
<h3>
<h2>
@Model.AlbumLePlusChronique
</h3>
</h2>
<p>
artiste avec le plus d'albums distincts
</p>
</div>
</div>
</a>
</div>
@@ -72,19 +73,20 @@
<div class="col-md-4">
<a asp-area="Administration"
asp-controller="Titre">
<div class="ratio ratio-4x3">
<div class="card shadow-sm p-4 bg-light h-100 dashboard-card">
<i class="fa fa-book fa-3x text-primary mb-3"></i>
<div class="py-5 bg-light rounded-3 d-flex flex-column justify-content-center align-items-center text-primary">
<i class="fa fa-book fa-5x text-primary mb-3"></i>
<h3>
<h2>
@Model.NombreBiographies
</h3>
</h2>
<p>
biographies d'artistes
</p>
</div>
</div>
</a>
</div>
@@ -94,19 +96,20 @@
asp-controller="Titre"
asp-action="Details"
asp-route-id="@Model.IdMusiqueLaPlusJouee">
<div class="ratio ratio-4x3">
<div class="card shadow-sm p-4 bg-light h-100 dashboard-card">
<i class="fa fa-compact-disc fa-3x text-primary mb-3"></i>
<div class="py-5 bg-light rounded-3 d-flex flex-column justify-content-center align-items-center text-primary">
<i class="fa fa-compact-disc fa-5x text-primary mb-3"></i>
<h4>
<h2>
@Model.MusiqueLaPlusJouee
</h4>
</h2>
<p>
titre le plus lu
</p>
</div>
</div>
</a>
</div>
@@ -114,19 +117,20 @@
<div class="col-md-4">
<a asp-area="Administration"
asp-controller="Titre">
<div class="ratio ratio-4x3">
<div class="card shadow-sm p-4 bg-light h-100 dashboard-card">
<i class="fa fa-music fa-3x text-primary mb-3"></i>
<div class="py-5 bg-light rounded-3 d-flex flex-column justify-content-center align-items-center text-primary">
<i class="fa fa-music fa-5x text-primary mb-3"></i>
<h3>
<h2>
@Model.NombreTitres
</h3>
</h2>
<p>
titres
</p>
</div>
</div>
</a>
</div>
@@ -134,50 +138,57 @@
<div class="col-md-4">
<a asp-area="Administration"
asp-controller="Styles">
<div class="ratio ratio-4x3">
<div class="card shadow-sm p-4 bg-light h-100 dashboard-card">
<i class="fa fa-tags fa-3x text-primary mb-3"></i>
<div class="py-5 bg-light rounded-3 d-flex flex-column justify-content-center align-items-center text-primary">
<i class="fa fa-tags fa-5x text-primary mb-3"></i>
<h3>
<h2>
@Model.NombreGenres
</h3>
</h2>
<p>
styles de musique
</p>
</div>
</div>
</a>
</div>
<!-- NOMBRE DE LECTURES -->
<div class="col-md-4">
<div class="card shadow-sm p-4 bg-light h-100">
<i class="fa fa-eye fa-3x text-dark mb-3"></i>
<div class="ratio ratio-4x3">
<h3>
@Model.NombreLectures
</h3>
<div class="py-5 bg-light rounded-3 d-flex flex-column justify-content-center align-items-center">
<i class="fa fa-eye fa-5x text-dark mb-3"></i>
<p>
lectures
</p>
<h2>
@Model.NombreLectures
</h2>
<p>
lectures
</p>
</div>
</div>
</div>
<!-- TOTAL LIKES -->
<div class="col-md-4">
<div class="card shadow-sm p-4 bg-light h-100">
<i class="fa fa-thumbs-up fa-3x text-dark mb-3"></i>
<div class="ratio ratio-4x3">
<h3>
<div class="py-5 bg-light rounded-3 d-flex flex-column justify-content-center align-items-center">
<i class="fa fa-thumbs-up fa-5x text-dark mb-3"></i>
<h2>
@Model.NombreLikes
</h3>
</h2>
<p>
likes
</p>
</div>
</div>
</div>
</div>

View File

@@ -22,7 +22,7 @@
@* Input *@
<div class="me-3">
<input asp-for="Libelle" class="form-control" style="width: 250px;" />
<input asp-for="Libelle" class="form-control" />
</div>
@* Bouton *@

View File

@@ -25,7 +25,7 @@
@* Input *@
<div class="me-3">
<input asp-for="Libelle" class="form-control" style="width: 250px;" />
<input asp-for="Libelle" class="form-control" />
</div>
@* Bouton *@

View File

@@ -20,7 +20,7 @@
<thead class="table-active">
<tr>
<th scope="col" class="p-2">Libellé</th>
<th scope="col" class="text-center p-2" style="width: 100px;">Actions</th>
<th scope="col" class="text-center p-2">Actions</th>
</tr>
</thead>
<tbody>
@@ -28,11 +28,11 @@
{
@foreach (Webzine.Entity.Style style in Model)
{
<tr class="align-middle">
<td class="p-2">
<tr >
<td class="p-2 w-75">
@style.Libelle
</td>
<td class="text-center p-2">
<td class="text-center w-auto p-2">
<a asp-action="Edit" asp-route-id="@style.IdStyle" class="text-primary me-2" title="Éditer">
<i class="fas fa-edit"></i>
</a>

View File

@@ -62,7 +62,7 @@
<!-- JAQUETTE -->
<div class="row mb-3 align-items-center">
<label class="col-md-3 col-form-label">Jaquette<span class="text-danger">*</span></label>
<label class="col-md-3 col-form-label">Jaquette de l'album<span class="text-danger">*</span></label>
<div class="col-md-9">
<input asp-for="UrlJaquette"
class="form-control"/>
@@ -102,13 +102,13 @@
</div>
<!-- LECTURES / LIKES (AFFICHAGE UNIQUEMENT) -->
<div class="row mb-4 align-items-center">
<div class="row align-items-center">
<label class="col-md-3 col-form-label">Nb de lectures<span class="text-danger">*</span></label>
<div class="col-md-3">
@Model.NbLectures
</div>
</div>
<div class="row mb-4 align-items-center">
<div class="row align-items-center">
<label class="col-md-3 col-form-label">Nb de likes<span class="text-danger">*</span></label>
<div class="col-md-3">
@Model.NbLikes

View File

@@ -28,7 +28,7 @@ public class ApiController : ControllerBase
return Ok(new
{
nom = "webzine",
version = "1.0",
version = "2.0",
});
}
}

View File

@@ -38,7 +38,7 @@
<!-- Chronique -->
<p class="mt-2 mb-3 text-muted">
@titre.Chronique
@(titre.Chronique.Length > 200 ? titre.Chronique.Substring(0, 200) + "..." : titre.Chronique)
</p>
<!-- Footer -->

View File

@@ -58,7 +58,7 @@ else
<a asp-controller="Titre"
asp-action="Details"
asp-route-id="@titre.IdTitre"
class="text-primary fw-bold">
class="text-primary">
@titre.Libelle
</a>
</td>

View File

@@ -4,14 +4,15 @@
<div class="container">
<h1>Contact</h1>
<div>
<div class="my-2">
C.U.C.D.B - DIIAGE <br />
69 Avenue Aristide Briand<br />
21000 Dijon
</div>
<div>
<div class ="my-2">
<i class="fa-solid fa-phone"></i> Phone : 03 80 40 50 60<br />
<i class="fa-solid fa-envelope"></i> secretariat@cucdb.fr
<i class="fa-solid fa-envelope"></i> <span class="text-primary">secretariat@cucdb.fr</span>
</div>
</div>
@@ -21,43 +22,43 @@
<h2>Suivez-nous</h2>
<div class="row g-4 text-center">
<div class="col-md-4">
<a href="#" class="card h-100 p-4 shadow-sm border-0 bg-light-subtle">
<i class="fa-solid fa-link fa-3x text-primary mb-3"></i>
<a href="#" class="card h-100 p-4 border-0 bg-light">
<i class="fa-solid fa-link fa-3x text-primary mb-3 align-self-center"></i>
<div class="fw-bold text-primary">Site officiel du DIIAGE</div>
</a>
</div>
<div class="col-md-4">
<a href="#" class="card h-100 p-4 shadow-sm border-0 bg-light-subtle">
<i class="fa-brands fa-facebook fa-3x text-primary mb-3"></i>
<a href="#" class="card h-100 p-4 border-0 bg-light">
<i class="fa-brands fa-facebook fa-3x text-primary mb-3 align-self-center"></i>
<div class="fw-bold text-primary">Facebook</div>
</a>
</div>
<div class="col-md-4">
<a href="#" class="card h-100 p-4 shadow-sm border-0 bg-light-subtle">
<i class="fa-brands fa-instagram fa-3x text-primary mb-3"></i>
<a href="#" class="card h-100 p-4 border-0 bg-light">
<i class="fa-brands fa-instagram fa-3x text-primary mb-3 align-self-center"></i>
<div class="fw-bold text-primary">Instagram</div>
</a>
</div>
<div class="col-md-4">
<a href="#" class="card h-100 p-4 shadow-sm border-0 bg-light-subtle">
<i class="fa-brands fa-linkedin fa-3x text-primary mb-3"></i>
<a href="#" class="card h-100 p-4 border-0 bg-light">
<i class="fa-brands fa-linkedin fa-3x text-primary mb-3 align-self-center"></i>
<div class="fw-bold text-primary">LinkedIn</div>
</a>
</div>
<div class="col-md-4">
<a href="#" class="card h-100 p-4 shadow-sm border-0 bg-light-subtle">
<i class="fa-solid fa-map fa-3x text-primary mb-3"></i>
<a href="#" class="card h-100 p-4 border-0 bg-light">
<i class="fa-solid fa-map fa-3x text-primary mb-3 align-self-center"></i>
<div class="fw-bold text-primary">Google Maps</div>
</a>
</div>
<div class="col-md-4">
<a href="#" class="card h-100 p-4 shadow-sm border-0 bg-light-subtle">
<i class="fa-brands fa-twitter fa-3x text-primary mb-3"></i>
<a href="#" class="card h-100 p-4 border-0 bg-light">
<i class="fa-brands fa-twitter fa-3x text-primary mb-3 align-self-center"></i>
<div class="fw-bold text-primary">Twitter</div>
</a>
</div>

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

227
scripts/test-endpoints.sh Normal file
View File

@@ -0,0 +1,227 @@
#!/usr/bin/env bash
# =============================================================================
# test-endpoints.sh
# Teste tous les endpoints du Webzine et signale ceux qui dépassent le seuil.
#
# Usage :
# ./scripts/test-endpoints.sh [URL_BASE] [MAX_MS]
#
# Exemples :
# ./scripts/test-endpoints.sh # défauts : localhost:5038, 1000ms
# ./scripts/test-endpoints.sh http://localhost:5038 500
# =============================================================================
set -euo pipefail
BASE_URL="${1:-http://localhost:5038}"
MAX_MS="${2:-1000}"
RAPPORT_FICHIER="/tmp/webzine_rapport_endpoints.txt"
ECHECS=0
TOTAL=0
# ── Couleurs ──────────────────────────────────────────────────────────────────
ROUGE='\033[0;31m'
JAUNE='\033[1;33m'
VERT='\033[0;32m'
CYAN='\033[0;36m'
GRAS='\033[1m'
RESET='\033[0m'
# ── Fonctions utilitaires ──────────────────────────────────────────────────────
log() { echo -e "$*"; }
succes() { log "${VERT}[OK]${RESET} $*"; }
echec() { log "${ROUGE}[ÉCHEC]${RESET} $*"; ECHECS=$((ECHECS + 1)); }
lent() { log "${JAUNE}[LENT]${RESET} $*"; ECHECS=$((ECHECS + 1)); }
info() { log "${CYAN}$*${RESET}"; }
# ── verifier_endpoint ─────────────────────────────────────────────────────────
# Arguments :
# $1 Méthode HTTP (GET | POST)
# $2 URL (absolue)
# $3 Libellé (texte lisible)
# $4 Corps (optionnel, pour POST)
# $5 Content-Type (optionnel, défaut : application/x-www-form-urlencoded)
# ─────────────────────────────────────────────────────────────────────────────
verifier_endpoint() {
local METHODE="${1:-GET}"
local URL="$2"
local LIBELLE="$3"
local CORPS="${4:-}"
local TYPE_CONTENU="${5:-application/x-www-form-urlencoded}"
TOTAL=$((TOTAL + 1))
# Exécution de la requête selon la méthode HTTP
if [ "$METHODE" = "POST" ] && [ -n "$CORPS" ]; then
REPONSE=$(curl -s -o /dev/null \
-w "%{http_code}|%{time_total}" \
-X POST \
-H "Content-Type: $TYPE_CONTENU" \
-d "$CORPS" \
--max-time 10 \
"$URL" 2>&1) || REPONSE="000|9.999"
else
REPONSE=$(curl -s -o /dev/null \
-w "%{http_code}|%{time_total}" \
-X GET \
--max-time 10 \
--location \
"$URL" 2>&1) || REPONSE="000|9.999"
fi
# Extraction du code HTTP et du temps de réponse
CODE_HTTP=$(echo "$REPONSE" | cut -d'|' -f1)
TEMPS_TOTAL=$(echo "$REPONSE" | cut -d'|' -f2)
# Conversion en millisecondes entières — awk évite les problèmes de locale décimale
TEMPS_MS=$(awk "BEGIN {printf \"%.0f\", $TEMPS_TOTAL * 1000}")
# Évaluation du résultat : erreur serveur, dépassement de seuil ou succès
if [ "${CODE_HTTP:-0}" -ge 500 ] 2>/dev/null; then
echec "$LIBELLE → HTTP $CODE_HTTP (${TEMPS_MS}ms)"
echo "[ÉCHEC] $LIBELLE → HTTP $CODE_HTTP (${TEMPS_MS}ms)" >> "$RAPPORT_FICHIER"
elif [ "${TEMPS_MS:-99999}" -gt "$MAX_MS" ] 2>/dev/null; then
lent "$LIBELLE${TEMPS_MS}ms dépasse le seuil de ${MAX_MS}ms"
echo "[LENT] $LIBELLE${TEMPS_MS}ms (limite : ${MAX_MS}ms)" >> "$RAPPORT_FICHIER"
else
succes "$LIBELLE${TEMPS_MS}ms"
echo "[OK] $LIBELLE${TEMPS_MS}ms" >> "$RAPPORT_FICHIER"
fi
}
# =============================================================================
# PROGRAMME PRINCIPAL
# =============================================================================
# Initialisation du fichier de rapport
> "$RAPPORT_FICHIER"
cat >> "$RAPPORT_FICHIER" <<EOF
=== Rapport de performance des endpoints Webzine ===
URL de base : $BASE_URL
Seuil : ${MAX_MS}ms
Date : $(date -u +"%Y-%m-%dT%H:%M:%SZ")
EOF
log ""
info "╔══════════════════════════════════════════════════════════╗"
info "║ Webzine Test de performance des endpoints ║"
info "╚══════════════════════════════════════════════════════════╝"
info " URL de base : $BASE_URL"
info " Seuil : ${MAX_MS}ms"
log ""
# ── SECTION PUBLIQUE ──────────────────────────────────────────────────────────
info "── Endpoints publics ─────────────────────────────────────"
verifier_endpoint GET "$BASE_URL/" "GET / (Accueil)"
verifier_endpoint GET "$BASE_URL/Accueil" "GET /Accueil"
verifier_endpoint GET "$BASE_URL/Contact" "GET /Contact"
log ""
info "── Titre Détails ───────────────────────────────────────"
# Test des pages de détail pour les 5 premiers titres
for ID in 1 2 3 4 5; do
verifier_endpoint GET "$BASE_URL/titre/$ID" "GET /titre/$ID"
done
log ""
info "── Titre Par style ─────────────────────────────────────"
# Test du filtrage par style musical
STYLES=("Rock" "Pop" "Rap" "Jazz" "Metal" "Electronic" "Hip-Hop" "Soul" "Funk")
for STYLE in "${STYLES[@]}"; do
ENCODE=$(python3 -c "import urllib.parse; print(urllib.parse.quote('$STYLE'))" 2>/dev/null || echo "$STYLE")
verifier_endpoint GET "$BASE_URL/titre/style/$ENCODE" "GET /titre/style/$STYLE"
done
log ""
info "── Artiste ───────────────────────────────────────────────"
# Test des pages artiste avec des noms en kebab-case
ARTISTES=("fatal-bazooka" "daft-punk" "justice" "kraftwerk")
for ARTISTE in "${ARTISTES[@]}"; do
verifier_endpoint GET "$BASE_URL/artiste/$ARTISTE" "GET /artiste/$ARTISTE"
done
log ""
info "── Recherche (POST) ──────────────────────────────────────"
# Test de la recherche plein texte par mots-clés
MOTS=("rock" "jazz" "pop" "metal")
for MOT in "${MOTS[@]}"; do
verifier_endpoint POST "$BASE_URL/recherche" \
"POST /recherche (mot=$MOT)" \
"mot=$MOT"
done
log ""
# ── SECTION ADMINISTRATION ────────────────────────────────────────────────────
info "── Administration Tableau de bord ──────────────────────"
verifier_endpoint GET "$BASE_URL/Administration/Dashboard" "GET /Administration/Dashboard"
log ""
info "── Administration Artiste ──────────────────────────────"
verifier_endpoint GET "$BASE_URL/Administration/Artiste" "GET /Administration/Artiste (liste)"
verifier_endpoint GET "$BASE_URL/Administration/Artiste/Create" "GET /Administration/Artiste/Create"
verifier_endpoint GET "$BASE_URL/Administration/Artiste/Edit/1" "GET /Administration/Artiste/Edit/1"
verifier_endpoint GET "$BASE_URL/Administration/Artiste/Delete/1" "GET /Administration/Artiste/Delete/1"
log ""
info "── Administration Commentaire ──────────────────────────"
verifier_endpoint GET "$BASE_URL/Administration/Commentaire" "GET /Administration/Commentaire (liste)"
verifier_endpoint GET "$BASE_URL/Administration/Commentaire/Delete/1" "GET /Administration/Commentaire/Delete/1"
log ""
info "── Administration Style ────────────────────────────────"
verifier_endpoint GET "$BASE_URL/Administration/Style" "GET /Administration/Style (liste)"
verifier_endpoint GET "$BASE_URL/Administration/Style/Create" "GET /Administration/Style/Create"
verifier_endpoint GET "$BASE_URL/Administration/Style/Edit/1" "GET /Administration/Style/Edit/1"
verifier_endpoint GET "$BASE_URL/Administration/Style/Delete/1" "GET /Administration/Style/Delete/1"
log ""
info "── Administration Titre ────────────────────────────────"
verifier_endpoint GET "$BASE_URL/Administration/Titre" "GET /Administration/Titre (liste)"
verifier_endpoint GET "$BASE_URL/Administration/Titre/Create" "GET /Administration/Titre/Create"
verifier_endpoint GET "$BASE_URL/Administration/Titre/Edit/1" "GET /Administration/Titre/Edit/1"
verifier_endpoint GET "$BASE_URL/Administration/Titre/Delete/1" "GET /Administration/Titre/Delete/1"
# ── RÉCAPITULATIF ─────────────────────────────────────────────────────────────
REUSSIS=$((TOTAL - ECHECS))
log ""
info "╔══════════════════════════════════════════════════════════╗"
info "║ Résultats ║"
info "╚══════════════════════════════════════════════════════════╝"
log " Total : ${TOTAL}"
log " ${VERT}Réussis${RESET} : ${REUSSIS}"
if [ "$ECHECS" -gt 0 ]; then
log " ${ROUGE}Échecs${RESET} : ${ECHECS}"
log ""
log "${ROUGE}${GRAS}❌ ENDPOINTS EN ÉCHEC :${RESET}"
# Affichage de tous les endpoints ayant échoué ou dépassé le seuil
grep -E "^\[(ÉCHEC|LENT)\]" "$RAPPORT_FICHIER" | while IFS= read -r ligne; do
log " ${ROUGE}${RESET} $ligne"
done
log ""
log "${ROUGE}La PR doit être rejetée. Corrigez les endpoints ci-dessus.${RESET}"
else
log " ${VERT}Échecs${RESET} : 0"
log ""
log "${VERT}${GRAS}✅ Tous les endpoints respectent le seuil de ${MAX_MS}ms.${RESET}"
fi
log ""
log "Rapport complet enregistré dans : ${RAPPORT_FICHIER}"
log ""
# Écriture du récapitulatif dans le rapport
cat >> "$RAPPORT_FICHIER" <<EOF
=== Récapitulatif ===
Total : $TOTAL
Réussis : $REUSSIS
Échecs : $ECHECS
EOF
# Code de sortie non nul si des échecs ont été détectés — permet à la CI de bloquer
exit "$ECHECS"