Conversation
📝 WalkthroughWalkthroughA new GitHub Actions workflow and Python script are added to automate changelog generation from merged pull requests. The workflow triggers via manual dispatch, retrieves merged PRs for specified repositories and milestones, extracts release notes and Jira links, optionally polishes content with Claude AI, and opens a PR with the generated changelog. Changes
Sequence Diagram(s)sequenceDiagram
actor User
participant GitHub as GitHub API
participant Script as generate_changelog.py
participant Claude as Claude API
participant Docs as Docs Repo
User->>Script: Trigger workflow<br/>(milestone, version, repos)
Script->>GitHub: Look up milestone number<br/>per repository
GitHub-->>Script: Milestone ID(s)
Script->>GitHub: Fetch merged PRs<br/>for milestone
GitHub-->>Script: PR data & metadata
Script->>Script: Extract release notes<br/>from PR bodies
Script->>Script: Extract Jira links<br/>from PR references
alt Has ANTHROPIC_API_KEY
Script->>Claude: Polish release notes<br/>with AI
Claude-->>Script: Refined notes
else No API Key
Script->>Script: Format notes<br/>as bullets
end
Script->>Script: Format changelog entry<br/>(version, date, sections)
Script->>Docs: Prepend entry to<br/>CHANGELOG.md
Docs-->>Script: File updated
Script->>GitHub: Create PR on<br/>docs repo
GitHub-->>User: PR created
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Newest code from mattermost has been published to preview environment for Git SHA 9bb74c4 |
|
Newest code from mattermost has been published to preview environment for Git SHA c561a08 |
|
Newest code from mattermost has been published to preview environment for Git SHA a79aeb5 |
|
Newest code from mattermost has been published to preview environment for Git SHA 132cd17 |
There was a problem hiding this comment.
Actionable comments posted: 7
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.github/workflows/generate-changelog.yml:
- Around line 52-59: The workflow job "Generate changelog" is running the wrong
script path; update the run command to call the new location of the script
(scripts/generate_changelog.py) so the runner executes the file added in this
PR; locate the job named "Generate changelog" and change the run entry from
"python .github/scripts/generate_changelog.py" to run "python
scripts/generate_changelog.py" (or alternatively move the script into
.github/scripts if you prefer to keep the original path).
- Around line 72-76: The GH CLI invocation in the gh pr create step hard-codes
the target branch via the --base main flag; change that to use the repository's
actual default branch by replacing the literal --base main with --base ${{
github.event.repository.default_branch }} so the PR opens against the repo's
default branch at runtime (update the gh pr create command invocation).
In `@scripts/generate_changelog.py`:
- Around line 34-47: The category headings in the generated changelog are being
emitted at the same level as the release header (because the prompt asks for
`##` headings) so change the prompt/template in scripts/generate_changelog.py
where `entry` is built (it currently starts with `## {VERSION} - {today}`) so
that all subsequent category headings use `###` instead of `##` and also ensure
the prompt instructs the generator to omit any empty categories; update the
string/variable that defines the list of categories to request `### User
Interface`, `### Administration`, etc., and confirm the code that appends
categories only includes non-empty ones.
- Around line 56-68: The milestone lookup in the function that queries url =
f"https://api.github.com/repos/{repo}/milestones" only checks the first page and
must be paginated like get_merged_prs(); update the logic to follow pagination
(use resp.links.get("next") or loop incrementing params["page"]) and iterate
through every page's resp.json() checking m["title"] == title, returning
m["number"] as soon as a match is found; only after exhausting all pages should
you print the "Milestone ... not found" message and return None, reusing
HEADERS, params and the existing resp.raise_for_status() pattern.
- Around line 161-168: Wrap the API call to client.messages.create(...) in a
try-except that catches any Exception; on success continue to return
response.content[0].text.strip() as before, but on failure log the exception (or
use processLogger) and return the already-available plain bullet list of raw
notes instead (e.g., join the raw notes into "- item" lines or call the existing
fallback formatter used for missing API key/package). Apply this change around
the client.messages.create(...) call and reference the variables client,
user_message, SYSTEM_PROMPT and response when editing.
- Around line 58-59: The requests.get() calls in generate_changelog.py (the one
that assigns resp and the second at the later call) lack explicit timeouts,
which can hang CI; update both requests.get(...) invocations to include a
timeout parameter (e.g., timeout=30) so the call fails fast on unresponsive
GitHub endpoints—locate the occurrences around the resp = requests.get(url,
headers=HEADERS, params=params) assignment and the second requests.get usage and
add timeout=30 to their argument lists.
- Around line 88-91: The PR filter inside the loop over items incorrectly checks
item["pull_request"].get("merged_at") so merged PRs are never detected; update
the check to use the top-level merged_at field by replacing
item["pull_request"].get("merged_at") with item.get("merged_at") in the loop
that builds prs (variables: items, item, prs) so merged pull requests are
correctly appended.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: a02297b8-d09d-40c4-87de-647be57ab533
📒 Files selected for processing (2)
.github/workflows/generate-changelog.ymlscripts/generate_changelog.py
|
Newest code from mattermost has been published to preview environment for Git SHA 37ea628 |
|
Newest code from mattermost has been published to preview environment for Git SHA e9d880f |
|
Newest code from mattermost has been published to preview environment for Git SHA 6bb6cfc |
|
Newest code from mattermost has been published to preview environment for Git SHA 497e0c6 |
|
Newest code from mattermost has been published to preview environment for Git SHA a3cba5d |
|
@coderabbitai help |
ChatThere are 3 ways to chat with CodeRabbit:
CodeRabbit commands
Other keywords and placeholders
CodeRabbit configuration file (
|
|
@coderabbitai full review |
✅ Actions performedFull review triggered. |
|
Newest code from mattermost has been published to preview environment for Git SHA a18a89e |
There was a problem hiding this comment.
Actionable comments posted: 4
🧹 Nitpick comments (1)
.github/workflows/generate-changelog.yml (1)
49-50: Pin workflow Python dependencies for reproducible runs.Installing unpinned
requestsandanthropiccan introduce non-deterministic failures when upstream releases change behaviour.🔧 Proposed fix
- - name: Install dependencies - run: pip install requests anthropic + - name: Install dependencies + run: pip install -r .github/scripts/requirements-generate-changelog.txtYou can keep exact pins in
.github/scripts/requirements-generate-changelog.txtand update them deliberately.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.github/workflows/generate-changelog.yml around lines 49 - 50, The workflow step "Install dependencies" currently runs an unpinned pip install of requests and anthropic; change it to install pinned dependencies from the requirements file instead (e.g. replace the run command with pip install -r .github/scripts/requirements-generate-changelog.txt) and add that requirements file with exact version pins for requests and anthropic (and any other Python deps used by the changelog generator) so CI runs are reproducible; update the workflow step name "Install dependencies" if needed to reflect the pinned install.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.github/scripts/generate_changelog.py:
- Line 85: The requests.get calls (e.g., the assignment to resp using
requests.get(url, headers=HEADERS, params=params)) lack timeouts and can block;
update both occurrences (the top-level requests.get and the one inside the
pagination loop) to pass a timeout argument (e.g., timeout=10 or a defined
constant like REQUEST_TIMEOUT_SECS) and propagate that constant to both calls so
they share the same value; ensure you import or define the timeout constant near
module-level configuration and add the timeout kwarg to requests.get(...)
invocations that use HEADERS/params and the paginated requests.
- Around line 222-229: Wrap the Anthropic API call (client.messages.create(...))
and the subsequent return of response.content[0].text.strip() in a try/except
block: catch broad exceptions from network/API/unexpected response shapes, log
or print the exception, and on any failure return the existing formatted
fallback (formatted raw_notes) used elsewhere in this script; use the same
variables referenced (client, SYSTEM_PROMPT, user_message, response) and ensure
the fallback path returns a string consistent with previous fallbacks so
transient API errors do not abort changelog generation.
- Around line 115-118: The loop that builds prs is checking merged_at at the top
level (item.get("merged_at")) which is always absent; update the filter to read
the nested field item["pull_request"]["merged_at"] (or use
item.get("pull_request", {}).get("merged_at")) so the condition correctly
detects merged PRs when iterating items and appends them to prs in
generate_changelog.py.
- Around line 84-95: get_milestone_number currently fetches only the first 100
milestones and can miss matches; change it to use pagination like get_merged_prs
by introducing a page loop (e.g., page = 1; while True) and include "page" in
params (params = {"state":"all","per_page":100,"page": page}), call
requests.get/resp.raise_for_status for each page, inspect resp.json() and return
m["number"] as soon as a matching m["title"] == title is found, break/return
when the returned list is empty (no more pages), and only then print the
not-found message and return None; keep using the existing HEADERS and variable
names.
---
Nitpick comments:
In @.github/workflows/generate-changelog.yml:
- Around line 49-50: The workflow step "Install dependencies" currently runs an
unpinned pip install of requests and anthropic; change it to install pinned
dependencies from the requirements file instead (e.g. replace the run command
with pip install -r .github/scripts/requirements-generate-changelog.txt) and add
that requirements file with exact version pins for requests and anthropic (and
any other Python deps used by the changelog generator) so CI runs are
reproducible; update the workflow step name "Install dependencies" if needed to
reflect the pinned install.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: aa5e819f-edb3-4bdf-9cb4-7f90453d798b
📒 Files selected for processing (2)
.github/scripts/generate_changelog.py.github/workflows/generate-changelog.yml
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
|
Newest code from mattermost has been published to preview environment for Git SHA 5a358ff |
|
Newest code from mattermost has been published to preview environment for Git SHA 57a178f |
|
Newest code from mattermost has been published to preview environment for Git SHA 6e2cc91 |
Created with the help of Claude Cowork 🤖
Add a new workflow that:
Summary by CodeRabbit
Release Notes