From c4eeed967c6210fe428dea10db36db8a349c70ac Mon Sep 17 00:00:00 2001 From: rizqiamad Date: Wed, 6 May 2026 10:47:40 +0700 Subject: [PATCH 1/2] feat: recommend Snapcraft 9.x for core22, core24, and core26 bases --- snapcraft/application.py | 14 ++++++++++++++ tests/unit/test_application.py | 12 ++++++++++++ 2 files changed, 26 insertions(+) diff --git a/snapcraft/application.py b/snapcraft/application.py index b65fea747d..eb99f3d40b 100644 --- a/snapcraft/application.py +++ b/snapcraft/application.py @@ -84,6 +84,19 @@ def _get_esm_error_for_base(base: str) -> None: ) +def _get_base_warning_for_base(base: str) -> None: + """Emit a warning to use Snapcraft 9.x for core22, core24, and core26 bases.""" + match base: + case "core22" | "core24" | "core26": + emit.message( + f"Base {base!r} is supported in Snapcraft 9.x. " + "It is recommended to upgrade to Snapcraft 9.x via the 'latest/stable' channel " + "to benefit from the latest bug fixes and performance improvements." + ) + case _: + return + + class Snapcraft(Application): """Snapcraft application definition.""" @@ -174,6 +187,7 @@ def _pre_run(self, dispatcher: craft_cli.Dispatcher) -> None: ) _get_esm_error_for_base(effective_base) self._ensure_remote_build_supported(effective_base) + _get_base_warning_for_base(effective_base) super()._pre_run(dispatcher) diff --git a/tests/unit/test_application.py b/tests/unit/test_application.py index 742b4f9ace..62b696a606 100644 --- a/tests/unit/test_application.py +++ b/tests/unit/test_application.py @@ -418,6 +418,18 @@ def test_esm_pass(mocker, snapcraft_yaml, base): mock_dispatch.assert_called_once() +@pytest.mark.parametrize("base", ["core22", "core24", "core26"]) +def test_get_base_warning_for_base_emits_message(emitter, base): + """Test that _get_base_warning_for_base emits the correct message for core22, core24, and core26.""" + application._get_base_warning_for_base(base) + + emitter.assert_message( + f"Base {base!r} is supported in Snapcraft 9.x. " + "It is recommended to upgrade to Snapcraft 9.x via the 'latest/stable' channel " + "to benefit from the latest bug fixes and performance improvements." + ) + + def test_yaml_syntax_error(in_project_path, monkeypatch, capsys): """Provide a user friendly error on yaml syntax errors.""" (in_project_path / "snapcraft.yaml").write_text("bad:\nyaml") From 8808c4f8ba5171a4db40b7c09d9292831c5d5475 Mon Sep 17 00:00:00 2001 From: rizqiamad Date: Fri, 8 May 2026 06:31:36 +0700 Subject: [PATCH 2/2] fix: use emit.warning instead of emit.message --- snapcraft/application.py | 2 +- tests/unit/test_application.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/snapcraft/application.py b/snapcraft/application.py index eb99f3d40b..2ce8942361 100644 --- a/snapcraft/application.py +++ b/snapcraft/application.py @@ -88,7 +88,7 @@ def _get_base_warning_for_base(base: str) -> None: """Emit a warning to use Snapcraft 9.x for core22, core24, and core26 bases.""" match base: case "core22" | "core24" | "core26": - emit.message( + emit.warning( f"Base {base!r} is supported in Snapcraft 9.x. " "It is recommended to upgrade to Snapcraft 9.x via the 'latest/stable' channel " "to benefit from the latest bug fixes and performance improvements." diff --git a/tests/unit/test_application.py b/tests/unit/test_application.py index 62b696a606..e2e0ba3ab1 100644 --- a/tests/unit/test_application.py +++ b/tests/unit/test_application.py @@ -423,7 +423,7 @@ def test_get_base_warning_for_base_emits_message(emitter, base): """Test that _get_base_warning_for_base emits the correct message for core22, core24, and core26.""" application._get_base_warning_for_base(base) - emitter.assert_message( + emitter.assert_warning( f"Base {base!r} is supported in Snapcraft 9.x. " "It is recommended to upgrade to Snapcraft 9.x via the 'latest/stable' channel " "to benefit from the latest bug fixes and performance improvements."