CI: make changelog automation LLM-based (Gemini) and race-safe#1082
Open
Gui-FernandesBR wants to merge 3 commits into
Open
CI: make changelog automation LLM-based (Gemini) and race-safe#1082Gui-FernandesBR wants to merge 3 commits into
Gui-FernandesBR wants to merge 3 commits into
Conversation
Member
Author
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #1082 +/- ##
===========================================
+ Coverage 82.18% 82.36% +0.18%
===========================================
Files 122 122
Lines 16355 16377 +22
===========================================
+ Hits 13441 13489 +48
+ Misses 2914 2888 -26 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
The post-merge changelog job used a blind label->prefix mapping that double-prefixed titles already carrying one (e.g. "ENH: BUG/MNT: ..."), never deduplicated, only ever used Added/Changed/Fixed, and pushed without a rebase (so it lost races with concurrent merges). Replace the inline script with .github/scripts/update_changelog.py: - Gemini (gemini-2.5-flash) formats and places the entry in the right subsection, reusing an existing prefix and avoiding duplicates. - Only the [Unreleased] block is ever rewritten; released history is preserved byte-for-byte. - Model output is validated (all existing links kept, new PR referenced exactly once, no leaked version header, bounded growth). On failure or a missing GEMINI_API_KEY it falls back to a safe deterministic insert that detects existing prefixes and skips duplicates. - Idempotent: a PR already in [Unreleased] is a no-op. - Push now rebases and retries to survive concurrent merges. Add self-contained tests (.github/scripts/test_update_changelog.py) covering the deterministic pieces; they run without network or the google-genai package. Requires a GEMINI_API_KEY repository secret; without it the job still works via the deterministic fallback. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
A live test showed gemini-2.5-flash returns 404 "no longer available to new users" for freshly created API keys, which would send every run to the deterministic fallback. Switch to the gemini-flash-latest alias so the job tracks the newest stable flash model and does not break when a pinned version is retired. Output validation still guards any drift. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributors no longer edit CHANGELOG.md by hand. Update the first-PR guide, style guide, and PR template to make clear that after a PR is merged an LLM workflow writes the entry automatically, so you only open and merge PRs. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Gui-FernandesBR
force-pushed
the
enh/llm-changelog-automation
branch
from
July 22, 2026 01:36
1ce6f94 to
c524b92
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The post-merge
Populate Changelogjob (.github/workflows/changelog.yml) used a blind label→prefix mapping inline in the workflow. It:BUG/MNT: ...) landed asENH: BUG/MNT: pre-release v1.13.0 review fixes(still visible in the v1.13.0 section).Added/Changed/Fixed, neverDeprecated/Removed/Security.develop(the "sometimes it just doesn't work").What changed
.github/scripts/update_changelog.py— the entry is now formatted and placed by Gemini (model aliasgemini-flash-latest), behind a deterministic safety net:[Unreleased]block is ever rewritten; released history is preserved byte-for-byte.[#N](url)link must survive, the new PR must be referenced exactly once, no released## [vX]header may leak in, and growth is bounded.GEMINI_API_KEY— it falls back to a safe deterministic insert that detects an existing prefix (never producingENH: BUG: ...) and skips duplicates.[Unreleased]is a no-op.changelog.yml— installsgoogle-genai, passesPR_BODY+GEMINI_API_KEY, and the push step now rebases and retries (5×) to survive concurrent merges..github/scripts/test_update_changelog.py— 13 self-contained tests of the deterministic pieces (split/reassemble, dedup, anti-double-prefix, canonical section ordering, output validator). They run without network or thegoogle-genaipackage.ruff checkandruff format --checkare clean.Docs —
docs/development/first_pr.rst,docs/development/style_guide.rst, and.github/pull_request_template.mdnow state that contributors do not editCHANGELOG.md: the LLM writes the entry after merge, so you just open and merge PRs.GEMINI_API_KEYrepository secretBefore this workflow can use Gemini, a maintainer must add the API key as a repository secret:
Settings → Secrets and variables → Actions → New repository secret — name
GEMINI_API_KEY.Without it the job still runs via the deterministic fallback (no LLM). The key is only ever read from
secrets.GEMINI_API_KEY; it is never hardcoded or logged.Notes
gemini-2.5-flashis now blocked for new API keys (returns 404 "no longer available to new users"), so the aliasgemini-flash-latestis used to track the newest stable flash model and avoid future breakage.ENH: BUG/MNT: ...line already committed in the released v1.13.0 section is left untouched (released history); can be cleaned up separately if desired.::error::) rather than corrupting the file — manual fixup needed.🤖 Generated with Claude Code