Skip to content

ci: validate CHANGELOG sections match base branch on PRs#72

Merged
eddietejeda merged 1 commit intomainfrom
chore/validate-changelog
Apr 29, 2026
Merged

ci: validate CHANGELOG sections match base branch on PRs#72
eddietejeda merged 1 commit intomainfrom
chore/validate-changelog

Conversation

@eddietejeda
Copy link
Copy Markdown
Contributor

Adds scripts/validate-changelog.py and a CI job (pull requests only) that fails if any ## [version] section present on the PR base branch differs from the working tree CHANGELOG.md.

This catches regressions like git-cliff dropping bullets from already-tagged releases (PR #70 review).

Adds scripts/validate-changelog.py: each ## [version] block on the base branch
must appear unchanged in CHANGELOG.md so full git-cliff regenerations cannot drop
already-shipped release notes.
@sentry
Copy link
Copy Markdown

sentry Bot commented Apr 29, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!


def main() -> None:
base = sys.argv[1] if len(sys.argv) > 1 else "origin/main"
current = Path("CHANGELOG.md").read_text()
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: read_text() is called outside the try/except, so a missing working-tree CHANGELOG.md produces a raw FileNotFoundError traceback instead of a clean error. Wrapping it gives a friendlier failure:

Suggested change
current = Path("CHANGELOG.md").read_text()
try:
current = Path("CHANGELOG.md").read_text()
except OSError as e:
print(f"error: could not read CHANGELOG.md ({e})", file=sys.stderr)
sys.exit(1)

(not blocking)

try:
base_text = git_show_changelog(base)
except subprocess.CalledProcessError as e:
print(f"error: could not read {base}:CHANGELOG.md ({e})", file=sys.stderr)
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.

super nit: str(CalledProcessError) reports the return code but drops git's stderr (e.g. "path 'CHANGELOG.md' does not exist in 'origin/main'"). Adding stderr=subprocess.PIPE to check_output and forwarding e.stderr here makes failures easier to diagnose. (not blocking)

@eddietejeda eddietejeda merged commit 6199dc0 into main Apr 29, 2026
10 checks passed
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.

1 participant