Skip to content

A platform for community discussion. Free, open, simple.

DEV: Notify Patch Triage about flaky test reports (#43250)

Alan Guo Xiang Tancc0d830a1845
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index ff0077122e3..2a5b777f073 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -385,6 +385,7 @@ jobs:
fi
- name: Merge failed system test artifacts
+ id: merge-failed-system-test-artifacts
if: steps.check-artifacts.outputs.has_failed_system == 'true'
uses: actions/upload-artifact/merge@v7
with:
@@ -393,9 +394,20 @@ jobs:
delete-merged: true
- name: Merge flaky test reports
+ id: merge-flaky-test-reports
if: steps.check-artifacts.outputs.has_flaky == 'true'
uses: actions/upload-artifact/merge@v7
with:
name: flaky-test-reports
pattern: flaky-test-reports-*
delete-merged: true
+
+ - name: Notify Patch Triage about flaky tests
+ if: steps.merge-flaky-test-reports.outputs.artifact-id != ''
+ continue-on-error: true
+ env:
+ PATCH_TRIAGE_FLAKY_TEST_REPORT_URL: ${{ secrets.PATCH_TRIAGE_FLAKY_TEST_REPORT_URL }}
+ PATCH_TRIAGE_FLAKY_TEST_REPORT_SECRET: ${{ secrets.PATCH_TRIAGE_FLAKY_TEST_REPORT_SECRET }}
+ REPORT_ARTIFACT_ID: ${{ steps.merge-flaky-test-reports.outputs.artifact-id }}
+ SCREENSHOT_ARTIFACT_ID: ${{ steps.merge-failed-system-test-artifacts.outputs.artifact-id }}
+ run: script/notify_patch_triage_of_flaky_tests
diff --git a/script/notify_patch_triage_of_flaky_tests b/script/notify_patch_triage_of_flaky_tests
new file mode 100755
index 00000000000..7ce19ce671f
--- /dev/null
+++ b/script/notify_patch_triage_of_flaky_tests
@@ -0,0 +1,33 @@
+#!/usr/bin/env bash
+
+set -euo pipefail
+
+if [[ -z "${PATCH_TRIAGE_FLAKY_TEST_REPORT_URL:-}" || -z "${PATCH_TRIAGE_FLAKY_TEST_REPORT_SECRET:-}" ]]; then
+ echo "::warning::Patch Triage flaky-test delivery secrets are not configured; skipping notification"
+ exit 0
+fi
+
+payload=$(jq -nc \
+ --arg repository "$GITHUB_REPOSITORY" \
+ --argjson workflow_run_id "$GITHUB_RUN_ID" \
+ --argjson run_attempt "$GITHUB_RUN_ATTEMPT" \
+ --argjson report_artifact_id "$REPORT_ARTIFACT_ID" \
+ --arg screenshot_artifact_id "${SCREENSHOT_ARTIFACT_ID:-}" \
+ '{
+ repository: $repository,
+ workflow_run_id: $workflow_run_id,
+ run_attempt: $run_attempt,
+ report_artifact_id: $report_artifact_id
+ } + if $screenshot_artifact_id == "" then {} else {
+ screenshot_artifact_id: ($screenshot_artifact_id | tonumber)
+ } end')
+
+curl --fail-with-body \
+ --retry 3 \
+ --retry-all-errors \
+ --connect-timeout 5 \
+ --max-time 30 \
+ --header "Content-Type: application/json" \
+ --header "Authorization: Bearer $PATCH_TRIAGE_FLAKY_TEST_REPORT_SECRET" \
+ --data-binary "$payload" \
+ "$PATCH_TRIAGE_FLAKY_TEST_REPORT_URL"