Skip to content

[internal] Auto-retry post-commit #236

[internal] Auto-retry post-commit

[internal] Auto-retry post-commit #236

name: "[internal] Auto-retry post-commit"
on:
workflow_dispatch:
inputs:
test_workflow_run_id:
description: "Unique GitHub workflow run ID to use for test"
default: 1278872273u
type: number
test_workflow_run_attempt:
description: "Run attempt of the workflow run"
default: 1
type: number
workflow_run:
workflows:
- "All post-commit tests"
types:
- completed
jobs:
auto-retry:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Get workflow run_id attempt number to analyze
id: get-run-id-and-attempt
shell: bash
run: |
event_name="${{ github.event_name }}"
if [[ "$event_name" == "workflow_dispatch" ]]; then
run_id="${{ inputs.test_workflow_run_id }}"
attempt_number="${{ inputs.test_workflow_run_attempt }}"
elif [[ "$event_name" == "workflow_run" ]]; then
run_id="${{ github.event.workflow_run.id }}"
attempt_number="${{ github.event.workflow_run.run_attempt }}"
[[ -z "$run_id" ]] && { echo "run_id is empty" ; exit 1; }
[[ -z "$attempt_number" ]] && { echo "attempt_number is empty" ; exit 1; }
else
echo "Unknown event name" && exit 1
fi
echo $run_id
echo $attempt_number
echo "run-id=$run_id" >> "$GITHUB_OUTPUT"
echo "attempt-number=$attempt_number" >> "$GITHUB_OUTPUT"
echo "::notice title=target-workflow-link::The workflow being analyzed is available at https://github.com/tenstorrent/tt-metal/actions/runs/$run_id/attempts/$attempt_number"
- name: Determine if we should continue
shell: bash
run: |
MAX_ATTEMPTS=5
if [[ "${{ steps.get-run-id-and-attempt.outputs.attempt_number }}" == "$MAX_ATTEMPTS" ]]; then
echo "::notice title=no-continue-max-tries::This workflow has exceeded max tries. Not re-trying"
should_continue=false
elif [[ "${{ github.event_name }}" != "workflow_dispatch" ]]; then
echo "::notice title=no-continue-is-on-branch::This workflow was not dispatched - not retrying"
should_continue=false
else
should_continue=true
fi
echo "should-continue=$should_continue" >> "$GITHUB_OUTPUT"
- name: Re-run failed jobs
env:
GH_TOKEN: ${{ github.token }}
run: |
echo "Re-running jobs here"
- uses: ./.github/actions/slack-report
if: ${{ failure() }}
with:
slack_webhook_url: ${{ secrets.SLACK_WEBHOOK_URL }}
owner: U014XCQ9CF8 # tt-rkim