Skip to content

Commit

Permalink
#0: [skip ci] Add initial auto-retry post commit workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
tt-rkim committed Jan 21, 2025
1 parent fb191aa commit d2179b5
Showing 1 changed file with 72 additions and 0 deletions.
72 changes: 72 additions & 0 deletions .github/workflows/_auto-retry-post-commit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
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

0 comments on commit d2179b5

Please sign in to comment.