Skip to content

Commit 7060510

Browse files
committed
attempt retries
1 parent bb7f0a3 commit 7060510

File tree

1 file changed

+33
-9
lines changed

1 file changed

+33
-9
lines changed

.github/workflows/experiment.yaml

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Next-Gen CI Pipeline
33
on:
44
pull_request:
55
branches: [ main, preview ]
6-
# Native Merge Queue support for O(1) batching
6+
# Native Merge Queue support for exhaustive batching
77
merge_group:
88
types: [checks_requested]
99

@@ -20,6 +20,8 @@ jobs:
2020
runs-on: ubuntu-latest
2121
outputs:
2222
packages: ${{ steps.changes.outputs.all_changed_files }}
23+
# Expose the dynamic Python matrix to downstream jobs
24+
python_versions: ${{ steps.set-python.outputs.matrix }}
2325
steps:
2426
- uses: actions/checkout@v4
2527
with:
@@ -35,6 +37,17 @@ jobs:
3537
json: true
3638
escape_json: false
3739

40+
- name: Determine Python Matrix (Risk-Tiering)
41+
id: set-python
42+
run: |
43+
if [[ "${{ github.event_name }}" == "merge_group" ]]; then
44+
echo "Merge Queue detected. Deploying exhaustive matrix."
45+
echo 'matrix=["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]' >> $GITHUB_OUTPUT
46+
else
47+
echo "Pull Request detected. Deploying Min/Max Boundary matrix."
48+
echo 'matrix=["3.9", "3.14"]' >> $GITHUB_OUTPUT
49+
fi
50+
3851
# ==========================================
3952
# 2. STATIC ANALYSIS (Grouped for Speed)
4053
# ==========================================
@@ -58,7 +71,6 @@ jobs:
5871
run: |
5972
cd ${{ matrix.package }}
6073
export NOX_DEFAULT_VENV_BACKEND=uv
61-
# Chaining sessions executes them in a single fast VM
6274
uvx --with 'nox[uv]' nox -s lint mypy lint_setup_py
6375
6476
# ==========================================
@@ -87,7 +99,7 @@ jobs:
8799
uvx --with 'nox[uv]' nox -s docs docfx
88100
89101
# ==========================================
90-
# 4. UNIT TESTS (The 2D Multiplier Matrix)
102+
# 4. UNIT TESTS (Dynamic 2D Matrix + Retries)
91103
# ==========================================
92104
unit-tests:
93105
needs: discover
@@ -97,7 +109,8 @@ jobs:
97109
fail-fast: false
98110
matrix:
99111
package: ${{ fromJSON(needs.discover.outputs.packages) }}
100-
python: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
112+
# Reads the array generated by the Discovery job
113+
python: ${{ fromJSON(needs.discover.outputs.python_versions) }}
101114
steps:
102115
- uses: actions/checkout@v4
103116
- uses: astral-sh/setup-uv@v5
@@ -106,11 +119,24 @@ jobs:
106119
enable-cache: true
107120
cache-dependency-glob: "${{ matrix.package }}/setup.py"
108121

109-
- name: Execute Unit Tests
122+
- name: Execute Unit Tests (With Shock Absorbers)
110123
run: |
111124
cd ${{ matrix.package }}
112125
export NOX_DEFAULT_VENV_BACKEND=uv
113-
uvx --with 'nox[uv]' nox -s unit-${{ matrix.python }}
126+
127+
# 3-Attempt retry loop to mask legacy flaky tests
128+
for i in 1 2 3; do
129+
echo "Attempt $i of 3 for Python ${{ matrix.python }}..."
130+
if uvx --with 'nox[uv]' nox -s unit-${{ matrix.python }}; then
131+
echo "Tests passed successfully!"
132+
exit 0
133+
fi
134+
echo "Tests failed. Waiting 5 seconds before retrying..."
135+
sleep 5
136+
done
137+
138+
echo "::error::Tests failed after 3 attempts. This is a hard failure."
139+
exit 1
114140
115141
# ==========================================
116142
# 5. SYSTEM TESTS
@@ -144,7 +170,6 @@ jobs:
144170
# 6. THE GATEKEEPER (Status Check Rollup)
145171
# ==========================================
146172
presubmit-passed:
147-
# Always runs so GitHub can definitively mark the PR as passed/failed
148173
if: always()
149174
needs:
150175
- discover
@@ -161,10 +186,9 @@ jobs:
161186
exit 1
162187
fi
163188
164-
# If the router output was empty, it means no Python code changed.
165189
if [[ "${{ needs.discover.outputs.packages }}" == "[]" ]]; then
166190
echo "No Python packages changed. Safely bypassing execution."
167191
exit 0
168192
fi
169193
170-
echo "All dynamically generated CI jobs completed successfully."
194+
echo "All dynamically generated CI jobs completed successfully."

0 commit comments

Comments
 (0)