mirror of
https://github.com/nomadkaraoke/karaoke-gen.git
synced 2026-11-20 13:07:57 +09:00
fix(e2e): self-heal job approves its PR's CI run (no manual step) (#1118)
## Summary This follows #1116. The live test of the self-heal loop (bot PR #1117) merged, but only after one manual step: approving its CI run. - **Approve the bot PR's CI run.** A bot-authored PR's `pull_request` CI run is created as **action_required** (waiting for approval), and until it runs it outranks the passing CI Gate from the dispatched run. The `self-heal-pr` job now approves that run via `POST /actions/runs/{id}/approve`. If approval fails, it dispatches `ci.yml` and the Discord alert says the PR needs a one-click approval, with a link. - **Ruleset dependency, now documented.** `require_extra_approval_for_unattributed_changes` is now set to `false` on the `protect main` ruleset (11423976). It's a newer GitHub setting that defaults to true and blocks bot-authored PRs until a human approves. This is recorded in `docs/TESTING.md` and `docs/LESSONS-LEARNED.md`. ## Testing - `actionlint` is clean for the changed lines. - After merge: a forced-LLM run on `main` on a step with no learned recipe yet (`fillPostalCode`) will open a fresh bot PR and exercise approval → CI → auto-merge without manual input. @coderabbitai ignore 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
84f709ea0e
commit
1c9104a79d
3 files changed
+57
-15
No files matched your search
@@ -246,11 +246,13 @@ jobs:
|
||||
# learned-variants.json) that auto-merges, so the next run replays the
|
||||
# recipe deterministically. No human in the loop.
|
||||
#
|
||||
# PRs opened with GITHUB_TOKEN don't trigger `pull_request` workflows, so we
|
||||
# dispatch ci.yml on the branch ourselves (workflow_dispatch IS allowed from
|
||||
# GITHUB_TOKEN); its "CI Gate" check run lands on the head SHA and satisfies
|
||||
# the `main` ruleset. `@coderabbitai ignore` keeps review threads (which the
|
||||
# ruleset requires resolved) from blocking auto-merge.
|
||||
# Merge gates for a bot PR (all verified live with #1117, 2026-10-03):
|
||||
# - its `pull_request` CI run is created "action_required" and, until run,
|
||||
# supersedes other CI Gate results → we approve it via the API;
|
||||
# - the `protect main` ruleset's require_extra_approval_for_unattributed_changes
|
||||
# (GitHub default true since ~Aug 2026) would demand a human review for
|
||||
# bot-authored changes → set to false on ruleset 11423976;
|
||||
# - review threads must be resolved → `@coderabbitai ignore` in the body.
|
||||
self-heal-pr:
|
||||
name: "Self-heal: auto-merge PR"
|
||||
runs-on: ubuntu-latest
|
||||
@@ -333,16 +335,47 @@ jobs:
|
||||
--title "test(e2e): self-heal Stripe Checkout ($STEPS)" --body-file /tmp/pr-body.md)
|
||||
echo "pr_url=$PR_URL" >> "$GITHUB_OUTPUT"
|
||||
gh pr merge "$PR_URL" --auto --squash
|
||||
# GITHUB_TOKEN-created PRs don't trigger CI on their own.
|
||||
gh workflow run ci.yml --ref "$BRANCH"
|
||||
echo "Opened $PR_URL (auto-merge enabled, CI dispatched)"
|
||||
|
||||
# A bot-authored PR's `pull_request` CI run is created as
|
||||
# "action_required" (awaiting approval) — and until it runs it
|
||||
# supersedes any other CI Gate result for the ruleset. Approve it.
|
||||
APPROVED=false
|
||||
for _ in $(seq 1 18); do
|
||||
IDS=$(gh run list --workflow ci.yml --branch "$BRANCH" --event pull_request --json databaseId,status,conclusion \
|
||||
--jq '.[] | select(.status == "waiting" or .status == "action_required" or .conclusion == "action_required") | .databaseId')
|
||||
for id in $IDS; do
|
||||
if gh api -X POST "repos/${{ github.repository }}/actions/runs/$id/approve" >/dev/null; then
|
||||
echo "Approved CI run $id"; APPROVED=true
|
||||
else
|
||||
echo "::warning::Could not approve CI run $id with GITHUB_TOKEN"
|
||||
fi
|
||||
done
|
||||
# Already running/finished without needing approval?
|
||||
if [ -z "$IDS" ] && [ -n "$(gh run list --workflow ci.yml --branch "$BRANCH" --event pull_request --json databaseId --jq '.[0].databaseId // ""')" ]; then
|
||||
APPROVED=true
|
||||
fi
|
||||
[ "$APPROVED" = "true" ] && break
|
||||
sleep 10
|
||||
done
|
||||
if [ "$APPROVED" != "true" ]; then
|
||||
# Fallback: dispatched CI (allowed from GITHUB_TOKEN) still puts a
|
||||
# CI Gate check on the head SHA if no pull_request run exists.
|
||||
gh workflow run ci.yml --ref "$BRANCH"
|
||||
echo "ci_needs_approval=true" >> "$GITHUB_OUTPUT"
|
||||
echo "::warning::CI for $PR_URL may need a one-click approval in the Actions tab"
|
||||
fi
|
||||
echo "Opened $PR_URL (auto-merge enabled, CI approved=$APPROVED)"
|
||||
|
||||
- name: Discord notification (self-heal)
|
||||
# Recipe already on main (e.g. merged between checkout and now) → nothing to report.
|
||||
if: always() && steps.pr.outputs.unchanged != 'true'
|
||||
run: |
|
||||
PR="${{ steps.pr.outputs.pr_url }}"
|
||||
if [ -n "$PR" ]; then
|
||||
if [ -n "$PR" ] && [ "${{ steps.pr.outputs.ci_needs_approval }}" = "true" ]; then
|
||||
TITLE="🩹 E2E self-healed Stripe — PR needs a CI approval click"
|
||||
DESC="LLM fallback healed a Stripe Checkout change. The auto-merge PR's CI run awaits approval (open the PR → Checks → Approve and run): $PR"
|
||||
COLOR=16776960
|
||||
elif [ -n "$PR" ]; then
|
||||
TITLE="🩹 E2E self-healed a Stripe Checkout change"
|
||||
DESC="Stripe changed its checkout page; the LLM fallback got through and the purchase was verified. Auto-merge PR: $PR"
|
||||
COLOR=16776960
|
||||
|
||||
Reference in new issue
Block a user