Skip to content

Add changelog.d fragments to avoid CHANGELOG.md merge conflicts - #5967

Merged
adutra merged 1 commit into
apache:mainfrom
adutra:add-changelog-d-folder
Nov 16, 2026
Merged

adutra merged 1 commit into
apache:mainfrom
adutra:add-changelog-d-folder

Conversation

@adutra

@adutra adutra commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Almost every user-facing PR adds an entry under ## [Unreleased] in CHANGELOG.md, so those PRs regularly conflict with each other even though there is no logical conflict. #5733 narrowed when an entry is needed, but as discussed on the dev list the contention remained.

PRs now add their entries as small files under changelog.d/, and the release merges them into CHANGELOG.md.

Instead of editing CHANGELOG.md, add changelog.d/<short-title>.md: a miniature changelog with one ### <section> heading per part of the changelog, each followed by list items. Example:

### Breaking changes

- `FOO_ENABLED` now defaults to true.

### Upgrade notes

- Set `FOO_ENABLED` to false to keep the previous behavior.

Notes:

  • The policy on when to add an entry is unchanged.
  • The JetBrains changelog plugin is removed.
  • Propagation to main is manual and assumes a release cut from main. Maintenance lines need separate review.
  • Nothing detects a PR that edits [Unreleased] directly. Reviewers should watch for it.

Copilot AI balanced review requested due to automatic review settings November 3, 2026 10:41
@github-project-automation github-project-automation Bot moved this to PRs In Progress in Basic Kanban Board Nov 3, 2026

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.

🟡 Changes recommended

The RC≥1 procedure can leave cherry-picked changelog fragments unmerged, while the new fragment rewrite and deletion logic lacks regression tests for release-note integrity and failure safety.

2 open issues
What changed in this PR

This PR moves release-note contributions to individual changelog.d fragments to reduce conflicts in the shared CHANGELOG.md.

Changes:

  • Adds Gradle tasks to validate fragments and merge them into the changelog at release time.
  • Integrates validation into CI and fragment merging into the release workflow.
  • Updates contributor instructions and release guides for the fragment-based process.
File Description
site/​content/​community/​release-guides/​semi-automated-release-guide.md Describes fragment handling in release automation.
site/​content/​community/​release-guides/​manual-release-guide.md Adds manual merge commands and fragment-deletion guidance.
releasey/​libs/​_constants.sh Defines the fragment directory path.
CHANGELOG.md Directs contributors to changelog fragments.
changelog.d/​README.md Documents fragment naming, format, validation, and merging.
build.gradle.kts Registers fragment tasks and excludes fragments from license auditing.
build-logic/​src/​main/​kotlin/​changelog/​ChangelogFragments.kt Implements fragment validation, merging, and deletion.
AGENTS.md Updates agent instructions to require fragments.
.github/​workflows/​release-2-update-release-candidate.yml Merges fragments before patching and stages their deletions.
.github/​workflows/​ci.yml Adds a dedicated fragment-validation job.
.github/​pull_request_template.md Updates the changelog checklist item.

Review effort: Balanced

Comment on lines +137 to +139
changelog.writeText(lines.joinToString("\n", postfix = "\n"))
fragments.values.flatten().forEach { it.delete() }
fragmentsDirectory.get().asFile.listFiles()!!.filter { it.isDirectory }.forEach { it.delete() }

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Agree, if deleting a fragment fails, the task still reports success.
A subsequent invocation can append that fragment again.
This needs checked deletion and explicit failure reporting.
Simply throwing after deletion fails also leaves a partially completed operation, so the recovery procedure must be clear.

Mind adding a that test successful execution includes successful consumption of every included fragment; incomplete cleanup cannot silently succeed or lead operators to assume a retry is harmless?

@jbonofre
jbonofre self-requested a review November 3, 2026 10:53
Comment on lines +137 to +139
changelog.writeText(lines.joinToString("\n", postfix = "\n"))
fragments.values.flatten().forEach { it.delete() }
fragmentsDirectory.get().asFile.listFiles()!!.filter { it.isDirectory }.forEach { it.delete() }

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Agree, if deleting a fragment fails, the task still reports success.
A subsequent invocation can append that fragment again.
This needs checked deletion and explicit failure reporting.
Simply throwing after deletion fails also leaves a partially completed operation, so the recovery procedure must be clear.

Mind adding a that test successful execution includes successful consumption of every included fragment; incomplete cleanup cannot silently succeed or lead operators to assume a retry is harmless?

Comment thread changelog.d/README.md Outdated
Comment on lines +22 to +24
Pull requests do not edit `CHANGELOG.md` directly. Instead, each changelog entry is a small file
in this directory. Since two pull requests never touch the same file, changelog entries never
cause merge conflicts.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The README asserts that two PRs never touch the same file, but later explicitly permits follow-up PRs to edit or delete existing fragments. Concurrent follow-ups, filename collisions, and release deletion versus ongoing edits can still conflict.

Maybe replace with something like this?

Separate fragment files avoid conflicts caused by unrelated PRs inserting entries at the same position in CHANGELOG.md.

* Base class for tasks handling the changelog fragments in `changelog.d`, see
* `changelog.d/README.md`.
*/
@DisableCachingByDefault

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Note: this concerns build-cache reuse, not up-to-date checks (below as well).

@DisableCachingByDefault
abstract class ChangelogFragmentsTask : DefaultTask() {

@get:Internal abstract val fragmentsDirectory: DirectoryProperty

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should be @get:InputDirectory with @get:PathSensitive(PathSensitivity.RELATIVE


/** Validates the changelog fragments. */
@DisableCachingByDefault
abstract class CheckChangelogFragmentsTask : ChangelogFragmentsTask() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should get an @get:OutputFile validation report or a success marker under build/, written only after successful validation.

* changelog file, then deletes them.
*/
@DisableCachingByDefault
abstract class MergeChangelogFragmentsTask : ChangelogFragmentsTask() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This task modifies its existing changelog input and deletes its fragment inputs.

There are two options here:

  1. separate rendering into a generated file under build/ from the explicit release-time application and cleanup
  2. keep the mutation deliberately untracked and document why

The 2nd one is fine IMO - a deliberate "up-to-date-if --> false" would make that explicit.

@adutra
adutra force-pushed the add-changelog-d-folder branch from e33a0fe to a96848a Compare November 4, 2026 13:27

@youngrae81 youngrae81 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.

I tried this from the contributor side rather than the Gradle side, on the PR head, with a few real and a few deliberately broken fragments. Everything below is observed behavior.

What worked:

  • A valid fragment under new-features/ passes checkChangelogFragments; a second run is UP-TO-DATE.
  • Nine broken fragments at once (missing NN-, uppercase, three-digit priority, empty file, leading - , .txt, unknown section directory, nested directory, file at the top level) are all reported in a single run, so a contributor fixes them in one pass.
  • mergeChangelogFragments into Unreleased: entries land after the last entry of their section and before the link reference definitions, 50- sorts before 99-, a two-paragraph fragment is rendered as a proper list item with the continuation indented, and the fragments and their directories are removed. Running it again with no fragments is a no-op.
  • --release-version=1.8.0 creates the missing ### Highlights subsection in the right place; --release-version=9.9.9 fails with Section '## [9.9.9]' not found and leaves the fragments and CHANGELOG.md untouched.
  • With a read-only section directory the task fails before writing anything (Cannot delete changelog fragments, nothing was changed), as the README says.
  • :polaris-build-logic:test and integrationTest pass locally.

Two small things from the contributor's point of view, neither blocking:

  1. Open PRs that already edited CHANGELOG.md directly (mine included) will keep merging their entries into the file after this lands, and nothing flags that. A line in the PR description or README asking authors of in-flight PRs to move their entry to a fragment would help; a CI check that the Unreleased section is unchanged in a PR could follow later.
  2. Minor messages: a nested directory inside a section is reported as "file name must match NN-short-title.md", which sent me looking at the wrong thing; and the errors print absolute paths where paths relative to the project root would read better in CI logs.

fragments.values.flatten().forEach { f ->
val text = if (f.isFile) f.readText().trim() else ""
when {
!f.isFile || !FRAGMENT_NAME.matches(f.name) ->

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.

nit: a directory inside a section hits this branch and is reported as a bad file name. A separate message such as "must be a file" would point the contributor at the actual problem.

Comment thread changelog.d/README.md Outdated
is itself a nested namespace that has no stored location.
```

A change that needs entries in several sections uses one file per section. Follow-up pull requests

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.

Suggestion: mention what authors of already-open PRs should do (move the CHANGELOG.md entry into a fragment when rebasing), since nothing in check catches a direct edit to the Unreleased section.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think that belongs on the dev@ mailing list and requires some discipline from reviewers to ask for that. It's temporary, so likely not worth to be added here.

@dimas-b dimas-b 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.

Nice PR, @adutra ! The diff LGTM 👍 with one minor file header concern.

Huge +1 to the whole idea behind this PR 😉

Comment thread build.gradle.kts Outdated
excludes.add(".github/pull_request_template.md")

// Changelog fragments are plain Markdown merged into CHANGELOG.md and deleted at release time
excludes.add("changelog.d/*/**")

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.

Could we keep ASF headers in these files and trim them in the tool code?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think it's fine here, because those fragments don't get into a release ("merge" deletes them).

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.

They are present in GH, open for download to anyone 🤷 (it's not a blocker, though)

abstract val fragmentsDirectory: DirectoryProperty

/** Marker written only after the fragments have been validated successfully. */
@get:OutputFile abstract val successMarker: RegularFileProperty

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.

nit: just for my education: Gradle automatically checks this file for freshness WRT files under fragmentsDirectory, right?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Gradle needs both inputs and outputs for its "up-to-date" (and build-cache) mechanisms to work.
In this case, only the inputs matter for freshness - the output is a technical necessity.

@TaskAction
fun check() {
ChangelogFragments.collect(fragmentsDirectory.get().asFile)
successMarker.get().asFile.writeText("ok\n")

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.

nit: would it make sense to write input file paths there?.. just for human review perhaps?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

That's a good point.
If we'd want to depend on this CheckChangelogFragmentsTask in other tasks, the better option would be to construct some value that depends on the input files and their contents. I don't see a need for that now, but it's maybe worth a comment.

@orca-review-bot orca-review-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nice work. The merge is validate-first and atomic, the recovery message is clear, and the TestKit coverage of merge→patchChangelog and the RC path is reassuring. I checked the RC>0 flow: the tag is created at HEAD after the fragment merge commit, so release-3/4 see the merged changelog.

A few things outside the diff lines:

  • Syncing main after a release is manual. If the propagation PR misses a consumed fragment, the next release repeats that entry and nothing catches it. Could checkChangelogFragments flag a fragment whose text already appears in a released section? If not, can we add an explicit checklist step to the release guides?
  • Can we add a unit test shaped like the real ### Highlights section (first item right under the heading, blank lines between items)? That would pin down where appended entries land.
  • Can the PR title get a Conventional Commits prefix (build:)? And can the description link the dev-list follow-up saying the narrowed rule from #5733 wasn't enough?

🤖 AI-generated review comment — agents make mistakes, so please verify before acting on it.

val section = SECTIONS[f.name]
if (f.isDirectory && section != null) {
fragments[section] = orderFragments(f.listFiles()!!.asList())
} else if (f.name != "README.md") {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This scans the real filesystem, so anything that isn't README.md counts as an error. Git ignores *.DS_Store, but if someone opens changelog.d/ in Finder, ./gradlew check fails locally with 'unknown section' over a file they can't even see in git status. Line 76 has the same problem inside a section dir. Can we skip dotfiles in both places?

🤖 AI-generated review comment — agents make mistakes, so please verify before acting on it.

@snazy snazy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The changes LGTM now!
From my side, the mentioned comment is maybe worth to be added, but not a strict requirement from my side.

abstract val fragmentsDirectory: DirectoryProperty

/** Marker written only after the fragments have been validated successfully. */
@get:OutputFile abstract val successMarker: RegularFileProperty

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Gradle needs both inputs and outputs for its "up-to-date" (and build-cache) mechanisms to work.
In this case, only the inputs matter for freshness - the output is a technical necessity.

@TaskAction
fun check() {
ChangelogFragments.collect(fragmentsDirectory.get().asFile)
successMarker.get().asFile.writeText("ok\n")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

That's a good point.
If we'd want to depend on this CheckChangelogFragmentsTask in other tasks, the better option would be to construct some value that depends on the input files and their contents. I don't see a need for that now, but it's maybe worth a comment.

Comment thread changelog.d/README.md Outdated
is itself a nested namespace that has no stored location.
```

A change that needs entries in several sections uses one file per section. Follow-up pull requests

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think that belongs on the dev@ mailing list and requires some discipline from reviewers to ask for that. It's temporary, so likely not worth to be added here.

Comment thread build.gradle.kts Outdated
excludes.add(".github/pull_request_template.md")

// Changelog fragments are plain Markdown merged into CHANGELOG.md and deleted at release time
excludes.add("changelog.d/*/**")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think it's fine here, because those fragments don't get into a release ("merge" deletes them).

@adutra

adutra commented Nov 6, 2026

Copy link
Copy Markdown
Contributor Author

As agreed on the ML I pushed a change to simplify the fragments layout.

@dimas-b @snazy @youngrae81 PTAL again 🙏

@adutra
adutra requested review from orca-review-bot and a balanced review from Copilot November 6, 2026 09:51

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.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

6 open issues

Review effort: Lite

source "${LIBS_DIR}/_constants.sh"

# In dry-run mode nothing was merged
if [[ ${DRY_RUN:-1} -ne 1 ]] && [[ -n "$(find "$CHANGELOG_FRAGMENTS_DIR" -mindepth 1 -maxdepth 1 -type f ! -name README.md ! -name '.*')" ]]; then

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.

Both _constants.sh and exec_process in _exec.sh set DRY_RUN to 1 by default.

Comment thread changelog.d/README.md Resolved
dimas-b
dimas-b previously approved these changes Nov 6, 2026
Comment thread changelog.d/README.md Outdated
## Releasing

When a release is cut, `./gradlew mergeChangelogFragments` appends the fragments to the matching
sections of `## [Unreleased]` in `CHANGELOG.md` and deletes them, before `./gradlew patchChangelog`

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.

optional: Do we even need patchChangelog now? Our scripts could probably own CHANGELOG processes end-to-end.

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.

I guess you are right. And it's probably better to do it now rather than in a follow-up. Working on it.

@github-project-automation github-project-automation Bot moved this from PRs In Progress to Ready to merge in Basic Kanban Board Nov 6, 2026
@adutra
adutra requested review from dimas-b and snazy and a balanced review from Copilot November 9, 2026 11:11

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.

🟡 Changes recommended

The CI filter skips changelog tests for catalog-only dependency updates, and the release guides need clearer link-propagation instructions to prevent subsequent validation failures.

3 open issues
1 previously missed issue

In code that hasn't changed since last review

Medium severity Trigger changelog tests when the versions catalog changes

.github/​workflows/​ci.yml:114

Please check whether gradle/baselibs.versions.toml should also trigger this test job. build-logic/settings.gradle.kts imports that catalog and the new suites use its test dependencies, but a catalog-only pull request skips this job. Include the catalog in this filter so dependency upgrades exercise the changelog tests before merging.

4 resolved since last review

Review effort: Balanced

Comment on lines +402 to +403
Submit a PR against `main` that brings in the release section generated in `CHANGELOG.md` on the
release branch, and deletes the changelog fragments that the release consumed from `changelog.d`.

@snazy snazy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM overall, the manual release guide would benefit from one more clarification.

Otherwise, maybe update the now stale PR description.

Comment on lines +411 to +413
The PR also deletes the changelog fragments that the release consumed from `changelog.d`. Only
delete those fragments: fragments added to `main` after the release branch was created belong to
the next release.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could we qualify these instructions for the current release arrangement? A fragment may have been edited on main since branching, and a future maintenance release may consume a fragment that main still needs for its next release. Likewise, propagating an older maintenance release must not reset main's [Unreleased] comparison base.

Maybe replace this paragraph with the following, and add the same qualification to the semi-automated guide:

Suggested change
The PR also deletes the changelog fragments that the release consumed from `changelog.d`. Only
delete those fragments: fragments added to `main` after the release branch was created belong to
the next release.
These propagation steps assume a release cut from `main`, rather than an independently maintained
release line. Delete only fragments whose entries have moved into the release section on `main`;
preserve fragments added after branching, and reconcile any fragments edited on `main` since then.
For an independent maintenance release, review propagation separately: consuming a fragment there
does not mean that `main` no longer needs it. Preserve notes still needed for `main`'s next release,
and do not replace its `[Unreleased]` comparison base with an older maintenance release.

@adutra

adutra commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

LGTM overall, the manual release guide would benefit from one more clarification.

Otherwise, maybe update the now stale PR description.

Thanks for the feedback, I updated the PR description.

dimas-b
dimas-b previously approved these changes Nov 9, 2026
This was referenced Nov 17, 2026
aiskakov28 added a commit to aiskakov28/polaris that referenced this pull request Nov 17, 2026
CHANGELOG.md is no longer edited directly since apache#5967.
qlong added a commit to qlong/polaris that referenced this pull request Nov 19, 2026
CHANGELOG.md is no longer edited directly since apache#5967. Revert the
entries added to it and add them as a fragment instead, with a new
Deprecations entry for updateEntitiesPropertiesIfNotChanged.
visit2rahul added a commit to visit2rahul/polaris that referenced this pull request Nov 19, 2026
apache#5967 replaced direct CHANGELOG.md edits with fragment
files under changelog.d/, to avoid merge conflicts between unrelated
PRs editing the same section. Moves our entry there unchanged.

Per adutra's note on this PR.
visit2rahul added a commit to visit2rahul/polaris that referenced this pull request Nov 19, 2026
apache#5967 replaced direct CHANGELOG.md edits with fragment
files under changelog.d/, to avoid merge conflicts between unrelated
PRs editing the same section. Moves our entry there unchanged.

Per adutra's note on this PR.
iprithv added a commit to iprithv/polaris that referenced this pull request Nov 19, 2026
Move the Unreleased CHANGELOG entry into changelog.d after the apache#5967
fragment workflow. Keep stsEndpoint from main as its own constructor
argument so named storageName tests compile against the 8-arg DPO.

Signed-off-by: Prithvi S <[email protected]>
qlong added a commit to qlong/polaris that referenced this pull request Nov 23, 2026
CHANGELOG.md is no longer edited directly since apache#5967. Revert the
entries added to it and add them as a fragment instead, with a new
Deprecations entry for updateEntitiesPropertiesIfNotChanged.
iprithv added a commit to iprithv/polaris that referenced this pull request Nov 27, 2026
Inject the application Clock instead of System.currentTimeMillis for
soft-delete and expire. The new SPI takes Instant; persistence still
stores epoch millis on dropTimestamp / toPurgeTimestamp.

Move the release note into changelog.d after apache#5967.

Signed-off-by: Prithvi S <[email protected]>
sririshindra added a commit to sririshindra/polaris that referenced this pull request Nov 28, 2026
…dentials

Changelog entries now go in changelog.d fragments (apache#5967), so this PR's
entries move from CHANGELOG.md to changelog.d/gcp-storage-name-credentials.md.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants