Skip to content

Add a nightly CI job preparing the changelog for the upcoming release - #111255

Merged
alexey-milovidov merged 9 commits into
masterfrom
add-nightly-changelog-job
Jul 21, 2026
Merged

alexey-milovidov merged 9 commits into
masterfrom
add-nightly-changelog-job

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Jul 21, 2026 •

Copy link
Copy Markdown
Member

Adds a scheduled (daily) CI workflow, NightlyChangelog, that prepares and updates the changelog for the next (upcoming) release, so that at release time the changelog is already generated, edited, and reviewed incrementally instead of being produced in one big batch.

Every day the job:

  1. Generates the raw changelog entries for the pull requests newly merged into master since the previous run, using tests/ci/changelog.py inside the clickhouse/style-test container (the same invocation as create_release.yml), and inserts them into CHANGELOG.md as a block delimited by HTML-comment markers, as one commit.
  2. Edits those entries following .claude/skills/edit-changelog/SKILL.md via the codex CLI (the same agent invocation as the Code Review job), integrating them into the in-progress release section (### <a id="..."></a> ClickHouse release X.Y, FIXME (in progress)), as a separate commit — so the raw and the edited state stay individually reviewable, mirroring the manual autogenerated-then-edited commit pairs of past releases.

The result is maintained on a per-release bot branch (auto/changelog-X.Y) posted as a draft PR ("Prepare changelog for X.Y") associated with the upcoming release. The point up to which the changelog was generated is remembered as a Changelog-generated-up-to: trailer in the generate commits, and each daily run continues from that point. The first run of a cycle starts from the vX.Y.1.1-new tag that marks the cycle start on master.

Details:

  • When master moves on to the next version (release branch cut), the previous cycle's branch gets a final catch-up up to the new v*.1.1-new tag, and a fresh branch/PR is started for the new version.
  • If master's CHANGELOG.md changes under the open branch (e.g. the previous release's changelog lands), the job merges master and resolves the expected conflict structurally by re-inserting the in-progress section on top of master's file; any other conflict fails the job for manual resolution.
  • Fail-closed editing: after the agent runs, the job verifies that only CHANGELOG.md changed, the markers are gone, the in-progress section and its table-of-contents line exist, previously accumulated entries did not vanish, and the sections of already-released versions are byte-identical; otherwise it resets to the generate commit, which is still pushed so the raw entries stay visible in the draft PR and are picked up by the next run.
  • If a human closes the draft PR without merging, the job leaves that cycle alone.
  • The release manager finalizes the draft at release time: fills in the date and presentation/video links (FIXME placeholders), reviews, marks ready.

Tested locally: 37 checks covering the CHANGELOG.md text manipulation against the real file, the git flow (state-trailer round-trip, push idempotence, reconcile/structural-merge scenarios) in a scratch repository, and the edit verification; plus a real tests/ci/changelog.py dry run over the last two days of master (85 entries) fed through the insertion pipeline. python3 -m praktika yaml regenerates the committed workflow YAML byte-identically.

Changelog category (leave one):

  • CI Fix or Improvement (changelog entry is not required)

Version info

  • Merged into: 26.7.1.1307 (included in 26.7 and later)

The `NightlyChangelog` workflow runs daily. It generates the raw
changelog entries for the pull requests newly merged into `master`,
using `tests/ci/changelog.py` in the `style-test` container (the same
way `create_release.yml` runs it), and inserts them into `CHANGELOG.md`
as a marker-delimited block. Then it edits them following
`.claude/skills/edit-changelog/SKILL.md` via the `codex` CLI (the same
way the `Code Review` job runs it), integrating them into the
in-progress release section. Generation and edit are two separate
commits, mirroring the manual autogenerated-plus-edited commit pairs of
past releases.

The result is maintained on a per-release bot branch
(`auto/changelog-X.Y`) with a draft pull request that the release
manager finalizes at release time. The point up to which the changelog
was generated is remembered as a `Changelog-generated-up-to:` trailer
in the generate commits, so the next daily run continues from there.
After `master` moves on to the next version, the previous cycle's
branch gets a final catch-up, up to the `v*.1.1-new` tag that started
the new cycle.

Co-Authored-By: Claude Fable 5 <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Jul 21, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [48b7f45]

Summary: ✅


AI Review

Summary

This PR adds a scheduled NightlyChangelog workflow plus a Python job that maintains per-release changelog branches and draft PRs. Most of the fail-closed issues from earlier review rounds are fixed in the current code, but the workflow still lacks the same current-master guard that the repo already added to docs_autogen_nightly, so a manual workflow_dispatch from another branch or a rerun of an older scheduled job can still push stale changelog logic with App credentials.

Findings

⚠️ Majors

  • [ci/jobs/changelog_nightly.py:854] [dismissed by author -- https://github.com/Add a nightly CI job preparing the changelog for the upcoming release #111255#discussion_r3625301301] The job still re-authenticates and starts mutating bot branches without first proving that HEAD is the current master tip. Praktika-generated workflows expose workflow_dispatch, and reruns replay their original ref/SHA; that means an old copy of this script can keep updating auto/changelog-* branches after newer fail-closed checks land on master. The same repository already added an on_current_base_branch guard to ci/jobs/docs_autogen_nightly.py for exactly this stale-rerun hazard. Suggested fix: add the same guard before any repo mutation here, and re-run it before the final push if you want parity with docs_autogen_nightly.
Final Verdict

Status: ⚠️ Request changes

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Jul 21, 2026
Comment thread ci/jobs/changelog_nightly.py Resolved
Comment thread ci/jobs/changelog_nightly.py Resolved
Comment thread ci/jobs/changelog_nightly.py Resolved
Fix three issues found in review:

- Read the `Changelog-generated-up-to:` trailer only after fetching and
  checking out the bot branch (it was read before the fetch, when the
  remote-tracking ref does not exist in a fresh CI checkout, silently
  falling back to the cycle start tag and duplicating entries). The
  fetches now use explicit refspecs, because the CI checkout restricts
  `remote.origin.fetch` to the triggering ref, and `git log` for the
  trailer is strict. As an extra guard, `determine_from_ref` refuses to
  fall back to the cycle start tag when the branch already carries
  changelog content.
- Reset the whole worktree to HEAD (`git reset --hard`) between edit
  attempts and on final edit failure, instead of restoring only
  `CHANGELOG.md`: a rejected edit may have modified other files, and
  they must not leak into the next attempt or the next processed
  version.
- Push the bot branch with the GitHub App token and a cleared
  `http.extraheader` (the same pattern as praktika's workflow
  regeneration push) instead of the persisted `GITHUB_TOKEN`, whose
  pushes do not trigger workflow runs on the pull request.

Co-Authored-By: Claude Fable 5 <[email protected]>
Comment thread ci/jobs/changelog_nightly.py Resolved
Comment thread ci/jobs/changelog_nightly.py Resolved
- `verify_edit` and the edit cleanup are now pinned to the generate
  commit SHA captured before the editing agent runs, instead of a
  mutable `HEAD`: the agent has git access, and a commit made by it
  must not bypass the only-`CHANGELOG.md`-changed verification or
  survive the reset (it previously could ride the push of the generate
  commit to the remote unverified).
- `get_pr_states` and the `gh pr` commands are scoped to the base
  repository and filter out cross-repository pull requests: a fork PR
  with the same head branch name must not make the job think its own
  PR exists or was closed (which would suppress creating the real one
  or disable the cycle).
- Commit the test suite as `ci/tests/test_changelog_nightly.py` (run
  by the CI Tests job), including regressions for both issues above,
  the restricted-refspec fetch behavior of the CI checkout, the state
  trailer round-trip, the reconciliation merge, and the fail-closed
  edit verification.

Co-Authored-By: Claude Fable 5 <[email protected]>
Comment thread ci/jobs/changelog_nightly.py Resolved
Comment thread ci/jobs/changelog_nightly.py Resolved
…es deleted

- `verify_edit` now requires previously integrated entries to survive
  the edit: a PR link may vanish from the in-progress section only when
  the processed raw block carries revert entries, at most one deletion
  per revert (the skill deletes an old entry only when a newly arrived
  revert cancels it, and follow-up merges keep all links). Previously
  only a full wipe was rejected.
- The per-cycle skip decision is factored into `cycle_skip_reason` and
  gains a fail-closed rule: when PRs for the bot branch exist but the
  branch itself does not (deleting the branch auto-closes the PR), the
  cycle is skipped instead of silently recreating the branch from the
  cycle start against a deliberate human action.

Co-Authored-By: Claude Fable 5 <[email protected]>
Comment thread ci/jobs/changelog_nightly.py Resolved
Comment thread ci/jobs/changelog_nightly.py Resolved
robot-clickhouse and others added 2 commits July 21, 2026 18:35
- `verify_edit` now also rejects untracked files created by the editing
  agent (against a pre-edit snapshot), and `_reset_worktree` removes
  them, so they can neither violate the only-`CHANGELOG.md` contract
  nor leak into the next attempt or cycle. The job's own scratch files
  under `ci/tmp` are gitignored and unaffected.
- `reconcile_with_master` now runs for any existing changelog branch,
  not only the current cycle's, so the final catch-up of the previous
  cycle cannot push onto a stale branch when master's `CHANGELOG.md`
  changed in the meantime.

Co-Authored-By: Claude Fable 5 <[email protected]>
`git check-ignore` fails there with the dubious-ownership error because
the checkout belongs to another uid (and `safe.directory` cannot be set
from the command line by design). Assert the invariant by reading
`ci/.gitignore` instead.

Co-Authored-By: Claude Fable 5 <[email protected]>
Comment thread ci/jobs/changelog_nightly.py Resolved
Comment thread ci/jobs/changelog_nightly.py Resolved
Comment thread ci/jobs/changelog_nightly.py Resolved
…e abort

- `verify_edit` now also requires today's raw entries from the strict
  categories (everything except the junk sections the skill prunes:
  `NOT FOR CHANGELOG`, `NO CL ENTRY`, `Build/Testing/Packaging`) to
  survive into the edited file — an entry dropped by the agent would
  otherwise be lost forever, since the state trailer has already
  advanced past it. The same at-most-one-loss-per-revert allowance
  applies as for previously accumulated entries; membership is checked
  against the whole file because a PR merged into the previous release
  branch after the cycle start may already sit in a published section.
- `_untracked_files` parses `git ls-files -z` NUL-delimited output, so
  an agent-created file name with spaces cannot break verification or
  the cleanup.
- `reconcile_with_master` aborts the in-progress merge before
  propagating a structural-resolution failure, so one broken cycle
  cannot leave the repository mid-merge and poison the next cycle's
  checkout in the same run.

Co-Authored-By: Claude Fable 5 <[email protected]>
Comment thread ci/jobs/changelog_nightly.py Resolved
Comment thread ci/jobs/changelog_nightly.py Resolved
Only bullets that are reverts (a `Revert "..."`/`Reverts #N`-shaped
title, or a quoted `This reverts commit ...`) earn deletion credit —
an entry merely mentioning reverts does not. Each revert is resolved to
the PR it reverts via the `Reverts owner/repo#N` marker GitHub puts
into revert PR bodies, and a disappeared entry must match a resolved
original; only reverts without the marker (manual reverts, failed
lookups) fall back to licensing one arbitrary deletion each.

Co-Authored-By: Claude Fable 5 <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member Author

Re the third round-6 finding (ignored untracked paths invisible to _untracked_files): declining as out of contract. Paths matched by .gitignore cannot affect any git operation the job performs — checkout, merge, commit, or the refspec-scoped push — so they cannot reach the changelog branch or break the next attempt or cycle; the fail-closed contract is about state that can reach the repository, and the round-4/5 fixes cover exactly that (tracked changes, commits, non-ignored files, including names with spaces). Enumerating all ignored artifacts (build_*, tool caches) would be slow and noisy on real runners for no contract value; runner workspace hygiene between jobs is praktika's responsibility, and the editing agent's sandbox is a separate control.

Comment thread ci/jobs/changelog_nightly.py Resolved
Comment thread ci/jobs/changelog_nightly.py Resolved
An entry disappearance must now be bound to a PR that a raw-block
revert actually reverts (the `Reverts owner/repo#N` marker in the
revert PR body); a revert without the marker or with a failed lookup
no longer licenses an arbitrary deletion — verification fails closed
instead, and the raw entries stay committed for the next run.

Co-Authored-By: Claude Fable 5 <[email protected]>

@alexey-milovidov alexey-milovidov left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Sounds ok.

@alexey-milovidov alexey-milovidov self-assigned this Jul 21, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Jul 21, 2026
Merged via the queue into master with commit 146297f Jul 21, 2026
179 checks passed
@alexey-milovidov
alexey-milovidov deleted the add-nightly-changelog-job branch July 21, 2026 23:56
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Jul 22, 2026
pull Bot pushed a commit to SINHASantos/ClickHouse that referenced this pull request Aug 25, 2026
The `NightlyChangelog` job has not updated
ClickHouse#111720 since 2026-08-13: every
run since then fails with

    RuntimeError: Failed to push auto/changelog-26.8

preceded by `HTTP 401: Bad credentials` from every `gh` call in the second
half of the run.

The GitHub App installation token is valid for an hour, and a run is much
longer than that (1h12m to 1h43m in the last ten days). The job does try to
refresh it before the editing attempts and before creating the pull request,
but `GHAuth.auth` mints a token at most once per process unless `force` is
set, so those calls have always been no-ops, and there was no refresh before
the push at all. In the run of 2026-08-24 the token was minted at 02:50:30,
the first `Bad credentials` appeared at 03:47:57, and the push failed at
04:32:17.

Mint a fresh token in every step that talks to GitHub - `changelog.py`, each
editing attempt, the revert resolution of the edit verification, the push,
the pull request lookup, and the per-version processing - through a
`refresh_gh_token` helper that passes `force=True`.

What made the runs cross the one-hour mark is `prepare repository`: the CI
checkout is shallow, and `git fetch --unshallow origin` pulled the trees and
blobs of the entire history plus every branch, which took 30 to 36 minutes of
each run. The job only walks the commit graph (the range from the cycle start
tag to master), so fetch the commits without contents: `--filter=tree:0`
against the master refspec only, the same way praktika unshallows the
repository for its own jobs. The few old file versions the job does read are
fetched lazily from the promisor remote.

With the push working again, the raw entries land on the branch and the
`Changelog-generated-up-to:` trailer advances, which also ends the loop where
each night regenerated a bigger block than the night before (579 entries on
2026-08-24 instead of the usual ~50) and so took even longer.

The editing step itself has been failing its own fail-closed verification
since 2026-08-12 (`Entries disappeared in the edit without a matching
revert`), which is a separate problem: that run finished inside the hour with
a valid token. This change makes the raw entries reach the pull request again
while that is investigated.

Related: ClickHouse#111255
Related: ClickHouse#111220
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…gelog-job

Add a nightly CI job preparing the changelog for the upcoming release
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-ci pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants