diff --git a/.ci/scripts/check_changelog_snippets.py b/.ci/scripts/check_changelog_snippets.py new file mode 100755 index 000000000..5501373ea --- /dev/null +++ b/.ci/scripts/check_changelog_snippets.py @@ -0,0 +1,39 @@ +#!/bin/env python3 +# /// script +# requires-python = ">=3.11" +# dependencies = [ +# ] +# /// +import re +import sys +import tomllib +from pathlib import Path + +EXCEPTIONS = [ + ".TEMPLATE.md", + ".gitkeep", + ".gitignore", + "pulp_deb", +] + + +def snippet_valid(path: Path, changelog_exts: list[str]) -> bool: + return (path.name in EXCEPTIONS) or ( + path.suffix in changelog_exts + and (path.stem.startswith("+") or re.fullmatch(r"\d*", path.stem)) + ) + + +if __name__ == "__main__": + with Path("pyproject.toml").open("rb") as fp: + pyproject_toml = tomllib.load(fp) + try: + changelog_exts = [ + f".{item['directory']}" for item in pyproject_toml["tool"]["towncrier"]["type"] + ] + except KeyError: + changelog_exts = [".feature", ".bugfix", ".doc", ".removal", ".misc"] + matches = Path("CHANGES").rglob("*") + invalid_snippets = ", ".join(f"'{s}'" for s in matches if not snippet_valid(s, changelog_exts)) + if invalid_snippets: + sys.exit(f"LINT: Invalid changelog entries: {invalid_snippets}.") diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bf455eb87..888f978d5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -44,8 +44,9 @@ jobs: uvx twine check dist/* - name: "Install built packages" run: | + uv run .ci/scripts/calc_constraints.py -u pyproject.toml > upperbounds_constraints.txt # This seems to be the only way to inject the constraints file. - uv pip install dist/pulp_deb-*-py3-none-any.whl -c .ci/assets/ci_constraints.txt + uv pip install dist/pulp_deb-*-py3-none-any.whl -c .ci/assets/ci_constraints.txt -c upperbounds_constraints.txt - name: "Generate api specs" run: | pulpcore-manager openapi --file "api.json" diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index c2502f588..656b2a621 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -51,6 +51,10 @@ jobs: run: | ruff check + - name: "Check Changelog Snippets" + run: | + uv run .ci/scripts/check_changelog_snippets.py + - name: "Run extra lint checks" run: | [ ! -x .ci/scripts/extra_linting.sh ] || .ci/scripts/extra_linting.sh diff --git a/pulp_deb/tests/unit/test_phase_out_reminders.py b/pulp_deb/tests/unit/test_phase_out_reminders.py deleted file mode 100644 index b9f8451f1..000000000 --- a/pulp_deb/tests/unit/test_phase_out_reminders.py +++ /dev/null @@ -1,39 +0,0 @@ -"""Scheduled reminders disguised as tests — these exist to nag, not to verify behavior.""" - -from importlib.metadata import requires as pkg_requires - -from packaging.requirements import Requirement -from packaging.version import Version - - -def _pulpcore_lower_bound(): - deps = pkg_requires("pulp-deb") or [] - pulpcore_spec = next(d for d in deps if d.split(";")[0].strip().startswith("pulpcore")) - pulpcore_spec = pulpcore_spec.split(";")[0].strip() - req = Requirement(pulpcore_spec) - lower_bounds = [spec.version for spec in req.specifier if spec.operator in (">=", ">")] - if not lower_bounds: - raise ValueError(f"Could not find a lower bound in: {pulpcore_spec!r}") - return Version(max(lower_bounds, key=Version)) - - -def test_pulpcore_lower_bound_below_3_115(): - """ - This is a reminder mechanism, not a functional test. - - Once the pulpcore lower bound in pyproject.toml reaches 3.115, the - distribution/publication phase-out work tracked in - https://github.com/pulp/pulp_deb/issues/1430 should be finished and this - test should be removed. - - If this test is failing, poke Pedro (@pedro-brochado on Matrix) to complete - the phase-out and delete this test. - """ - lower_bound = _pulpcore_lower_bound() - assert lower_bound < Version("3.115"), ( - f"pulpcore lower bound is {lower_bound}, which is >= 3.115. " - "This is a reminder that the distribution/publication phase-out " - "(https://github.com/pulp/pulp_deb/issues/1430) should now be " - "completed. Poke @pedro-brochado on Matrix to finish the phase-out " - "and remove this test." - ) diff --git a/pyproject.toml b/pyproject.toml index 7f16c51eb..a4ccf8340 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -28,7 +28,7 @@ requires-python = ">=3.11" dependencies = [ # All things django and asyncio are deliberately left to pulpcore # Example transitive requirements: asgiref, asyncio, aiohttp - "pulpcore>=3.113.0,<3.130", + "pulpcore>=3.118.0,<3.130", "python-debian>=0.1.44,<0.2.0", "jsonschema>=4.6,<5.0", ]