The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
ci(label-rerun): never rerun a CI run whose PR head has moved
teknium1013b776ab069
diff --git a/.github/workflows/label-rerun.yml b/.github/workflows/label-rerun.ymlindex a09e0b375e4..d8d6fe79059 100644--- a/.github/workflows/label-rerun.yml+++ b/.github/workflows/label-rerun.yml@@ -43,6 +43,7 @@ jobs:GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}REPO: ${{ github.repository }}HEAD_SHA: ${{ github.event.pull_request.head.sha }}+ PR: ${{ github.event.pull_request.number }}run: |set -uo pipefail@@ -88,6 +89,15 @@ jobs:fifi+ # A push while we waited cancelled this run (that is the "completed"+ # we saw). Rerunning it would rejoin the PR's CI concurrency group and+ # cancel the new head's run, which already sees the label.+ CURRENT_HEAD=$(gh pr view "$PR" --repo "$REPO" --json headRefOid --jq .headRefOid || true)+ if [ "$CURRENT_HEAD" != "$HEAD_SHA" ]; then+ echo "PR head moved to $CURRENT_HEAD; not rerunning superseded run $RUN_ID."+ exit 0+ fi+echo "Run completed. Rerunning all failed jobs..."gh run rerun "$RUN_ID" --repo "$REPO" --failed || trueecho "Done. GitHub will rerun review-labels and all dependent jobs."@@ -103,6 +113,7 @@ jobs:GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}REPO: ${{ github.repository }}HEAD_SHA: ${{ github.event.pull_request.head.sha }}+ PR: ${{ github.event.pull_request.number }}run: |set -uo pipefailfor workflow in ci.yaml docker.yml nix.yml; do@@ -123,6 +134,12 @@ jobs:sleep 5donefi+ # Same supersede guard as above: never rerun a run for an old head.+ CURRENT_HEAD=$(gh pr view "$PR" --repo "$REPO" --json headRefOid --jq .headRefOid || true)+ if [ "$CURRENT_HEAD" != "$HEAD_SHA" ]; then+ echo "PR head moved to $CURRENT_HEAD; not rerunning superseded $workflow run $RUN_ID."+ exit 0+ fiif gh run rerun "$RUN_ID" --repo "$REPO"; thenecho "$workflow: rerunning $RUN_ID"else