From 5f3b91a07e7b38c0037e81bbc67991a27cda199c Mon Sep 17 00:00:00 2001 From: Ruchi Sharma Date: Tue, 4 Feb 2025 01:05:19 +0000 Subject: [PATCH] add faile dmetrics Signed-off-by: Ruchi Sharma --- .github/workflows/backport.yml | 4 +-- .github/workflows/performance_testing.yml | 30 ++++++++++++++++++++--- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/.github/workflows/backport.yml b/.github/workflows/backport.yml index c8dfef417daa..ea4f856c041b 100644 --- a/.github/workflows/backport.yml +++ b/.github/workflows/backport.yml @@ -38,6 +38,6 @@ jobs: with: github_token: ${{ steps.github_app_token.outputs.token }} head_template: backport/backport-<%= number %>-to-<%= base %> - files_to_skip: "CHANGELOG.md" + files_to_skip: 'CHANGELOG.md' labels_template: "<%= JSON.stringify([...labels, 'autocut']) %>" - failure_labels: "failed backport" + failure_labels: 'failed backport' diff --git a/.github/workflows/performance_testing.yml b/.github/workflows/performance_testing.yml index 269e5c906a20..26dbbc45993a 100644 --- a/.github/workflows/performance_testing.yml +++ b/.github/workflows/performance_testing.yml @@ -90,9 +90,33 @@ jobs: run: | echo "🚦 **Lighthouse CI Report**" > comment.txt echo "" >> comment.txt + + # Run Lighthouse and capture failures + yarn lhci autorun --json > lhci_output.json || true + + # Extract failed assertions + FAILURES=$(jq -r '[.assertionResults[] | select(.status=="fail") | + {metric: .auditId, reason: .explanation}]' lhci_output.json) + + if [[ "$FAILURES" == "[]" ]]; then + echo "✅ All Lighthouse metrics passed!" >> comment.txt + else + echo "❌ **Failed Lighthouse Metrics:**" >> comment.txt + echo '```json' >> comment.txt + echo "$FAILURES" >> comment.txt + echo '```' >> comment.txt + fi + + # Ensure correct extraction of the report URL yarn lhci upload --target=temporary-public-storage | tee lhci_output.txt - REPORT_URL=$(grep -o 'https://storage.googleapis.com/lighthouse-infrastructure-.*' lhci_output.txt | head -n 1) - echo "🔗 [View Full Lighthouse Report]($REPORT_URL)" >> comment.txt + REPORT_URL=$(grep -Eo 'https://storage.googleapis.com/lighthouse-infrastructure-[^\s]+' lhci_output.txt | head -n 1) + + if [[ -n "$REPORT_URL" ]]; then + echo "🔗 [View Full Lighthouse Report]($REPORT_URL)" >> comment.txt + else + echo "⚠️ Lighthouse report link not found. Check workflow logs." >> comment.txt + fi + gh pr comment ${{ github.event.pull_request.number }} --body "$(cat comment.txt)" env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + LHCI_GITHUB_APP_TOKEN: ${{ secrets.LHCI_GITHUB_APP_TOKEN }}