|
30 | 30 |
|
31 | 31 | permissions: |
32 | 32 | contents: write |
| 33 | + # Needed to delete the failed `viable-strict-gate` run that the |
| 34 | + # original push triggered — see the "Delete failed gate runs" step. |
| 35 | + actions: write |
33 | 36 |
|
34 | 37 | concurrency: |
35 | 38 | # One in-flight promotion at a time; safer than racing tag pushes. |
|
96 | 99 | git push origin "$TAG" |
97 | 100 |
|
98 | 101 | echo "::notice::Pushed $TAG. Watch the tag-triggered workflow runs (pull / trunk / viable-strict-gate); once they pass, the next update-viablestrict cron (every 30 min) will advance viable/strict." |
| 102 | +
|
| 103 | + # Defense-in-depth: the push that originally landed this commit |
| 104 | + # triggered a `viable-strict-gate` run that failed (because the |
| 105 | + # commit wasn't sampled). The tag push above triggers a NEW run |
| 106 | + # of the gate workflow that will succeed. Standard PyTorch viable/ |
| 107 | + # strict resolves multiple runs by taking the latest conclusion, |
| 108 | + # so this is usually fine — but to remove ambiguity (and keep the |
| 109 | + # commit's HUD row clean), explicitly delete any prior failed/ |
| 110 | + # cancelled gate runs on this SHA. |
| 111 | + - name: Delete failed viable-strict-gate runs on this SHA |
| 112 | + env: |
| 113 | + GH_TOKEN: ${{ github.token }} |
| 114 | + SHA: ${{ inputs.sha }} |
| 115 | + REPO: ${{ github.repository }} |
| 116 | + run: | |
| 117 | + set -euo pipefail |
| 118 | +
|
| 119 | + # List all viable-strict-gate runs for the SHA, filter to |
| 120 | + # those that completed unsuccessfully, and delete each one. |
| 121 | + # Failures here are non-fatal: the tag push above is the |
| 122 | + # primary mechanism; this cleanup is best-effort. |
| 123 | + RUNS=$(gh api "repos/$REPO/actions/runs?head_sha=$SHA&per_page=100" \ |
| 124 | + --jq '.workflow_runs[] |
| 125 | + | select(.name == "viable-strict-gate") |
| 126 | + | select(.conclusion == "failure" or .conclusion == "cancelled" or .conclusion == "timed_out") |
| 127 | + | .id' 2>/dev/null || true) |
| 128 | +
|
| 129 | + if [ -z "$RUNS" ]; then |
| 130 | + echo "No prior failed viable-strict-gate runs to clean up." |
| 131 | + exit 0 |
| 132 | + fi |
| 133 | +
|
| 134 | + while IFS= read -r RUN_ID; do |
| 135 | + [ -z "$RUN_ID" ] && continue |
| 136 | + echo "Deleting failed viable-strict-gate run $RUN_ID" |
| 137 | + gh api -X DELETE "repos/$REPO/actions/runs/$RUN_ID" || \ |
| 138 | + echo "::warning::Failed to delete run $RUN_ID; continuing anyway." |
| 139 | + done <<< "$RUNS" |
0 commit comments