mit einem Klick
retry-flaky-tests
// Automatically retry failed required CI checks on GitHub PRs, with smart waiting and filtering logic
// Automatically retry failed required CI checks on GitHub PRs, with smart waiting and filtering logic
Generate a concise PR description from code changes, following the repo's PR template
Automatically resolve CVEs by checking GitHub issues, verifying presence in codebase, and attempting various remediation strategies while documenting the process.
Run Jest unit tests for files changed in the current branch
| name | retry_flaky_tests |
| description | Automatically retry failed required CI checks on GitHub PRs, with smart waiting and filtering logic |
| arguments | [{"name":"pr_number","description":"PR number to check. If not provided, will detect from current branch","required":false}] |
Automatically handles flaky CI tests by intelligently retrying only failed required checks on GitHub PRs. Saves time by avoiding manual monitoring and selective retrying.
/retry-flaky-tests [--pr_number 123] [--wait_for_completion true] [--max_retries 3] [--poll_interval 30]
If --pr_number provided:
gh pr view {pr_number} --json number,headRefName,baseRefName
If not provided, detect from current branch:
# Get current branch
current_branch=$(git branch --show-current)
# Find PR for this branch
gh pr list --head "$current_branch" --json number,title,headRefName
Validation:
# Get all check runs for the PR
gh pr checks {pr_number} --json name,status,conclusion,detailsUrl
# Get workflow runs with more detail
gh run list --pr {pr_number} --json databaseId,name,status,conclusion,workflowName
Parse results to categorize checks:
status: "completed", conclusion: "success"status: "completed", conclusion: "failure"status: "in_progress" or status: "queued"conclusion: "skipped" or conclusion: "cancelled"Get branch protection rules:
# Get protection rules for base branch (usually main/master)
gh api repos/{owner}/{repo}/branches/{base_branch}/protection \
--jq '.required_status_checks.contexts[]'
Cross-reference with current checks:
Fallback if no protection rules:
# If branch protection API fails, use heuristics:
# - Checks with "required" in description
# - Common required check patterns: "build", "test", "lint", "security"
# - Exclude obvious optional ones: "codecov", "sonar", "deploy-preview"
If --wait_for_completion true:
while [[ $in_progress_count -gt 0 ]]; do
echo "⏳ Waiting for $in_progress_count checks to complete..."
sleep {poll_interval}
# Re-check status
gh pr checks {pr_number} --json name,status,conclusion
# Update in_progress_count
done
echo "✅ All checks completed. Proceeding with retry logic..."
Progress indicators:
For each failed required check:
# Get the specific workflow run ID
run_id=$(gh run list --pr {pr_number} --workflow "{workflow_name}" \
--json databaseId --jq '.[0].databaseId')
# Retry only the failed jobs (not successful ones)
gh run rerun $run_id --failed
echo "🔄 Retried {workflow_name} (run #$run_id)"
Retry strategy:
conclusion: "failure" (not cancelled/skipped)--max_retriesAfter triggering retries:
echo "🚀 Triggered retries for $retry_count required checks:"
for check in "${retried_checks[@]}"; do
echo " - $check"
done
echo ""
echo "📊 Current status summary:"
echo " ✅ Passed: $passed_count"
echo " 🔄 Retrying: $retry_count"
echo " ⏸️ In Progress: $in_progress_count"
echo " ❌ Still Failed: $still_failed_count"
This skill transforms flaky CI from a time-sink into an automated background task! 🚀