Skip to content

Commit 315732a

Browse files
committed
GMQ CIsetup
1 parent 39b6044 commit 315732a

File tree

3 files changed

+431
-0
lines changed

3 files changed

+431
-0
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: 'Flaky Test Simulation'
2+
description: 'Simulates flaky test behavior for merge queue testing'
3+
inputs:
4+
failure-rate:
5+
description: 'Percentage chance of failure (0-100)'
6+
required: false
7+
default: '10'
8+
stable-prefix:
9+
description: 'Branch prefix that ensures success'
10+
required: false
11+
default: 'stable-'
12+
test-name:
13+
description: 'Name of the test being simulated'
14+
required: false
15+
default: 'generic test'
16+
17+
runs:
18+
using: 'composite'
19+
steps:
20+
- name: Flaky Test Simulation
21+
shell: bash
22+
run: |
23+
echo "🎲 Running flaky test simulation for: ${{ inputs.test-name }}"
24+
echo "Branch: ${{ github.head_ref }}"
25+
echo "Base branch: ${{ github.base_ref }}"
26+
echo "Failure rate: ${{ inputs.failure-rate }}%"
27+
28+
# Check if base branch is master-gmq (no flaky failures for gmq)
29+
if [[ "${{ github.base_ref }}" == "master-gmq" ]]; then
30+
echo "✅ Base branch is 'master-gmq' - no flaky failures for gmq merge queue"
31+
exit 0
32+
fi
33+
34+
# Check if branch has stable prefix
35+
if [[ "${{ github.head_ref }}" == ${{ inputs.stable-prefix }}* ]]; then
36+
echo "✅ Branch has stable prefix '${{ inputs.stable-prefix }}' - guaranteed success"
37+
exit 0
38+
fi
39+
40+
# Generate random number between 1-100
41+
RANDOM_NUM=$((1 + RANDOM % 100))
42+
echo "Random number: $RANDOM_NUM"
43+
44+
# Check if we should fail
45+
if [ $RANDOM_NUM -le ${{ inputs.failure-rate }} ]; then
46+
echo "💥 Simulating flaky test failure ($RANDOM_NUM <= ${{ inputs.failure-rate }})"
47+
echo "This represents the ${{ inputs.failure-rate }}% flaky failure rate"
48+
exit 1
49+
else
50+
echo "✅ Test passed ($RANDOM_NUM > ${{ inputs.failure-rate }})"
51+
exit 0
52+
fi

0 commit comments

Comments
 (0)