Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate support for classic changelogs (Ansible 2.9 and before) #123

Merged
merged 1 commit into from
Jun 26, 2023
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
2 changes: 2 additions & 0 deletions changelogs/fragments/123-deprecate-classic.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
deprecated_features:
- "Support for ``classic`` changelogs is deprecated and will be removed soon. If you need to build changelogs for Ansible 2.9 or before, please use an older version (https://github.com/ansible-community/antsibull-changelog/pull/123)."
2 changes: 2 additions & 0 deletions docs/changelog-configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ The default value is ``classic`` for existing configurations, and ``combined`` f

Determines whether ``changes_file`` contains only references to changelog fragments or plugins (was used internally by Ansible until version 2.9), or whether all fragments and plugin data is stored inside the file (used by Ansible 2.10 and in collections). Should never be set to ``classic``, except when using the changelog generator for Ansible 2.9 or earlier.

Note that support for ``classic`` is **DEPRECATED** and will be removed in a future release. The field will from then on be required.

``flatmap`` (optional boolean)
------------------------------

Expand Down
16 changes: 16 additions & 0 deletions src/antsibull_changelog/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import os
import sys
import traceback
import warnings
from collections.abc import Callable
from typing import Any, cast

Expand Down Expand Up @@ -576,6 +577,15 @@ def _get_version_and_codename(
return version, codename


def _check_deprecation(config: ChangelogConfig):
if config.changes_format == "classic":
warnings.warn(
"Support for 'classic' changelogs (Ansible 2.9 and before) is deprecated"
" and will soon be removed from antsibull-changelog.",
DeprecationWarning,
)


def command_release(args: Any) -> int:
"""
Add a new release to a changelog.
Expand All @@ -590,6 +600,8 @@ def command_release(args: Any) -> int:
collection_details = CollectionDetails(paths)
config = ChangelogConfig.load(paths, collection_details)

_check_deprecation(config)

load_collection_details(collection_details, args)

flatmap = _determine_flatmap(collection_details, config)
Expand Down Expand Up @@ -659,6 +671,8 @@ def command_generate(args: Any) -> int:
collection_details = CollectionDetails(paths)
config = ChangelogConfig.load(paths, collection_details)

_check_deprecation(config)

load_collection_details(collection_details, args)

flatmap = _determine_flatmap(collection_details, config)
Expand Down Expand Up @@ -699,6 +713,8 @@ def command_lint(args: Any) -> int:
paths, collection_details, ignore_is_other_project=True
)

_check_deprecation(config)

exceptions: list[tuple[str, Exception]] = []
fragments = load_fragments(paths, config, fragment_paths, exceptions)
return lint_fragments(config, fragments, exceptions)
Expand Down
28 changes: 22 additions & 6 deletions tests/functional/test_changelog_basic_ansible_classic.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from __future__ import annotations

import os
import warnings
from unittest import mock

from fixtures import ansible_changelog # noqa: F401; pylint: disable=unused-variable
Expand Down Expand Up @@ -40,13 +41,28 @@ def test_changelog_release_ansible_empty( # pylint: disable=redefined-outer-nam
)
ansible_changelog.set_plugin_cache("2.9", {})

assert (
ansible_changelog.run_tool(
"release",
["-v", "--date", "2020-01-02", "--version", "2.9", "--codename", "meow"],
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("always")

assert (
ansible_changelog.run_tool(
"release",
[
"-v",
"--date",
"2020-01-02",
"--version",
"2.9",
"--codename",
"meow",
],
)
== 0
)
== 0
)

assert len(w) == 1
assert issubclass(w[-1].category, DeprecationWarning)
assert "Support for 'classic' changelogs" in str(w[-1].message)

diff = ansible_changelog.diff()
assert diff.added_dirs == []
Expand Down