Skip to content

Flaky Monitor

Flaky Monitor #2389

Workflow file for this run

name: Flaky Monitor
# Triggered when the main `Tests` workflow completes. Pulls the JUnit XML
# artifacts uploaded by that workflow, publishes a unified test report, and
# surfaces tests that were flaky (failed initially but passed on retry).
on:
workflow_run:
workflows: [Tests]
types:
- completed
permissions:
actions: read
contents: read
pull-requests: write
checks: write
issues: write
jobs:
flaky-monitor:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event.workflow_run.conclusion == 'failure' }}
steps:
- name: 📥 Download JUnit Results
uses: actions/download-artifact@v4
with:
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ secrets.GITHUB_TOKEN }}
pattern: junit-*
path: junit-results
merge-multiple: true
- name: 🔎 List Downloaded Files
run: |
echo "Downloaded JUnit artifacts:"
find junit-results -type f -name '*.xml' -print || true
- name: 📊 Publish Unit Test Results
id: publish
uses: EnricoMi/publish-unit-test-result-action@v2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
junit_files: "junit-results/**/*.xml"
# Treat tests that failed first but passed on retry as flaky.
report_individual_runs: true
deduplicate_classes_by_file_name: false
# Don't fail this workflow when downstream tests had failures;
# we want the report regardless of the Tests workflow outcome.
fail_on: "nothing"
# Use the head commit of the workflow_run for the check.
commit: ${{ github.event.workflow_run.head_sha }}
check_name: "Flaky Test Report"
comment_mode: off
- name: 📝 Summarize Flaky Tests
if: always()
env:
RUNS_FLAKY: ${{ steps.publish.outputs.runs_flaky }}
TESTS_FLAKY: ${{ steps.publish.outputs.tests_flaky }}
JSON: ${{ steps.publish.outputs.json }}
run: |
{
echo "## Flaky Test Summary"
echo ""
echo "- Flaky tests: ${TESTS_FLAKY:-0}"
echo "- Flaky runs: ${RUNS_FLAKY:-0}"
echo "- Source workflow run: [${{ github.event.workflow_run.id }}](${{ github.event.workflow_run.html_url }})"
echo ""
if [ -n "${JSON}" ]; then
echo "<details><summary>Raw JSON output</summary>"
echo ""
echo '```json'
echo "${JSON}"
echo '```'
echo ""
echo "</details>"
fi
} >> "$GITHUB_STEP_SUMMARY"