Skip to content

Commit 711c455

Browse files
authored
Merge branch 'open-telemetry:main' into dev/sapatr/codesimplification1
2 parents 8f673f9 + 446e251 commit 711c455

47 files changed

Lines changed: 6106 additions & 689 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
name: Flaky Test Tracker
2+
3+
# Runs daily and on-demand to detect flaky tests from recent CI runs.
4+
# Parses JUnit XML artifacts from Rust-CI workflow runs, identifies tests
5+
# marked as flaky (failed then passed on retry), and creates/updates a
6+
# tracking issue with a summary table.
7+
8+
permissions:
9+
contents: read
10+
issues: write
11+
actions: read
12+
13+
on:
14+
schedule:
15+
# Run daily at 06:00 UTC
16+
- cron: "0 6 * * *"
17+
workflow_dispatch:
18+
19+
env:
20+
# The label applied to the flaky test tracking issue.
21+
FLAKY_ISSUE_LABEL: "flaky-test"
22+
# How many recent Rust-CI workflow runs to scan.
23+
LOOKBACK_RUNS: 20
24+
25+
jobs:
26+
detect-flaky-tests:
27+
runs-on: ubuntu-latest
28+
steps:
29+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
30+
31+
- name: Ensure flaky-test label exists
32+
env:
33+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34+
run: |
35+
gh label create "$FLAKY_ISSUE_LABEL" \
36+
--description "Automatically detected flaky tests" \
37+
--color "FBCA04" \
38+
--force
39+
40+
- name: Download JUnit XML from recent Rust-CI runs
41+
env:
42+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43+
run: |
44+
set -euo pipefail
45+
mkdir -p junit-artifacts
46+
47+
# Get the workflow ID for Rust-CI
48+
WORKFLOW_ID=$(gh api "repos/${{ github.repository }}/actions/workflows" \
49+
--jq '.workflows[] | select(.name == "Rust-CI") | .id')
50+
51+
if [[ -z "$WORKFLOW_ID" ]]; then
52+
echo "::warning::Could not find Rust-CI workflow"
53+
exit 0
54+
fi
55+
56+
echo "Rust-CI workflow ID: $WORKFLOW_ID"
57+
58+
# Get recent completed runs on the default branch
59+
RUN_IDS=$(gh api "repos/${{ github.repository }}/actions/workflows/$WORKFLOW_ID/runs?branch=main&status=completed&per_page=$LOOKBACK_RUNS" \
60+
--jq '.workflow_runs[].id')
61+
62+
echo "Found $(echo "$RUN_IDS" | wc -l) recent runs"
63+
64+
for RUN_ID in $RUN_IDS; do
65+
echo "Checking run $RUN_ID for JUnit artifacts..."
66+
# List artifacts for this run that match our naming pattern
67+
ARTIFACT_INFO=$(gh api "repos/${{ github.repository }}/actions/runs/$RUN_ID/artifacts" \
68+
--jq '.artifacts[] | select(.name | startswith("junit-xml-")) | "\(.id) \(.name)"' || true)
69+
70+
while IFS=' ' read -r ARTIFACT_ID ARTIFACT_NAME; do
71+
[[ -z "$ARTIFACT_ID" ]] && continue
72+
echo " Downloading artifact $ARTIFACT_NAME ($ARTIFACT_ID) from run $RUN_ID"
73+
DEST_DIR="junit-artifacts/run-$RUN_ID/$ARTIFACT_NAME"
74+
mkdir -p "$DEST_DIR"
75+
gh api "repos/${{ github.repository }}/actions/artifacts/$ARTIFACT_ID/zip" \
76+
> "$DEST_DIR/artifact.zip" || true
77+
(cd "$DEST_DIR" && unzip -o -q "artifact.zip" 2>/dev/null && rm -f "artifact.zip") || true
78+
done <<< "$ARTIFACT_INFO"
79+
done
80+
81+
echo "Downloaded artifacts:"
82+
find junit-artifacts -name '*.xml' | head -50 || echo "No XML files found"
83+
84+
- name: Parse JUnit XML and detect flaky tests
85+
id: parse
86+
env:
87+
GITHUB_REPO_URL: ${{ github.server_url }}/${{ github.repository }}
88+
FLAKY_ISSUE_LABEL: ${{ env.FLAKY_ISSUE_LABEL }}
89+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
90+
run: python3 .github/workflows/scripts/parse_flaky.py
91+
92+
- name: Create or update tracking issue
93+
env:
94+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
95+
run: |
96+
set -euo pipefail
97+
98+
BODY=$(cat flaky-report.md)
99+
TITLE="Flaky Test Report (automated)"
100+
101+
# Find existing open issue with the flaky-test label and our title
102+
EXISTING_ISSUE=$(gh issue list \
103+
--label "$FLAKY_ISSUE_LABEL" \
104+
--state open \
105+
--search "$TITLE" \
106+
--json number,title \
107+
--jq '.[] | select(.title == "'"$TITLE"'") | .number' \
108+
| head -1)
109+
110+
if [[ -n "$EXISTING_ISSUE" ]]; then
111+
echo "Updating existing issue #$EXISTING_ISSUE"
112+
gh issue edit "$EXISTING_ISSUE" --body "$BODY"
113+
else
114+
echo "Creating new tracking issue"
115+
gh issue create \
116+
--title "$TITLE" \
117+
--body "$BODY" \
118+
--label "$FLAKY_ISSUE_LABEL"
119+
fi
120+
121+
- name: Post summary
122+
if: always()
123+
run: |
124+
if [[ -f flaky-report.md ]]; then
125+
cat flaky-report.md >> "$GITHUB_STEP_SUMMARY"
126+
fi

.github/workflows/rust-ci.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,22 @@ jobs:
170170
- name: Run tests (partition ${{ matrix.partition }}/3)
171171
run: cargo nextest run --profile ci --config-file .config/nextest.toml --archive-file nextest-archive.tar.zst --partition count:${{ matrix.partition }}/3
172172
working-directory: ./rust/${{ matrix.folder }}
173+
- name: Write JUnit artifact metadata
174+
if: always()
175+
shell: bash
176+
run: |
177+
echo '{"job": "${{ github.job }}", "os": "${{ matrix.os }}", "partition": "${{ matrix.partition }}", "folder": "${{ matrix.folder }}"}' \
178+
> ./rust/${{ matrix.folder }}/target/nextest/ci/metadata.json
179+
- name: Upload JUnit XML results
180+
if: always()
181+
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
182+
with:
183+
name: junit-xml-nonrequired-${{ matrix.os }}-${{ matrix.partition }}
184+
path: |
185+
./rust/${{ matrix.folder }}/target/nextest/ci/junit.xml
186+
./rust/${{ matrix.folder }}/target/nextest/ci/metadata.json
187+
retention-days: 30
188+
if-no-files-found: ignore
173189

174190
fmt:
175191
strategy:
@@ -517,6 +533,22 @@ jobs:
517533
- name: Run tests (partition ${{ matrix.partition }}/3)
518534
run: cargo nextest run --profile ci --config-file .config/nextest.toml --archive-file nextest-archive.tar.zst --partition count:${{ matrix.partition }}/3
519535
working-directory: ./rust/${{ matrix.folder }}
536+
- name: Write JUnit artifact metadata
537+
if: always()
538+
shell: bash
539+
run: |
540+
echo '{"job": "${{ github.job }}", "os": "${{ matrix.os }}", "partition": "${{ matrix.partition }}", "folder": "${{ matrix.folder }}"}' \
541+
> ./rust/${{ matrix.folder }}/target/nextest/ci/metadata.json
542+
- name: Upload JUnit XML results
543+
if: always()
544+
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
545+
with:
546+
name: junit-xml-required-${{ matrix.os }}-${{ matrix.partition }}
547+
path: |
548+
./rust/${{ matrix.folder }}/target/nextest/ci/junit.xml
549+
./rust/${{ matrix.folder }}/target/nextest/ci/metadata.json
550+
retention-days: 30
551+
if-no-files-found: ignore
520552

521553
# Coverage runs unpartitioned on Linux x86_64 (does not block merge).
522554
# This compiles from scratch with coverage instrumentation and runs all tests.
@@ -701,6 +733,32 @@ jobs:
701733
echo "- Add the label \`cargobench\` to your PR to run micro benchmarks." >> $GITHUB_STEP_SUMMARY
702734
echo "- More info: [link to docs](https://github.com/open-telemetry/otel-arrow/blob/main/CONTRIBUTING.md#micro-benchmarks)" >> $GITHUB_STEP_SUMMARY
703735
736+
# Publish test results from JUnit XML artifacts.
737+
# Runs after all test jobs and posts a summary to the workflow run.
738+
test-report:
739+
runs-on: ubuntu-latest
740+
if: always()
741+
needs:
742+
- test_required
743+
- test_nonrequired
744+
permissions:
745+
checks: write
746+
steps:
747+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
748+
- name: Download all JUnit XML artifacts
749+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
750+
with:
751+
pattern: junit-xml-*
752+
path: junit-results
753+
- name: Publish test results
754+
uses: dorny/test-reporter@df6247429542221bc30d46a036ee47af1102c451 # v2.7.0
755+
if: always()
756+
with:
757+
name: Rust Test Results
758+
path: junit-results/**/*.xml
759+
reporter: java-junit
760+
fail-on-error: false
761+
704762
# Aggregated status check - depends only on the required matrix combinations.
705763
# Add/remove jobs from the needs list to change what is required via PR,
706764
# rather than updating GitHub branch protection settings directly.

0 commit comments

Comments
 (0)