Skip to content

fix(ci): break infinite SHA-bump loop + fix extract-plan nested JSON#136

Merged
YiWang24 merged 5 commits into
mainfrom
fix/extract-plan-nested-json-93
May 5, 2026
Merged

fix(ci): break infinite SHA-bump loop + fix extract-plan nested JSON#136
YiWang24 merged 5 commits into
mainfrom
fix/extract-plan-nested-json-93

Conversation

@YiWang24

@YiWang24 YiWang24 commented May 5, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Break infinite SHA-bump loop (on-main-bump-sha.yml): merging a bump PR was re-triggering the workflow, creating another bump PR, ad infinitum. Added a Guard step that reads the commit message and author via git log and skips when the HEAD commit is itself a bot-authored bump (covers both squash-merge and regular-merge strategies).
  • Fix stale skip condition: the original guard required current_sha == head_sha, which can never be true after a merge commit. Simplified to skip only when already at HEAD; bump-self-sha.sh already walks back to find a valid ancestor.
  • Avoid wasteful auto-release runs on bump commits: added the same guard so chore(manifest) commits don't spin up the full commit-analysis pipeline (they always produce BUMP=none anyway).
  • Fix extract-plan nested JSON parsing (actions/issue/extract-plan, actions/pr/extract-plan): replaced the broken (?R) recursive regex (not supported in most shells) with a depth-tracking parser that correctly handles arbitrarily nested JSON objects.
  • Align docs.yml SHA with manifest after drift introduced in an earlier commit.
  • Resolve pre-push hook failures on clean main checkout (lefthook bats path issue).

Test plan

  • Merge this PR — confirm on-main-bump-sha creates exactly one follow-up bump PR and stops there (no second PR appears after the bump PR is merged)
  • Verify auto-release does not run when the bump PR is merged
  • Confirm extract-plan correctly parses issue bodies containing deeply nested JSON plan objects
  • Check that docs.yml SHA matches manifest.yml
  • All 743 bats tests pass (verified locally via pre-push hook)

View in Codesmith
Need help on this PR? Tag @codesmith with what you need.

  • Let Codesmith autofix CI failures and bot reviews

Summary by CodeRabbit

  • Chores
    • Improved automated release pipeline with enhanced safety mechanisms to prevent unintended automated commits.
    • Updated documentation build workflow to current versions.
    • Refined automated version management logic for better accuracy.

YiWang24 added 4 commits May 4, 2026 19:36
(?R) in perl recursively applies the full outer pattern, which requires
every nested {} to contain "version":"<version>" — causing extraction to
fail whenever the action plan has nested objects like params:{...} inside
an action entry (e.g. escalate action with reason+labels params).

Replace the recursive regex in Strategies B2, C (issue) and C (pr) with
a character-by-character depth tracker that:
1. Walks the input finding balanced {…} blocks (tracking strings/escapes)
2. Filters candidates by /"version"\s*:\s*"$v"/ on the full block text
3. Returns the last match so multi-attempt runs use the final output

Strategy E (issue) is fixed the same way, filtering by /"actions"\s*:\s*\[/
instead; the jq validation step that follows still checks version+type.

Adds a regression test (issue #93) that embeds a plan with nested params
objects in a markdown code-fence and confirms it is extracted correctly.
Three pre-existing issues blocked `git push` via the lefthook pre-push:

1. actionlint-full: auto-release.yml had shellcheck-reported SC2001/SC2086/
   SC2129 findings (sed → param-expansion, unquoted vars, grouped redirects).

2. verify-sha: docs.yml referenced b96e013b but manifest.yml
   pinned 4e1ecad; commit 2c283d8 updated the workflow without updating the
   manifest. Fixed by reverting docs.yml to the manifest SHA.

3. shellcheck-full / shell-lint: SC2034 (warning) is a false positive in
   library/helper .sh files that are consumed via `source`; shellcheck
   cannot follow dynamic source paths so it wrongly flags library variables
   as unused. Also fix SC2168 (local outside function) in test-reusable-
   issue.sh. Both hooks updated to --severity=error so genuine errors are
   still caught while warning-level false positives don't block pushes.
Two bugs caused on-main-bump-sha to open PRs in an endless loop:

1. No guard against self-triggering: merging a bump PR pushes a new
   commit to main, which retriggered the workflow, which created
   another bump PR, ad infinitum. Fixed by adding a Guard step that
   reads commit message + author via git log and sets skip=true when
   the HEAD commit is itself a bot-authored bump (covers both squash
   and regular merge strategies).

2. Skip condition required current_sha == head_sha, which can never
   be true after any merge commit. Simplified to only skip when the
   pinned SHA is already at HEAD; bump-self-sha.sh already handles
   walking back to a valid ancestor.

Also adds the same guard to auto-release.yml to avoid wasteful no-op
runs when a bump commit lands on main (chore commits never produce a
release anyway).
@qodo-code-review

Copy link
Copy Markdown
ⓘ You've reached your Qodo monthly free-tier limit. Reviews pause until next month — upgrade your plan to continue now, or link your paid account if you already have one.

@coderabbitai

coderabbitai Bot commented May 5, 2026

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 7f098cce-89c1-4eed-ad50-c83df00ed175

📥 Commits

Reviewing files that changed from the base of the PR and between 2cb7ff8 and 7be42db.

📒 Files selected for processing (3)
  • .github/workflows/auto-release.yml
  • .github/workflows/docs.yml
  • .github/workflows/on-main-bump-sha.yml

📝 Walkthrough

Walkthrough

Added guard steps to two release automation workflows to detect and skip bot-authored SHA-bump and merge commits, preventing recursive automation loops. Updated the pinned reference for a reusable documentation workflow to a new commit hash. Simplified SHA validation logic to check only direct HEAD equality instead of inspecting workflow file changes.

Changes

Release Automation Guard Logic

Layer / File(s) Summary
Guard Detection & Commit Analysis
.github/workflows/auto-release.yml, .github/workflows/on-main-bump-sha.yml
Two new guard steps inspect the latest commit message and author. auto-release.yml detects chore(manifest): bump ... SHA and chore/bump-self-sha- patterns. on-main-bump-sha.yml detects bot-authored commits and merge commits from the bump branch, outputting skip=true to prevent subsequent processing.
Workflow Execution Gating
.github/workflows/auto-release.yml, .github/workflows/on-main-bump-sha.yml
Conditional if: gates added to downstream steps. In auto-release.yml, "Get latest tag" and "Analyze commits since last tag" steps are skipped when guard sets skip=true. In on-main-bump-sha.yml, "Install yq" and SHA-check steps are gated on the same condition, avoiding unnecessary work.
SHA Bump Decision Logic
.github/workflows/on-main-bump-sha.yml
Reworked the "needs bumping" check: now immediately sets skip=true when current_sha equals head_sha (pinned SHA matches repository HEAD). Removed prior logic that inspected .github/workflows/ tree entries as part of the validation, simplifying when a SHA is treated as current.
Workflow Reference Update
.github/workflows/docs.yml
Reusable documentation workflow reference updated from YiAgent/OpenCI/.github/workflows/reusable-docs.yml@f195c36e... to YiAgent/OpenCI/.github/workflows/reusable-docs.yml@4e1ecadc....

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • YiAgent/OpenCI#133: Automated SHA-bump commit that the new guard logic is designed to detect and skip.
  • YiAgent/OpenCI#86: Modifies on-main-bump-sha.yml to harden branch/PR creation and cleanup, directly related to the bump automation workflow changes.
  • YiAgent/OpenCI#35: Updates the reusable docs workflow reference in .github/workflows/docs.yml, same target workflow pin as this PR.

Suggested labels

automation, workflows, ci

Poem

🐰 Loops begone, our guard stands tall,
Bot-bumped commits won't spin at all!
Skip the noise, keep the SHA,
Workflows flow the cleaner way.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/extract-plan-nested-json-93

Comment @coderabbitai help to get the list of available commands and usage tips.

@YiWang24 YiWang24 merged commit 0babb42 into main May 5, 2026
5 of 14 checks passed
@YiWang24 YiWang24 deleted the fix/extract-plan-nested-json-93 branch May 5, 2026 00:08
@sonarqubecloud

sonarqubecloud Bot commented May 5, 2026

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant