chore(tools): configurable chloggen change types and required entry author - #7351
Conversation
…y author
Add a 'change_types' config field (ordered list of {key, heading}) that
drives both validation and summary grouping/order, defaulting to the five
built-in change types so existing behavior is unchanged. This lets Tempo
use its own [CHANGE]/[FEATURE]/[SECURITY] taxonomy.
Add a required 'user' field on entries, rendered as a '(@handle)' suffix
in the changelog, restoring the author attribution the old format carried.
The summary model gains an ordered Groups list (custom types render via it)
while keeping the named per-type fields for backward-compatible templates.
- config: initialize ChangeLogs map when 'change_logs' is omitted (was a nil-map panic); unmarshal into *Config; correct error messages to use the actual 'change_logs'/'default_change_logs' keys. - ReadEntries: reject entries referencing a 'change_logs' key not defined in the config instead of silently creating it. - DeleteEntries: join and return removal errors instead of always nil. - update: write changelog with 0644 (not 0600); print a newline after the --dry header; delete consumed entry files once after all changelogs are written, and never in --dry mode. - Makefile: only pass --config when .chloggen/config.yaml exists, and accept FILENAME=... (chlog-new) / VERSION=... (chlog-update).
There was a problem hiding this comment.
Pull request overview
This PR evolves the in-tree tools/chloggen changelog tool to better match Tempo’s changelog taxonomy and attribution needs, while also addressing robustness and workflow issues found in the initial fork.
Changes:
- Add configurable
change_types(key + heading, ordered) to drive validation and summary grouping, with backward-compatible summary fields retained. - Require a
userfield on entries and render it as an author suffix in the generated changelog output. - Fix several operational/workflow issues (nil-map config panic, clearer config errors, reject unknown changelog keys, propagate delete errors, safer update behavior, Makefile improvements).
Reviewed changes
Copilot reviewed 26 out of 26 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tools/chloggen/internal/config/config.go | Adds change_types support and fixes config parsing defaults/error messages. |
| tools/chloggen/internal/config/config_test.go | Updates config tests and adds coverage for omitted change_logs. |
| tools/chloggen/internal/chlog/TEMPLATE.yaml | Documents new required user field in entry template. |
| tools/chloggen/internal/chlog/summary.tmpl | Switches summary rendering to iterate configured groups and appends author suffix. |
| tools/chloggen/internal/chlog/summary.go | Introduces ordered Groups model while retaining legacy per-type fields for template compatibility. |
| tools/chloggen/internal/chlog/summary_test.go | Adds test coverage for configured change type ordering and custom types. |
| tools/chloggen/internal/chlog/entry.go | Adds user, makes change types configurable for validation, rejects unknown changelog keys, and returns deletion errors. |
| tools/chloggen/internal/chlog/entry_test.go | Updates validation/template expectations for author rendering and custom change types; adds unknown changelog test. |
| tools/chloggen/cmd/validate.go | Plumbs configured change types into entry validation. |
| tools/chloggen/cmd/update.go | Adjusts dry-run output formatting, file perms, and defers entry deletion until all changelogs are written. |
| tools/chloggen/cmd/cmd_test.go | Updates cmd test fixtures to include required user. |
| tools/chloggen/cmd/testdata/subtext/CHANGELOG.md | Regenerates golden output to include author suffix. |
| tools/chloggen/cmd/testdata/new_component_only/CHANGELOG.md | Regenerates golden output to include author suffix. |
| tools/chloggen/cmd/testdata/multiple_changelogs/CHANGELOG.md | Regenerates golden output to include author suffix. |
| tools/chloggen/cmd/testdata/multiple_changelogs/CHANGELOG-API.md | Regenerates golden output to include author suffix. |
| tools/chloggen/cmd/testdata/multiple_changelogs_single_default/CHANGELOG.md | Regenerates golden output to include author suffix. |
| tools/chloggen/cmd/testdata/multiple_changelogs_single_default/CHANGELOG-API.md | Regenerates golden output to include author suffix. |
| tools/chloggen/cmd/testdata/multiple_changelogs_multiple_defaults/CHANGELOG.md | Regenerates golden output to include author suffix. |
| tools/chloggen/cmd/testdata/multiple_changelogs_multiple_defaults/CHANGELOG-API.md | Regenerates golden output to include author suffix. |
| tools/chloggen/cmd/testdata/enhancement_only/CHANGELOG.md | Regenerates golden output to include author suffix. |
| tools/chloggen/cmd/testdata/deprecation_only/CHANGELOG.md | Regenerates golden output to include author suffix. |
| tools/chloggen/cmd/testdata/bug_fix_only/CHANGELOG.md | Regenerates golden output to include author suffix. |
| tools/chloggen/cmd/testdata/breaking_only/CHANGELOG.md | Regenerates golden output to include author suffix. |
| tools/chloggen/cmd/testdata/all_change_types/CHANGELOG.md | Regenerates golden output to include author suffix. |
| tools/chloggen/cmd/testdata/all_change_types_multiple/CHANGELOG.md | Regenerates golden output to include author suffix. |
| Makefile | Makes --config conditional on file existence and adds FILENAME/VERSION passthrough. |
| if strings.TrimSpace(e.User) == "" { | ||
| errs = errors.Join(errs, fmt.Errorf("specify a 'user'")) | ||
| } |
|
Might not be worth it, but it would be very accurate, can we determine the author from the yaml file creator? Then its a field we dont have to fill in. |
Addresses review feedback on grafana#7351: - update: validate all entries (via a shared chlog.ValidateEntries helper used by both 'validate' and 'update') before rendering or deleting, so an entry with an invalid change_type can't be silently dropped from the summary and then lost when its source file is deleted. - config: fail fast in NewFromFile when 'change_types' is malformed (empty key or heading, or duplicate keys). - ReadEntries: normalize a leading '@' on 'user' so '@octocat' renders as '(@octocat)' rather than '(@@octocat)', matching the documented format.
mattdurham
left a comment
There was a problem hiding this comment.
minor comment but good
Let's do it a dumb way now, since I feel it'll get complicated when considering the backports. |
* chore(tools): add chloggen for changelog management (#7346) (cherry picked from commit 90e1d17) * chore(tools): configurable chloggen change types and required entry author (#7351) (cherry picked from commit 2e3dabb) * chore: adopt chloggen for changelog management (#7339) (cherry picked from commit f3e791f) * chore: update changelog check to include modified files (#7366) (cherry picked from commit 57897eb) * chore(chloggen): branch-name default, optional auto-filled PR, type/docs skip (#7368) (cherry picked from commit d182bec) * chore(chloggen): retarget changelog workflow to release-v2.9 Backport adaptation: the changelog workflow introduced in #7339 only runs for PRs targeting main and uses origin/main as the diff base. Point both at release-v2.9 so the check runs on backport PRs to this branch. --------- Co-authored-by: Ruslan Mikhailov <195758209+ruslan-mikhailov@users.noreply.github.com>
* chore(tools): add chloggen for changelog management (#7346) (cherry picked from commit 90e1d17) * chore(tools): configurable chloggen change types and required entry author (#7351) (cherry picked from commit 2e3dabb) * chore: adopt chloggen for changelog management (#7339) (cherry picked from commit f3e791f) * chore: update changelog check to include modified files (#7366) (cherry picked from commit 57897eb) * chore(chloggen): branch-name default, optional auto-filled PR, type/docs skip (#7368) (cherry picked from commit d182bec) * chore(chloggen): retarget changelog workflow to release-v2.10 Backport adaptation: the changelog workflow introduced in #7339 only runs for PRs targeting main and uses origin/main as the diff base. Point both at release-v2.10 so the check runs on backport PRs to this branch. --------- Co-authored-by: Ruslan Mikhailov <195758209+ruslan-mikhailov@users.noreply.github.com>
* chore(tools): add chloggen for changelog management (#7346) (cherry picked from commit 90e1d17) * chore(tools): configurable chloggen change types and required entry author (#7351) (cherry picked from commit 2e3dabb) * chore: adopt chloggen for changelog management (#7339) (cherry picked from commit f3e791f) * chore: update changelog check to include modified files (#7366) (cherry picked from commit 57897eb) * chore(chloggen): branch-name default, optional auto-filled PR, type/docs skip (#7368) (cherry picked from commit d182bec) * chore(chloggen): retarget changelog workflow to release-v3.0 Backport adaptation: the changelog workflow introduced in #7339 only runs for PRs targeting main and uses origin/main as the diff base. Point both at release-v3.0 so the check runs on backport PRs to this branch. --------- Co-authored-by: Ruslan Mikhailov <195758209+ruslan-mikhailov@users.noreply.github.com>
What this PR does:
Two commits, both scoped to the in-tree
chloggentool added in #7346:1.
feat(tools)— configurable change types + required authorchange_typesconfig (ordered{key, heading}list) drives validation and summary section grouping/order. Defaults to the built-in five, so existing behavior is unchanged — lets Tempo use its own[CHANGE]/[FEATURE]/[SECURITY]taxonomy.userfield on entries, rendered as a(@handle)suffix (restores author attribution).Groupslist (custom types render via it) while keeping the named per-type fields so backward-compatible custom templates keep working.2.
fix(tools)— addresses review feedback on #7346change_logsis omitted; correct error messages to use the real key names.ReadEntries: reject entries referencing an undefinedchange_logskey.DeleteEntries: return removal errors instead of alwaysnil.update: write changelog0644(not0600); newline after the--dryheader; delete consumed entries once after all changelogs are written, never in--dry.--configpassed only if.chloggen/config.yamlexists; acceptFILENAME=/VERSION=.Which issue(s) this PR fixes:
N/A
Checklist
CHANGELOG.mdupdated — N/A (tooling, no user-facing change)