-
Notifications
You must be signed in to change notification settings - Fork 259
Automate Hammer CLI release notes integration #2242
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: gh-pages
Are you sure you want to change the base?
Automate Hammer CLI release notes integration #2242
Conversation
## Background Manual integration of Hammer CLI release notes into Foreman documentation is time-consuming and error-prone. This addresses theforeman/theforeman-rel-eng#514 by automating the process through the existing release_notes.rb script. ## Expected Steps: * Extend release_notes.rb to fetch Hammer CLI and Hammer CLI - Foreman release notes * Add configurable category mapping system for maintainable transformations * Generate properly formatted sections matching existing manual structure * Maintain human oversight through script output review ## Definition of Done: * Script automatically generates Hammer CLI and Hammer CLI - Foreman sections * Category mappings are configurable and easily extensible * Output format matches existing theforeman.org manual structure * No manual copy-paste work required for Hammer CLI components 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this looks very complex and would suggest to start fresh. My recommendation would be to take https://github.com/theforeman/foreman-documentation/blob/master/guides/doc-Release_Notes/redmine_release_notes as a base. Then work on expanding that.
The first thing I would try is the trick I suggest inline with repeating v[cf_12][]
multiple time, once for each release you want to include.
It also already cleaner where category_from_issue
is already the method to extract the category from an issue. I think that's a better base then the complex mapping here.
Once you have the version in foreman-documentation working then I'd suggest to replace the script in this repo with a version that spits out markdown instead of asciidoc.
rescue StandardError => e | ||
puts "Error getting version list from #{url}: #{e}" | ||
exit 1 | ||
return nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should still exit if it fails. It may not be very clean, but it's a simple script and it's good enough error handling.
return nil | |
exit 1 |
].freeze | ||
|
||
# Category mappings and transformations | ||
CATEGORY_MAPPINGS = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is too complex. Why don't you simplify this to various separate constants?
# Rename categories - simple string replacements using regex patterns | ||
rename: { | ||
/^Hammer CLI$/ => 'Hammer CLI', # Keep as-is for base hammer-cli | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the point of this noop rename? Feels like this can just be dropped.
CATEGORY_MAPPINGS[:merge].each do |target_category, source_categories| | ||
grouped_issues[target_category] ||= [] # Initialize if doesn't exist | ||
source_categories.each do |source_category| | ||
if grouped_issues.key?(source_category) | ||
# Move issues from source to target category and remove source | ||
grouped_issues[target_category] += grouped_issues.delete(source_category) | ||
end | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feels way overengineered. The previous code was easier to understand IMHO. Now you have ~15 lines of code for what used to be 2 lines.
# Step 3: Apply general rename mappings | ||
new_grouped_issues = {} | ||
grouped_issues.each do |category, category_issues| | ||
new_category = category | ||
CATEGORY_MAPPINGS[:rename].each do |pattern, replacement| | ||
new_category = new_category.gsub(pattern, replacement) | ||
end | ||
new_grouped_issues[new_category] = category_issues | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The whole renaming isn't used so I think this can be dropped
# Step 3: Apply general rename mappings | |
new_grouped_issues = {} | |
grouped_issues.each do |category, category_issues| | |
new_category = category | |
CATEGORY_MAPPINGS[:rename].each do |pattern, replacement| | |
new_category = new_category.gsub(pattern, replacement) | |
end | |
new_grouped_issues[new_category] = category_issues | |
end |
# Project-specific category transformations | ||
project_specific: { | ||
'hammer-cli-foreman-' => { | ||
/^Hammer CLI/ => 'Hammer CLI - Foreman' | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This took me a long time to figure out and again, IMHO a bit too complex.
generate_release_notes_for_project(project_config[:project], @current_release_name, project_config[:version_prefix]) | ||
end | ||
|
||
puts "*A full list of changes in #{@current_release_name} is available via [Redmine](https://projects.theforeman.org/issues?set_filter=1&sort=id%3Adesc&status_id=closed&f[]=cf_12&op[cf_12]=%3D&v[cf_12]=#{@current_release_id})*" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is no longer true because you also need to include the Hammer releases.
'v[cf_12][]' => @current_release_id, | ||
'f[]' => 'cf_12', # Filter by custom field 12 (Fix version) | ||
'op[cf_12]' => '=', # Operator: equals | ||
'v[cf_12][]' => release_id, # Value: the release ID we want |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can repeat this parameter to gather the issues for multiple releases in a single API call. I think you can just change params
to an array of arrays and repeat v[cf12][]
for each release you want to include.
|
||
grouped_issues = gather_issues.group_by { |issue| "#{issue['project']['name']}#{ ' - ' + issue['category']['name'] if issue.key?('category') }" } | ||
# Sort categories alphabetically | ||
grouped_issues = Hash[ grouped_issues.sort_by { |key, val| key } ] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this existed before, but this can be done easier in current Ruby (probably couldn't when it was written). The version in foreman-documentation already does this.
grouped_issues = Hash[ grouped_issues.sort_by { |key, val| key } ] | |
grouped_issues = grouped_issues.sort |
Summary
scripts/release_notes.rb
Background
Manual integration of Hammer CLI release notes into Foreman documentation is time-consuming and error-prone during releases. This addresses theforeman/theforeman-rel-eng#514 by automating the process through the existing
release_notes.rb
script.Changes Made
Core Functionality
release_notes.rb
to fetch bothhammer-cli
andhammer-cli-foreman
release notes from Redminehammer-cli-3.16.0
,hammer-cli-foreman-3.16.0
)Configurable Category Mapping System
CATEGORY_MAPPINGS
Output Format
The script now automatically generates properly formatted Hammer CLI sections:
Usage
Now automatically includes Hammer CLI and Hammer CLI - Foreman sections alongside Foreman release notes.
Benefits
🤖 Generated with Claude Code