Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@ and this project follows [Semantic Versioning](https://semver.org/spec/v2.0.0.ht

## [Unreleased]

### Added
- Added `python -m devr.release_preflight` to run release artifact smoke tests and validate changelog/version consistency before tagging.

## [0.1.0] - 2026-02-17

### Added
- Added `devr doctor` for environment diagnostics and setup troubleshooting.
- Added `python -m devr.release_preflight` to run release artifact smoke tests and validate changelog/version consistency before tagging.

### Changed
- Improved `devr check` diagnostics with explicit stage headers and command summaries.
Expand Down
12 changes: 12 additions & 0 deletions src/devr/release_preflight.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def changelog_versions(changelog_path: Path) -> list[str]:

def validate_changelog(changelog_path: Path, version: str) -> None:
"""Validate changelog has expected release structure for ``version``."""
changelog_text = changelog_path.read_text(encoding="utf-8")
versions = changelog_versions(changelog_path)
if not versions or versions[0] != "Unreleased":
raise ReleasePreflightError(
Expand All @@ -57,6 +58,17 @@ def validate_changelog(changelog_path: Path, version: str) -> None:
"Move completed entries from Unreleased into that release section before tagging."
)

unreleased_match = re.search(
r"^## \[Unreleased\]\s*(.*?)(?=^## \[|\Z)",
changelog_text,
flags=re.MULTILINE | re.DOTALL,
)
if unreleased_match and unreleased_match.group(1).strip():
raise ReleasePreflightError(
"CHANGELOG.md has unreleased entries. Move completed entries from "
"'Unreleased' into the current version section before tagging."
)


def run_checked(cmd: list[str], cwd: Path) -> None:
"""Run command and fail with a clear message on non-zero exit."""
Expand Down
11 changes: 11 additions & 0 deletions tests/test_release_preflight.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,17 @@ def test_validate_changelog_requires_current_version_section(tmp_path: Path) ->
validate_changelog(changelog, "0.1.0")


def test_validate_changelog_requires_empty_unreleased_section(tmp_path: Path) -> None:
changelog = tmp_path / "CHANGELOG.md"
changelog.write_text(
"## [Unreleased]\n\n### Added\n- pending item\n\n## [0.1.0] - 2026-01-01\n",
encoding="utf-8",
)

with pytest.raises(ReleasePreflightError, match="unreleased entries"):
validate_changelog(changelog, "0.1.0")


def test_changelog_versions_extracts_headings(tmp_path: Path) -> None:
changelog = tmp_path / "CHANGELOG.md"
changelog.write_text(
Expand Down