Skip to content

chore(tools): configurable chloggen change types and required entry author - #7351

Merged
zhxiaogg merged 3 commits into
grafana:mainfrom
zhxiaogg:chloggen-feat-change-types
Jun 2, 2026
Merged

chore(tools): configurable chloggen change types and required entry author#7351
zhxiaogg merged 3 commits into
grafana:mainfrom
zhxiaogg:chloggen-feat-change-types

Conversation

@zhxiaogg

@zhxiaogg zhxiaogg commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

What this PR does:

Two commits, both scoped to the in-tree chloggen tool added in #7346:

1. feat(tools) — configurable change types + required author

  • New change_types config (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.
  • New required user field on entries, rendered as a (@handle) suffix (restores author attribution).
  • Summary gains an ordered Groups list (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 #7346

  • config: fix nil-map panic when change_logs is omitted; correct error messages to use the real key names.
  • ReadEntries: reject entries referencing an undefined change_logs key.
  • DeleteEntries: return removal errors instead of always nil.
  • update: write changelog 0644 (not 0600); newline after the --dry header; delete consumed entries once after all changelogs are written, never in --dry.
  • Makefile: --config passed only if .chloggen/config.yaml exists; accept FILENAME= / VERSION=.

Which issue(s) this PR fixes:
N/A

Checklist

  • Tests updated — chloggen unit tests (new coverage for the nil-map and unknown-key fixes) + regenerated golden CHANGELOGs
  • Documentation added
  • CHANGELOG.md updated — N/A (tooling, no user-facing change)
zhxiaogg added 2 commits June 2, 2026 10:46
…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).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 user field 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.
Comment thread tools/chloggen/cmd/update.go
Comment thread tools/chloggen/internal/config/config.go
Comment on lines +121 to +123
if strings.TrimSpace(e.User) == "" {
errs = errors.Join(errs, fmt.Errorf("specify a 'user'"))
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fixed.

@mattdurham

Copy link
Copy Markdown
Contributor

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 mattdurham left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

minor comment but good

@zhxiaogg

zhxiaogg commented Jun 2, 2026

Copy link
Copy Markdown
Contributor Author

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.

Let's do it a dumb way now, since I feel it'll get complicated when considering the backports.

@zhxiaogg
zhxiaogg enabled auto-merge (squash) June 2, 2026 18:51
@zhxiaogg zhxiaogg changed the title feat(tools): configurable chloggen change types and required entry author Jun 2, 2026
@zhxiaogg
zhxiaogg merged commit 2e3dabb into grafana:main Jun 2, 2026
29 checks passed
zhxiaogg added a commit that referenced this pull request Jun 3, 2026
* 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>
zhxiaogg added a commit that referenced this pull request Jun 3, 2026
* 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>
zhxiaogg added a commit that referenced this pull request Jun 3, 2026
* 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants