STANDARDS.md binds every repository in the NAPALM org: one default branch, Conventional Commits, the device-types contract, test-driven development, clean-code limits, a quality ratchet for existing code, packaging rules and releases by tag to PyPI. napalm-standard holds what a tool can check: the conformance check (with release rules on a tag), the quality ratchet (ported from netOrk's quality_ratchet.py), and the Gitea release from the CHANGELOG section. .gitea/workflows/driver.yml is the CI every driver calls; template/ is a new driver's starting point and passes the check as it is.
49 lines
1.1 KiB
Python
49 lines
1.1 KiB
Python
"""Release notes come from CHANGELOG.md (Keep a Changelog headings)."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from napalm_standard.changelog import changelog_section
|
|
|
|
TEXT = """\
|
|
# Changelog
|
|
|
|
## [Unreleased]
|
|
|
|
- not yet
|
|
|
|
## [1.2.0] - 2026-10-22
|
|
|
|
### Added
|
|
- Interfaces.
|
|
|
|
---
|
|
|
|
## [1.1.0] - 2026-10-01
|
|
|
|
- Facts.
|
|
"""
|
|
|
|
|
|
def test_the_section_runs_to_the_next_version_heading() -> None:
|
|
assert changelog_section(TEXT, "1.2.0") == "### Added\n- Interfaces."
|
|
|
|
|
|
def test_a_leading_v_is_ignored() -> None:
|
|
assert changelog_section(TEXT, "v1.1.0") == "- Facts."
|
|
|
|
|
|
def test_an_unknown_version_has_no_section() -> None:
|
|
assert changelog_section(TEXT, "9.9.9") is None
|
|
|
|
|
|
def test_an_empty_section_has_none() -> None:
|
|
assert changelog_section("## [1.0.0] - x\n\n## [0.9.0] - y\n- a\n", "1.0.0") is None
|
|
|
|
|
|
def test_a_heading_without_brackets_is_not_a_version_heading() -> None:
|
|
assert changelog_section("## 1.0.0\n\n- a\n", "1.0.0") is None
|
|
|
|
|
|
def test_the_last_section_runs_to_the_end() -> None:
|
|
assert changelog_section("## [1.0.0] - x\n- a\n- b", "1.0.0") == "- a\n- b"
|