chore(tools): add chloggen for changelog management - #7346
Merged
Conversation
zhxiaogg
force-pushed
the
chloggen-vendor-baseline
branch
from
June 2, 2026 16:13
9468014 to
030d777
Compare
Add the chloggen changelog tool under tools/chloggen, as part of the
tools module, to manage CHANGELOG.md from per-PR entry files. The
chlog-{new,validate,preview,update} Makefile targets build and run it
from the repo root.
The code originates from OpenTelemetry chloggen (open-telemetry/
opentelemetry-go-build-tools) and is maintained directly in-tree, not
synced upstream. The Apache-2.0 LICENSE and upstream copyright headers
are retained; see tools/chloggen/FORK.md for provenance.
Changelog adoption (.chloggen config, CI, CHANGELOG migration) and the
configurable change_type change are handled separately.
zhxiaogg
force-pushed
the
chloggen-vendor-baseline
branch
from
June 2, 2026 16:23
030d777 to
bde3f79
Compare
zhxiaogg
marked this pull request as ready for review
June 2, 2026 16:38
zhxiaogg
requested review from
carles-grafana,
electron0zero,
ie-pham,
javiermolinar,
mapno,
mattdurham,
mdisibio,
oleg-kozlyuk-grafana,
ruslan-mikhailov,
stoewer,
yvrhdn and
zalegrala
as code owners
June 2, 2026 16:38
Contributor
There was a problem hiding this comment.
Pull request overview
This PR vendors the OpenTelemetry chloggen changelog generator into Tempo under tools/chloggen (as part of the tools Go module) and wires up repo-root Makefile targets intended to build/run it for managing CHANGELOG.md from per-PR YAML entry files.
Changes:
- Add the
tools/chloggenCLI (cobra-based) plus its internal config/changelog rendering logic and upstream-derived tests/testdata. - Promote
cobra,testify, andyaml.v3to direct dependencies intools/go.modto support the new tool. - Add
chlog-{new,validate,preview,update}Makefile targets that build the tool into./bin/chloggenand run it from the repo root.
Reviewed changes
Copilot reviewed 47 out of 47 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| Makefile | Adds chlog-* targets to build/run chloggen from repo root. |
| tools/go.mod | Promotes cobra, testify, and yaml.v3 to direct tool-module deps. |
| tools/chloggen/FORK.md | Documents in-tree fork status and attribution. |
| tools/chloggen/LICENSE | Adds upstream Apache-2.0 license text for the fork. |
| tools/chloggen/README.md | Adds basic usage documentation for the tool. |
| tools/chloggen/main.go | Adds the chloggen CLI entrypoint wiring to cmd.Execute(). |
| tools/chloggen/cmd/cmd_test.go | Adds cobra test harness and helper data builders. |
| tools/chloggen/cmd/new.go | Implements chloggen new (create entry file from template). |
| tools/chloggen/cmd/new_test.go | Tests new command behavior and filename sanitization. |
| tools/chloggen/cmd/root.go | Defines root cobra command, global config init, and repo root discovery. |
| tools/chloggen/cmd/root_test.go | Tests root command help/usage and repoRoot. |
| tools/chloggen/cmd/update.go | Implements chloggen update (render and write changelog updates). |
| tools/chloggen/cmd/update_test.go | Golden-file tests for update behavior across scenarios. |
| tools/chloggen/cmd/validate.go | Implements chloggen validate (validate YAML entries). |
| tools/chloggen/cmd/validate_test.go | Tests validation behavior and error accumulation. |
| tools/chloggen/cmd/testdata/.chloggen/TEMPLATE.yaml | Test-only YAML template used by command tests. |
| tools/chloggen/cmd/testdata/CHANGELOG.md | Baseline changelog input used in command tests. |
| tools/chloggen/cmd/testdata/all_change_types/CHANGELOG.md | Golden output for “all_change_types” update scenario. |
| tools/chloggen/cmd/testdata/all_change_types_alphabetical/CHANGELOG.md | Golden output verifying component sort ordering. |
| tools/chloggen/cmd/testdata/all_change_types_multiple/CHANGELOG.md | Golden output for multiple-entry update scenario. |
| tools/chloggen/cmd/testdata/breaking_only/CHANGELOG.md | Golden output for breaking-only scenario. |
| tools/chloggen/cmd/testdata/bug_fix_only/CHANGELOG.md | Golden output for bug-fix-only scenario. |
| tools/chloggen/cmd/testdata/deprecation_only/CHANGELOG.md | Golden output for deprecation-only scenario. |
| tools/chloggen/cmd/testdata/dry_run/CHANGELOG.md | Golden output baseline for dry-run scenario. |
| tools/chloggen/cmd/testdata/enhancement_only/CHANGELOG.md | Golden output for enhancement-only scenario. |
| tools/chloggen/cmd/testdata/filter_component/CHANGELOG.md | Golden output for component filter scenario. |
| tools/chloggen/cmd/testdata/filter_component_no_match/CHANGELOG.md | Golden output for “no filter match” scenario. |
| tools/chloggen/cmd/testdata/multiple_changelogs/CHANGELOG-API.md | Golden output for multi-changelog (“api”) scenario. |
| tools/chloggen/cmd/testdata/multiple_changelogs/CHANGELOG.md | Golden output for multi-changelog (“user”) scenario. |
| tools/chloggen/cmd/testdata/multiple_changelogs_multiple_defaults/CHANGELOG-API.md | Golden output for multi-defaults + multi-changelog (“api”). |
| tools/chloggen/cmd/testdata/multiple_changelogs_multiple_defaults/CHANGELOG.md | Golden output for multi-defaults + multi-changelog (“user”). |
| tools/chloggen/cmd/testdata/multiple_changelogs_single_default/CHANGELOG-API.md | Golden output for single-default + multi-changelog (“api”). |
| tools/chloggen/cmd/testdata/multiple_changelogs_single_default/CHANGELOG.md | Golden output for single-default + multi-changelog (“user”). |
| tools/chloggen/cmd/testdata/new_component_only/CHANGELOG.md | Golden output for new-component-only scenario. |
| tools/chloggen/cmd/testdata/subtext/CHANGELOG.md | Golden output for subtext formatting scenario. |
| tools/chloggen/internal/chlog/TEMPLATE.yaml | Adds default entry template used by the tool. |
| tools/chloggen/internal/chlog/entry.go | Implements entry parsing/validation and entry file discovery/deletion. |
| tools/chloggen/internal/chlog/entry_test.go | Tests entry validation and YAML file read/delete behavior. |
| tools/chloggen/internal/chlog/summary.go | Implements summary generation via Go templates (embedded default). |
| tools/chloggen/internal/chlog/summary.tmpl | Provides the embedded default summary template. |
| tools/chloggen/internal/chlog/summary_test.go | Tests summary rendering against golden files. |
| tools/chloggen/internal/chlog/testdata/CHANGELOG | Golden output file for default summary template tests. |
| tools/chloggen/internal/chlog/testdata/CHANGELOG_custom | Golden output file for custom template tests. |
| tools/chloggen/internal/chlog/testdata/custom.tmpl | Custom template used by summary tests. |
| tools/chloggen/internal/config/config.go | Implements config defaults and YAML config loading. |
| tools/chloggen/internal/config/config.yaml | Adds example/commented config file. |
| tools/chloggen/internal/config/config_test.go | Tests config defaults, path resolution, and error cases. |
Comment on lines
+69
to
+86
| cfg := &Config{} | ||
| if err = yaml.Unmarshal(cfgBytes, &cfg); err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| cfg.ConfigYAML = cfgYAML | ||
| cfg.EntriesDir = makeAbs(rootDir, cfg.EntriesDir, DefaultEntriesDir) | ||
| cfg.TemplateYAML = makeAbs(rootDir, cfg.TemplateYAML, filepath.Join(DefaultEntriesDir, DefaultTemplateYAML)) | ||
|
|
||
| if len(cfg.ChangeLogs) == 0 && len(cfg.DefaultChangeLogs) > 0 { | ||
| return nil, errors.New("cannot specify 'default_changelogs' without 'changelogs'") | ||
| } | ||
|
|
||
| if len(cfg.ChangeLogs) == 0 { | ||
| cfg.ChangeLogs[DefaultChangeLogKey] = filepath.Join(rootDir, DefaultChangeLogFilename) | ||
| cfg.DefaultChangeLogs = []string{DefaultChangeLogKey} | ||
| return cfg, nil | ||
| } |
Comment on lines
+97
to
+100
| for _, key := range cfg.DefaultChangeLogs { | ||
| if _, ok := cfg.ChangeLogs[key]; !ok { | ||
| return nil, fmt.Errorf("'default_changelogs' contains key %q which is not defined in 'changelogs'", key) | ||
| } |
Comment on lines
+134
to
+142
| if len(entry.ChangeLogs) == 0 { | ||
| for _, cl := range cfg.DefaultChangeLogs { | ||
| entries[cl] = append(entries[cl], entry) | ||
| } | ||
| } else { | ||
| for _, cl := range entry.ChangeLogs { | ||
| entries[cl] = append(entries[cl], entry) | ||
| } | ||
| } |
Comment on lines
+154
to
+163
| for _, file := range yamlFiles { | ||
| if file == cfg.TemplateYAML || file == cfg.ConfigYAML { | ||
| continue | ||
| } | ||
|
|
||
| if err := os.Remove(file); err != nil { | ||
| fmt.Printf("Failed to delete: %s\n", file) | ||
| } | ||
| } | ||
| return nil |
Comment on lines
+70
to
+73
| if dry { | ||
| cmd.Printf("Generated changelog updates for %s:", changeLogKey) | ||
| cmd.Println(chlogUpdate) | ||
| continue |
Comment on lines
+94
to
+97
| tmpMD := filename + ".tmp" | ||
| if err = os.WriteFile(filepath.Clean(tmpMD), []byte(chlogBuilder.String()), 0o600); err != nil { | ||
| return err | ||
| } |
Comment on lines
+103
to
+109
| cmd.Printf("Finished updating %s\n", filename) | ||
|
|
||
| if err = chlog.DeleteEntries(globalCfg); err != nil { | ||
| return err | ||
| } | ||
| } | ||
| return nil |
Comment on lines
+438
to
+459
| CHLOGGEN ?= $(CURDIR)/bin/chloggen | ||
| CHLOGGEN_CONFIG := .chloggen/config.yaml | ||
|
|
||
| .PHONY: $(CHLOGGEN) | ||
| $(CHLOGGEN): | ||
| cd $(CURDIR)/tools/chloggen && go build -o $(CHLOGGEN) . | ||
|
|
||
| .PHONY: chlog-new | ||
| chlog-new: $(CHLOGGEN) ## Create a new changelog entry under .chloggen/ | ||
| $(CHLOGGEN) new --config $(CHLOGGEN_CONFIG) | ||
|
|
||
| .PHONY: chlog-validate | ||
| chlog-validate: $(CHLOGGEN) ## Validate the pending changelog entries | ||
| $(CHLOGGEN) validate --config $(CHLOGGEN_CONFIG) | ||
|
|
||
| .PHONY: chlog-preview | ||
| chlog-preview: $(CHLOGGEN) ## Render the pending changelog entries to stdout | ||
| $(CHLOGGEN) update --config $(CHLOGGEN_CONFIG) --dry | ||
|
|
||
| .PHONY: chlog-update | ||
| chlog-update: $(CHLOGGEN) ## Collate pending entries into CHANGELOG.md (VERSION=vX.Y.Z) | ||
| $(CHLOGGEN) update --config $(CHLOGGEN_CONFIG) --version "$(VERSION)" |
Contributor
Author
|
will address the issues in next PR, this one is to baseline the chloggen tool codes into tempo. |
This was referenced Jun 2, 2026
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>
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.
What this PR does:
Adds the OpenTelemetry chloggen changelog tool under
tools/chloggen, as part of thetoolsmodule, to manageCHANGELOG.mdfrom per-PR entry files.toolsmodule; the only change totools/go.modis promotingcobra/testify/yaml.v3to direct dependencies.chlog-{new,validate,preview,update}Makefile targets build and run it from the repo root.LICENSEand upstream copyright headers are retained — seetools/chloggen/FORK.mdfor attribution.This is infrastructure only — changelog adoption (
.chloggenconfig, CI enforcement,CHANGELOG.mdmigration) and the configurablechange_typechange follow in separate PRs.Which issue(s) this PR fixes:
N/A
Checklist
tools/chloggen/FORK.mdCHANGELOG.mdupdated — N/A (toolingchore, no user-facing change)