feat: améliorer le workflow de test de performance en capturant le code de sortie et en formatant le rapport Markdown
This commit is contained in:
@@ -49,11 +49,14 @@ jobs:
|
|||||||
id: perf_test
|
id: perf_test
|
||||||
run: |
|
run: |
|
||||||
chmod +x scripts/test-endpoints.sh
|
chmod +x scripts/test-endpoints.sh
|
||||||
bash scripts/test-endpoints.sh http://localhost:5038 1000 2>&1 \
|
bash scripts/test-endpoints.sh http://localhost:5038 1000 2>&1 | tee /tmp/webzine_endpoint_output.txt
|
||||||
| tee /tmp/webzine_endpoint_output.txt || true
|
EXIT_CODE=${PIPESTATUS[0]}
|
||||||
|
|
||||||
FAIL_COUNT=$(grep -cE "^\[(LENT|ÉCHEC)\]" /tmp/webzine_rapport_endpoints.txt 2>/dev/null || echo 0)
|
FAIL_COUNT=$(grep -cE "^\[(LENT|ÉCHEC)\]" /tmp/webzine_endpoint_output.txt 2>/dev/null || echo 0)
|
||||||
echo "failed=$FAIL_COUNT" >> "$GITHUB_OUTPUT"
|
echo "failed=$FAIL_COUNT" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "exit_code=$EXIT_CODE" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
exit $EXIT_CODE
|
||||||
|
|
||||||
- name: Post performance report as PR comment
|
- name: Post performance report as PR comment
|
||||||
if: always()
|
if: always()
|
||||||
@@ -63,11 +66,15 @@ jobs:
|
|||||||
REPO: ${{ gitea.repository }}
|
REPO: ${{ gitea.repository }}
|
||||||
PR_NUMBER: ${{ gitea.event.pull_request.number }}
|
PR_NUMBER: ${{ gitea.event.pull_request.number }}
|
||||||
run: |
|
run: |
|
||||||
|
# Lire le rapport original
|
||||||
RAW_REPORT=$(cat /tmp/webzine_endpoint_output.txt 2>/dev/null || echo "Aucune sortie capturée.")
|
RAW_REPORT=$(cat /tmp/webzine_endpoint_output.txt 2>/dev/null || echo "Aucune sortie capturée.")
|
||||||
FAILED_COUNT="${{ steps.perf_test.outputs.failed }}"
|
FAILED_COUNT="${{ steps.perf_test.outputs.failed }}"
|
||||||
|
|
||||||
|
# Convertir le rapport ANSI en Markdown avec couleurs
|
||||||
|
# Supprimer d'abord les codes ANSI pour le traitement
|
||||||
CLEAN_REPORT=$(echo "$RAW_REPORT" | sed 's/\x1b\[[0-9;]*m//g')
|
CLEAN_REPORT=$(echo "$RAW_REPORT" | sed 's/\x1b\[[0-9;]*m//g')
|
||||||
|
|
||||||
|
# Générer le rapport formaté en Markdown avec couleurs
|
||||||
FORMATTED_REPORT=$(echo "$CLEAN_REPORT" | sed \
|
FORMATTED_REPORT=$(echo "$CLEAN_REPORT" | sed \
|
||||||
-e 's/^\[OK\] /✅ /' \
|
-e 's/^\[OK\] /✅ /' \
|
||||||
-e 's/^\[LENT\] /⚠️ /' \
|
-e 's/^\[LENT\] /⚠️ /' \
|
||||||
@@ -83,7 +90,7 @@ jobs:
|
|||||||
-e 's/^\(La PR doit.*\)$/\n**❌ \1**/' \
|
-e 's/^\(La PR doit.*\)$/\n**❌ \1**/' \
|
||||||
-e 's/^╔\(.*\)╗$/```\n╔\1╗/' \
|
-e 's/^╔\(.*\)╗$/```\n╔\1╗/' \
|
||||||
-e 's/^╚\(.*\)╝$/╚\1╝\n```/')
|
-e 's/^╚\(.*\)╝$/╚\1╝\n```/')
|
||||||
|
|
||||||
if [ "${FAILED_COUNT:-0}" -gt 0 ]; then
|
if [ "${FAILED_COUNT:-0}" -gt 0 ]; then
|
||||||
HEADER="## ❌ Vérification des performances ÉCHOUÉE"
|
HEADER="## ❌ Vérification des performances ÉCHOUÉE"
|
||||||
INTRO="${FAILED_COUNT} endpoint(s) ont dépassé 1 seconde ou retourné une erreur serveur."
|
INTRO="${FAILED_COUNT} endpoint(s) ont dépassé 1 seconde ou retourné une erreur serveur."
|
||||||
@@ -93,28 +100,28 @@ jobs:
|
|||||||
INTRO="Tous les endpoints ont répondu en moins d'une seconde."
|
INTRO="Tous les endpoints ont répondu en moins d'une seconde."
|
||||||
STATUS="✅ SUCCÈS"
|
STATUS="✅ SUCCÈS"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
BODY=$(cat <<EOF
|
|
||||||
$HEADER
|
|
||||||
|
|
||||||
$INTRO
|
|
||||||
|
|
||||||
### Rapport complet des tests :
|
|
||||||
|
|
||||||
$FORMATTED_REPORT
|
|
||||||
|
|
||||||
---
|
BODY=$(cat <<EOF
|
||||||
**Statut**: $STATUS
|
$HEADER
|
||||||
**Seuil**: 1000ms
|
|
||||||
**Vérifié par**: Workflow PR Endpoint Performance
|
$INTRO
|
||||||
EOF
|
|
||||||
|
### Rapport complet des tests :
|
||||||
|
|
||||||
|
$FORMATTED_REPORT
|
||||||
|
|
||||||
|
---
|
||||||
|
**Statut**: $STATUS
|
||||||
|
**Seuil**: 1000ms
|
||||||
|
**Vérifié par**: Workflow PR Endpoint Performance
|
||||||
|
EOF
|
||||||
)
|
)
|
||||||
|
|
||||||
curl -s -X POST \
|
curl -s -X POST \
|
||||||
-H "Authorization: token $GITEA_TOKEN" \
|
-H "Authorization: token $GITEA_TOKEN" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d "$(jq -n --arg body "$BODY" '{body: $body}')" \
|
-d "$(jq -n --arg body "$BODY" '{body: $body}')" \
|
||||||
"$GITEA_SERVER_URL/api/v1/repos/$REPO/issues/$PR_NUMBER/comments"
|
"$GITEA_SERVER_URL/api/v1/repos/$REPO/issues/$PR_NUMBER/comments"
|
||||||
|
|
||||||
- name: Enforce performance gate
|
- name: Enforce performance gate
|
||||||
if: always()
|
if: always()
|
||||||
|
|||||||
Reference in New Issue
Block a user