Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions .github/workflows/auto-retry-failed.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Copyright (c) Advanced Micro Devices, Inc., or its affiliates.
# SPDX-License-Identifier: MIT

# Automatically re-runs the failed jobs of a watched CI run, up to a fixed
# number of attempts. This mirrors clicking "Re-run failed jobs" in the web UI:
# `gh run rerun --failed` calls the same rerun-failed-jobs API, so each retry
# lands on a fresh runner and is recorded as a new attempt on the SAME run
# (prior attempts stay visible in the run's attempt history).
#
# The retry loop is self-capping: `workflow_run` fires whenever an attempt of
# the watched run completes, so a failed attempt N triggers this workflow with
# run_attempt == N, which re-runs and produces attempt N+1, and so on until the
# run_attempt cap below is reached.
#
# Motivation: most nightly failures are infrastructure flakes (no GPU assigned,
# an overloaded/wedged machine, or a network blip during artifact fetch) rather
# than real test regressions. Those clear on a fresh runner, which a same-runner
# step retry cannot provide.
#
# NOTE: `workflow_run` always uses the copy of this file on the repository's
# default branch, and only fires for runs there. It has no effect from a PR
# branch until merged.

name: Auto-retry failed CI

on:
workflow_run:
workflows:
- "TheRock CI Nightly"
types:
- completed

permissions:
# Required to trigger a re-run of the watched workflow run.
actions: write
contents: read

jobs:
rerun-failed:
name: Rerun failed jobs
runs-on: ubuntu-24.04
timeout-minutes: 5
# Only genuine failures under the attempt cap. run_attempt < 4 allows up to
# 4 total attempts (the original run plus 3 auto-retries). 'cancelled'
# (concurrency / superseded runs) and 'startup_failure' are intentionally
# excluded so we never retry work that was deliberately abandoned.
if: >-
github.event.workflow_run.conclusion == 'failure' &&
github.event.workflow_run.run_attempt < 4
Comment thread
tony-davis marked this conversation as resolved.
Resolved
env:
GH_TOKEN: ${{ github.token }}
RUN_ID: ${{ github.event.workflow_run.id }}
ATTEMPT: ${{ github.event.workflow_run.run_attempt }}
steps:
- name: Re-run failed jobs
run: |
echo "Run ${RUN_ID} failed on attempt ${ATTEMPT}; re-running failed jobs on fresh runners."
gh run rerun "${RUN_ID}" --failed --repo "${{ github.repository }}"
Loading