Skip to content

MOEN-46303: Robust CHANGELOG anchoring + PR body improvements for dependency-update automation - #131

Merged
umangmoe merged 1 commit into
developmentfrom
patch/MOEN-46303/dep-automation-fix
Jul 24, 2026
Merged

MOEN-46303: Robust CHANGELOG anchoring + PR body improvements for dependency-update automation#131
umangmoe merged 1 commit into
developmentfrom
patch/MOEN-46303/dep-automation-fix

Conversation

@AnirudhaSM-engg-sdk

@AnirudhaSM-engg-sdk AnirudhaSM-engg-sdk commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Jira Ticket

MOEN-46303

Description

Summary

Fixes root cause of the CHANGELOG-pollution bug that was patched manually in PR #129, plus a few small improvements found during review.

Motivation

PR #128 (the first real production run of the automation) produced a diff that placed dependency bump entries inside released sections of several CHANGELOGs — for personalize on the iOS side, and for all 5 modules on the Android side. PR #129 manually moved those entries into unreleased sections, but the root causes in the scripts remained. This PR fixes those root causes.

What changed

1. Robust CHANGELOG anchoring (bug fix)

The scripts previously tried to detect where released content starts via Regex("^# \\d{2}-\\d{2}-\\d{4}$"). That strict regex fails on trailing whitespace (the actual PR #128 trigger — the personalize CHANGELOG had # 11-06-2026 with a trailing space) and any other date-format variation. When the regex fails, both scripts fall through and insert new entries into the most recent released section.

Fix: Anchor on the explicit # Release Date unreleased marker instead. If present, append into it; if absent, prepend a fresh unreleased section. Applied to both update-ios-deps.main.kts and update-bom.main.kts. The Android script never had the "prepend when missing" behavior at all — that's why PR #128 polluted every released Android section.

2. patch/ branch prefix

Workflow-generated branches now follow the repo convention:

  • Before: ${TICKET}/dependency_update
  • After: patch/${TICKET}/dependency_update

3. Pre-flight branch collision check

Before running the scripts, the workflow checks whether the target branch already exists on remote. If yes, it fails fast with a clear message: "Branch already exists. Use a fresh ticket, or delete the existing branch first." Enforces the "one ticket = one PR" invariant explicitly.

4. Duplicate-line protection

If a subsequent run bumps the same artifact to a newer version (e.g. MoEngagePluginBase 6.10.0 → 6.10.1 after a previous run left 6.10.0 in the CHANGELOG), the existing bullet is updated in place instead of creating a duplicate.

5. Descriptive PR body

Both scripts now emit .github/scripts/.bump-summary.txt per-run. The workflow includes it in the PR body under a ## Bumps section, so reviewers see the actual version changes without opening the diff.

Files changed

  • .github/scripts/update-ios-deps.main.kts — refactor appendIosChangelogEntries; artifact-level duplicate protection; emit bump summary
  • .github/scripts/update-bom.main.kts — refactor updateChangelog with same anchoring pattern; prepend fresh unreleased section when missing; emit bump summary
  • .github/workflows/update_dependency.ymlpatch/ prefix; pre-flight collision check; PR body enhancement

Testing

21 dry-run assertions across 7 scenarios pass locally (kotlin 2.3.21, matching CI):

# Scenario Assertions
A Pathological PR #128 case — CHANGELOG starts with # 11-06-2026 (trailing space) Released 1.0.2 NOT polluted; fresh unreleased section prepended
B CHANGELOG already has # Release Date unreleased section Exactly one # Release Date marker; bump lands in unreleased
C Re-run with same artifact Bullet updated in place, no duplicate
D - Android heading with pre-existing manual bullets Manual bullets preserved; new bump appended
E Byte-exact podspec format preservation across all 5 quote/whitespace styles 5 podspecs byte-identical to HEAD after downgrade + bump
F .bump-summary.txt emission Correct format for iOS bumps + MoEngage-iOS-SDK line
G Workflow YAML validity Parses; has patch/ prefix, pre-flight check, bumps section

Behavior when # Release Date section already exists

The refactored anchoring works as follows:

  • File starts with # Release Date → append into the existing unreleased section. Finds or creates the - iOS / - Android heading within it; respects existing manual bullets; updates in place if the same artifact was bumped previously.
  • File starts with anything else (dated heading, etc.) → prepend a fresh # Release Date / ## Release Version / - <Platform> section. Existing released content is never touched.

Suggested smoke test before merge

Trigger the workflow on this PR branch (Actions → Update Dependency → Run workflow → select patch/MOEN-46303/dep-automation-fix) with a test ticket and target=ios. Expected: all pods SKIP (already latest), no diff, no PR created, workflow green. This validates the wiring in real CI without side-effects.

…endency-update automation

Refactor both dependency-update scripts to anchor on the explicit
"# Release Date" unreleased marker instead of trying to detect where
released content starts via a strict dated-entry regex. The prior
approach failed on trailing whitespace and other date-format quirks
(root cause of PR #129).

- update-ios-deps.main.kts: rewrite appendIosChangelogEntries; add
  artifact-level duplicate protection so re-runs update bullets in
  place instead of duplicating; emit .bump-summary.txt.
- update-bom.main.kts: same anchoring refactor for updateChangelog;
  prepend a fresh unreleased section when missing (this was absent —
  the reason PR #128 polluted every released Android section); emit
  .bump-summary.txt.
- update_dependency.yml: switch branch name to patch/<TICKET>/... to
  match repo convention; pre-flight branch-collision check with a
  clear error message; include the bumps summary in the PR body under
  a ## Bumps section.

Verified locally with 21 dry-run assertions across 7 scenarios
(pathological CHANGELOG shapes, byte-exact format preservation,
duplicate re-run, workflow YAML validity).
@moe-hodor

moe-hodor Bot commented Jul 22, 2026

Copy link
Copy Markdown

🚪 Hodor is reviewing this PR... 👀

@moe-hodor moe-hodor Bot added branch:patch Weekly maintenance / support tickets (neutral CFR) cfr:neutral Change Failure Rate: neutral impact labels Jul 22, 2026
Comment thread .github/scripts/update-bom.main.kts
Comment thread .github/scripts/update-bom.main.kts
Comment thread .github/scripts/update-ios-deps.main.kts
Comment thread .github/workflows/update_dependency.yml

@moe-hodor moe-hodor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Summary

Issues (4 after filtering):
🔴 Critical: 1
💡 Suggestion: 3

Hodor filtered 9 low-signal comment(s) to reduce noise.
Verdict: REQUEST_CHANGES

@umangmoe
umangmoe merged commit dba5b8c into development Jul 24, 2026
10 checks passed
@umangmoe
umangmoe deleted the patch/MOEN-46303/dep-automation-fix branch July 24, 2026 07:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

branch:patch Weekly maintenance / support tickets (neutral CFR) cfr:neutral Change Failure Rate: neutral impact

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants