feat: améliorer le rapport de performance des endpoints en utilisant un fichier de rapport généré

This commit is contained in:
mirage
2026-03-27 10:17:35 +01:00
parent 838da780a6
commit ae880af550

View File

@@ -52,12 +52,10 @@ jobs:
bash scripts/test-endpoints.sh http://localhost:5038 1000 2>&1 | tee /tmp/webzine_endpoint_output.txt bash scripts/test-endpoints.sh http://localhost:5038 1000 2>&1 | tee /tmp/webzine_endpoint_output.txt
EXIT_CODE=${PIPESTATUS[0]} EXIT_CODE=${PIPESTATUS[0]}
FAIL_COUNT=$(grep -c "^\[FAIL\]\|^\[SLOW\]" /tmp/webzine_endpoint_output.txt || echo 0) FAIL_COUNT=$(grep -c "\[ÉCHEC\]\|\[LENT\]" /tmp/webzine_endpoint_output.txt || echo 0)
echo "failed=$FAIL_COUNT" >> "$GITHUB_OUTPUT" echo "failed=$FAIL_COUNT" >> "$GITHUB_OUTPUT"
echo "exit_code=$EXIT_CODE" >> "$GITHUB_OUTPUT" echo "exit_code=$EXIT_CODE" >> "$GITHUB_OUTPUT"
cat /tmp/webzine_endpoint_output.txt > /tmp/webzine_endpoint_report.txt
exit $EXIT_CODE exit $EXIT_CODE
- name: Post performance report as PR comment - name: Post performance report as PR comment
@@ -68,9 +66,10 @@ jobs:
REPO: ${{ gitea.repository }} REPO: ${{ gitea.repository }}
PR_NUMBER: ${{ gitea.event.pull_request.number }} PR_NUMBER: ${{ gitea.event.pull_request.number }}
run: | run: |
REPORT_CONTENT=$(cat /tmp/webzine_endpoint_report.txt 2>/dev/null || echo "Aucun rapport généré.") REPORT_CONTENT=$(cat /tmp/webzine_endpoint_output.txt)
FAILED_COUNT="${{ steps.perf_test.outputs.failed }}" FAILED_COUNT="${{ steps.perf_test.outputs.failed }}"
# Échapper le contenu pour JSON
REPORT_CONTENT_ESCAPED=$(echo "$REPORT_CONTENT" | sed 's/`/\\`/g' | sed 's/\\/\\\\/g') REPORT_CONTENT_ESCAPED=$(echo "$REPORT_CONTENT" | sed 's/`/\\`/g' | sed 's/\\/\\\\/g')
if [ "${FAILED_COUNT:-0}" -gt 0 ]; then if [ "${FAILED_COUNT:-0}" -gt 0 ]; then
@@ -108,7 +107,7 @@ jobs:
"$GITEA_SERVER_URL/api/v1/repos/$REPO/issues/$PR_NUMBER/comments" "$GITEA_SERVER_URL/api/v1/repos/$REPO/issues/$PR_NUMBER/comments"
mkdir -p /tmp/artifacts mkdir -p /tmp/artifacts
cp /tmp/webzine_endpoint_report.txt /tmp/artifacts/performance-report.txt cp /tmp/webzine_endpoint_output.txt /tmp/artifacts/performance-report.txt
- name: Upload performance report - name: Upload performance report
if: always() if: always()
@@ -127,7 +126,11 @@ jobs:
echo " Corrigez les endpoints lents ou en erreur avant de fusionner." echo " Corrigez les endpoints lents ou en erreur avant de fusionner."
echo "" echo ""
echo "Résumé des problèmes :" echo "Résumé des problèmes :"
grep -E "^\[(FAIL|SLOW)\]" /tmp/webzine_endpoint_report.txt || echo " (aucun détail disponible)" if [ -f /tmp/webzine_endpoint_output.txt ]; then
grep -E "\[ÉCHEC\]|\[LENT\]" /tmp/webzine_endpoint_output.txt || echo " (aucun détail disponible)"
else
echo " (fichier de rapport non disponible)"
fi
exit 1 exit 1
else else
echo "✅ Tous les endpoints ont passé le contrôle de performance." echo "✅ Tous les endpoints ont passé le contrôle de performance."