Add /recipe-upgrade + /upgrade-all skills (cc-ci-gated upgrades, never merge)
Per-recipe and fleet-wide upgrade skills modelled on recipe-maintainer's
recipe-upgrade-full / recipe-upgrade-cron-all, but gated by the cc-ci CI server
and inheriting ci-test-review's create+verify+never-merge discipline.
- recipe-upgrade/: plan (release notes, breaking changes) -> implement (abra
recipe upgrade + version bump + config, lint) -> open the recipe PR -> VERIFY
green on cc-ci (full suite cold against the PR head via verify-pr.sh). If the
upgrade is correct but a cc-ci TEST went stale, also update the test, verify
it, and open a second PR to recipe-maintainers/cc-ci. Never merges; never
weakens a test; prefers a recipe-only PR. Emits a parseable RESULT line.
+ open-recipe-pr.sh: adapted recipe-create-pr; runs on cc-ci (has the recipe
checkout + bot token), creds passed from the orchestrator .testenv;
force-syncs the mirror main so the PR diff is exactly the upgrade.
- upgrade-all/: weekly fan-out — enumerate enrolled recipes, survey upgrades,
run /recipe-upgrade per upgradeable recipe via subagent (sequential default,
--parallel / --dry-run), collect into one PR-list summary. Coordination +
single-writer + shared-Swarm-teardown guardrails; built for a weekly cron.
- ci-test-review/verify-pr.sh: pass SRC (recipe-maintainers/<recipe>) alongside
REF so the harness clones the mirror PR head correctly (its real contract).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
+94
@@ -0,0 +1,94 @@
|
||||
#!/usr/bin/env bash
|
||||
# recipe-upgrade :: open a recipe PR on git.autonomic.zone (adapted from
|
||||
# recipe-maintainer's recipe-create-pr for the cc-ci context).
|
||||
# -------------------------------------------------------------------------
|
||||
# RUNS ON cc-ci (it has the recipe checkout at ~/.abra/recipes/<recipe>).
|
||||
# Invoke from the orchestrator, feeding creds + the script over ssh:
|
||||
#
|
||||
# set -a; . /srv/cc-ci/.testenv; set +a
|
||||
# ssh cc-ci "GITEA_USERNAME='$GITEA_USERNAME' GITEA_PASSWORD='$GITEA_PASSWORD' \
|
||||
# GITEA_URL='$GITEA_URL' bash -s <recipe>" \
|
||||
# < /srv/cc-ci/.claude/skills/recipe-upgrade/open-recipe-pr.sh
|
||||
#
|
||||
# Preconditions on cc-ci: ~/.abra/recipes/<recipe> is a git checkout with the
|
||||
# upgrade commit(s) on HEAD beyond origin/main (the apply step made them).
|
||||
# Force-syncs the gitea mirror's main from upstream origin/main so the PR diff
|
||||
# is exactly the upgrade. Prints the PR URL. Never merges.
|
||||
set -o errexit -o nounset -o pipefail
|
||||
|
||||
RECIPE="${1:?usage: open-recipe-pr.sh <recipe>}"
|
||||
: "${GITEA_USERNAME:?missing GITEA_USERNAME (pass via ssh env)}"
|
||||
: "${GITEA_PASSWORD:?missing GITEA_PASSWORD}"
|
||||
: "${GITEA_URL:?missing GITEA_URL}"
|
||||
NAMESPACE="${GITEA_NAMESPACE:-recipe-maintainers}"
|
||||
RECIPE_DIR="${HOME}/.abra/recipes/${RECIPE}"
|
||||
|
||||
export PATH="/run/current-system/sw/bin:${PATH}"
|
||||
PASS_ENC=$(python3 -c "import urllib.parse,sys;print(urllib.parse.quote(sys.argv[1],safe=''))" "${GITEA_PASSWORD}")
|
||||
API="https://${GITEA_URL}/api/v1"
|
||||
AUTH=(-u "${GITEA_USERNAME}:${GITEA_PASSWORD}")
|
||||
|
||||
[ -d "${RECIPE_DIR}/.git" ] || { echo "ERROR: ${RECIPE_DIR} is not a git repo (run 'abra recipe fetch ${RECIPE}')"; exit 1; }
|
||||
cd "${RECIPE_DIR}"
|
||||
|
||||
echo "→ Fetching upstream main..."
|
||||
git fetch origin main
|
||||
|
||||
DIVERGED=$(git log --oneline origin/main..HEAD 2>/dev/null || true)
|
||||
[ -n "${DIVERGED}" ] || { echo "ERROR: HEAD has no commits beyond origin/main. Nothing to PR."; exit 1; }
|
||||
echo "→ Local commits to PR:"; echo "${DIVERGED}" | sed 's/^/ /'
|
||||
|
||||
LATEST_MSG=$(git log -1 --pretty=%s HEAD)
|
||||
if echo "${LATEST_MSG}" | grep -qiE "upgrade to [0-9]"; then
|
||||
VERSION=$(echo "${LATEST_MSG}" | grep -oiE "upgrade to [0-9][^[:space:]]+" | awk '{print $NF}')
|
||||
BRANCH="upgrade-${VERSION}"
|
||||
else
|
||||
BRANCH="upgrade-$(git rev-parse --short HEAD)"
|
||||
fi
|
||||
echo "→ PR branch: ${BRANCH}"
|
||||
|
||||
# Check / create the mirror repo.
|
||||
STATUS=$(curl -s -o /dev/null -w "%{http_code}" "${AUTH[@]}" "${API}/repos/${NAMESPACE}/${RECIPE}")
|
||||
if [ "${STATUS}" = "404" ]; then
|
||||
echo "→ Mirror ${NAMESPACE}/${RECIPE} missing; creating..."
|
||||
BODY=$(python3 -c "import json;print(json.dumps({'name':'${RECIPE}','private':True,'default_branch':'main','auto_init':False}))")
|
||||
CS=$(curl -s -o /dev/null -w "%{http_code}" "${AUTH[@]}" -H "Content-Type: application/json" -X POST "${API}/orgs/${NAMESPACE}/repos" -d "${BODY}")
|
||||
if [ "${CS}" != "201" ]; then
|
||||
CS=$(curl -s -o /dev/null -w "%{http_code}" "${AUTH[@]}" -H "Content-Type: application/json" -X POST "${API}/user/repos" -d "${BODY}")
|
||||
[ "${CS}" = "201" ] || { echo "ERROR: repo create failed (HTTP ${CS})"; exit 1; }
|
||||
NAMESPACE="${GITEA_USERNAME}"
|
||||
fi
|
||||
echo " ✓ created ${NAMESPACE}/${RECIPE}"
|
||||
elif [ "${STATUS}" != "200" ]; then
|
||||
echo "ERROR: unexpected HTTP ${STATUS} checking mirror repo"; exit 1
|
||||
fi
|
||||
|
||||
REMOTE_URL="https://${GITEA_USERNAME}:${PASS_ENC}@${GITEA_URL}/${NAMESPACE}/${RECIPE}.git"
|
||||
git remote | grep -qx gitea && git remote set-url gitea "${REMOTE_URL}" || git remote add gitea "${REMOTE_URL}"
|
||||
|
||||
echo "→ Force-syncing gitea/main from origin/main (clean diff)..."
|
||||
git push --force gitea "refs/remotes/origin/main:refs/heads/main"
|
||||
echo "→ Pushing branch '${BRANCH}'..."
|
||||
git push --force gitea "HEAD:refs/heads/${BRANCH}"
|
||||
|
||||
PR_BODY="${RECIPE_PR_BODY:-$(printf 'Recipe upgrade.\n\nCommits on top of upstream main:\n\n%s\n' "$(git log origin/main..HEAD --pretty='- %h %s')")}"
|
||||
PR_BODY="${PR_BODY}
|
||||
|
||||
Tested green on the cc-ci recipe CI server (full suite, cold, against this PR head). NOT merged — for operator review.
|
||||
|
||||
cc @trav @notplants"
|
||||
PAYLOAD=$(python3 -c "
|
||||
import json,sys
|
||||
print(json.dumps({'title':sys.argv[1],'body':sys.argv[2],'head':sys.argv[3],'base':'main','reviewers':['trav','notplants']}))" \
|
||||
"${LATEST_MSG}" "${PR_BODY}" "${BRANCH}")
|
||||
|
||||
RESP=$(mktemp)
|
||||
PS=$(curl -s -o "${RESP}" -w "%{http_code}" "${AUTH[@]}" -H "Content-Type: application/json" -X POST "${API}/repos/${NAMESPACE}/${RECIPE}/pulls" -d "${PAYLOAD}")
|
||||
if [ "${PS}" = "201" ]; then
|
||||
echo "PR_URL=$(python3 -c "import json;print(json.load(open('${RESP}'))['html_url'])")"
|
||||
elif [ "${PS}" = "409" ] || grep -q "pull request already exists" "${RESP}" 2>/dev/null; then
|
||||
echo "PR_URL=https://${GITEA_URL}/${NAMESPACE}/${RECIPE}/pulls (branch ${BRANCH} already has a PR)"
|
||||
else
|
||||
echo "ERROR: PR creation failed (HTTP ${PS}):"; cat "${RESP}"; rm -f "${RESP}"; exit 1
|
||||
fi
|
||||
rm -f "${RESP}"
|
||||
Reference in New Issue
Block a user