mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-12-04 16:58:28 +00:00
chore(ci): drop the cancelled-run rerun automation
The hourly sweep fought the rest of the CI control plane instead of helping it: it preempted itself (17 of the last 29 runs concluded cancelled 1-2s after their successor was created, for 8s of work behind a 74-80min queue wait) and shipped MAX_ATTEMPTS=0, which the script reads as no ceiling while its own README promised the opposite. The 24h age cutoff could not bound it either, because every rerun refreshes the run's updatedAt and so keeps it inside the window. Removes the workflow, the two scripts it was the sole consumer of, its unit test, and the CI_RERUN_* documentation that would otherwise point at a deleted file. The workflow is disabled in both origin and fork so no sweep fires before this lands. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
8aaac027d2
commit
3a1ef70cbb
8 files changed
-276
No files matched your search
@@ -1,11 +0,0 @@
|
||||
# Run Reruns 🔁
|
||||
|
||||
Shell helpers that restart the unfinished parts of GitHub Actions workflow runs that were cancelled rather than completed.
|
||||
|
||||
## Scope 📋
|
||||
|
||||
This directory contains helpers invoked from scheduled workflows. They call the GitHub Actions API to rerun the failed jobs of a cancelled run, never the run as a whole, so the work that already succeeded is kept. A run is a candidate only while it is recent and below its attempt ceiling; both bounds are passed in by the calling workflow, because a sweep without them would resurrect abandoned branches and retry a permanently cancelled run forever.
|
||||
|
||||
Helpers MUST NOT rerun a run whose conclusion is `failure`. A real defect has to be fixed, not retried, and the [cancel](../cancel/README.md) helpers exist precisely so that a cancellation means "interrupted", not "broken".
|
||||
|
||||
For the workflow catalog that drives these calls see [workflows.md](../../../docs/contributing/tools/github/actions/workflows.md).
|
||||
@@ -1,74 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# Restart the failed jobs of every branch whose latest workflow run ended
|
||||
# cancelled.
|
||||
#
|
||||
# Inputs via env:
|
||||
# GH_TOKEN token carrying actions:write on REPOSITORY
|
||||
# REPOSITORY owner/repo
|
||||
# MAX_ATTEMPTS leave runs alone once they reached this attempt count;
|
||||
# 0 keeps reviving a run for as long as it stays in range
|
||||
# MAX_AGE_HOURS leave runs alone whose last update is older than this
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
: "${GH_TOKEN:?Missing GH_TOKEN}"
|
||||
: "${REPOSITORY:?Missing REPOSITORY}"
|
||||
: "${MAX_ATTEMPTS:?Missing MAX_ATTEMPTS}"
|
||||
: "${MAX_AGE_HOURS:?Missing MAX_AGE_HOURS}"
|
||||
|
||||
if ! command -v gh >/dev/null 2>&1; then
|
||||
echo "ERROR: gh CLI not found." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! command -v jq >/dev/null 2>&1; then
|
||||
echo "ERROR: jq not found." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cutoff="$(date -u -d "${MAX_AGE_HOURS} hours ago" +%Y-%m-%dT%H:%M:%SZ)"
|
||||
|
||||
echo "Rerunning cancelled runs updated after ${cutoff}, below attempt ${MAX_ATTEMPTS}"
|
||||
|
||||
branches="$(
|
||||
gh api --paginate \
|
||||
-H "Accept: application/vnd.github+json" \
|
||||
"/repos/${REPOSITORY}/branches?per_page=100" |
|
||||
jq -r '.[].name'
|
||||
)"
|
||||
|
||||
while read -r branch; do
|
||||
[[ -n "${branch}" ]] || continue
|
||||
|
||||
runs="$(
|
||||
gh run list \
|
||||
--repo "${REPOSITORY}" \
|
||||
--branch "${branch}" \
|
||||
--limit 20 \
|
||||
--json databaseId,conclusion,status,attempt,updatedAt
|
||||
)"
|
||||
|
||||
active="$(jq -r 'map(select(.status != "completed")) | length' <<<"${runs}")"
|
||||
if [[ "${active}" != "0" ]]; then
|
||||
echo "${branch}: ${active} run(s) still active, leaving the cancelled one alone"
|
||||
continue
|
||||
fi
|
||||
|
||||
run_id="$(
|
||||
jq -r --arg cutoff "${cutoff}" --argjson max "${MAX_ATTEMPTS}" '
|
||||
.[0]
|
||||
| select(.conclusion == "cancelled")
|
||||
| select($max == 0 or .attempt < $max)
|
||||
| select(.updatedAt > $cutoff)
|
||||
| .databaseId
|
||||
' <<<"${runs}"
|
||||
)"
|
||||
|
||||
[[ -n "${run_id}" ]] || continue
|
||||
|
||||
echo "${branch}: rerunning the failed jobs of cancelled run ${run_id}"
|
||||
if ! gh run rerun "${run_id}" --repo "${REPOSITORY}" --failed; then
|
||||
echo "${branch}: run ${run_id} could not be rerun, likely already restarted"
|
||||
fi
|
||||
done <<<"${branches}"
|
||||
@@ -1,28 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# Emit due=true on GITHUB_OUTPUT when the current hour opens an interval window
|
||||
# counted from 00:00 UTC. Intervals are rounded up to whole hours.
|
||||
#
|
||||
# Inputs via env:
|
||||
# INTERVAL_MINUTES wanted interval between two sweeps
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
: "${INTERVAL_MINUTES:?Missing INTERVAL_MINUTES}"
|
||||
: "${GITHUB_OUTPUT:?Missing GITHUB_OUTPUT}"
|
||||
|
||||
hours="$(((INTERVAL_MINUTES + 59) / 60))"
|
||||
|
||||
if ((hours < 1)); then
|
||||
hours=1
|
||||
fi
|
||||
|
||||
hour="$((10#$(date -u +%H)))"
|
||||
|
||||
if ((hour % hours == 0)); then
|
||||
echo "$(date -u +%H:%M) UTC opens the ${hours}h window, sweeping"
|
||||
echo "due=true" >>"${GITHUB_OUTPUT}"
|
||||
else
|
||||
echo "$(date -u +%H:%M) UTC is inside the ${hours}h window, skipping"
|
||||
echo "due=false" >>"${GITHUB_OUTPUT}"
|
||||
fi
|
||||
Reference in new issue
Block a user