From 4d5e467dc9f30acf1233b6c3a4b6166bbe24ca4e Mon Sep 17 00:00:00 2001 From: Tiago Nobrega Date: Tue, 9 Apr 2024 15:40:50 -0300 Subject: [PATCH] feat(project): ubuntu@24.04 no longer requires "devel" (#531) --- rockcraft/models/project.py | 4 ++-- schema/rockcraft.json | 1 + .../plugin-python/base-2404/rockcraft.yaml | 1 - tests/unit/test_project.py | 18 ++++++++++++++---- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/rockcraft/models/project.py b/rockcraft/models/project.py index 4a8cd1460..4909c9acf 100644 --- a/rockcraft/models/project.py +++ b/rockcraft/models/project.py @@ -118,7 +118,7 @@ def _validate_platform_set(cls, values: Mapping[str, Any]) -> Mapping[str, Any]: DEPRECATED_COLON_BASES = ["ubuntu:20.04", "ubuntu:22.04"] -CURRENT_DEVEL_BASE = "ubuntu@24.04" +CURRENT_DEVEL_BASE = "ubuntu@26.04" DEVEL_BASE_WARNING = ( "The development build-base should only be used for testing purposes, " @@ -138,7 +138,7 @@ class BuildPlanner(BaseBuildPlanner): platforms: dict[str, Any] # type: ignore[reportIncompatibleVariableOverride] base: Literal["bare", "ubuntu@20.04", "ubuntu@22.04", "ubuntu@24.04"] - build_base: Literal["ubuntu@20.04", "ubuntu@22.04", "devel"] | None + build_base: Literal["ubuntu@20.04", "ubuntu@22.04", "ubuntu@24.04", "devel"] | None @pydantic.root_validator(skip_on_failure=True) @classmethod diff --git a/schema/rockcraft.json b/schema/rockcraft.json index a2dded00b..8da287eab 100644 --- a/schema/rockcraft.json +++ b/schema/rockcraft.json @@ -45,6 +45,7 @@ "enum": [ "ubuntu@20.04", "ubuntu@22.04", + "ubuntu@24.04", "devel" ], "type": "string" diff --git a/tests/spread/rockcraft/plugin-python/base-2404/rockcraft.yaml b/tests/spread/rockcraft/plugin-python/base-2404/rockcraft.yaml index 4e4455cb2..7e89daebd 100644 --- a/tests/spread/rockcraft/plugin-python/base-2404/rockcraft.yaml +++ b/tests/spread/rockcraft/plugin-python/base-2404/rockcraft.yaml @@ -1,5 +1,4 @@ name: base-2404 base: ubuntu@24.04 -build-base: devel # Remaining contents will come from "parts.yaml" diff --git a/tests/unit/test_project.py b/tests/unit/test_project.py index a17f0d784..a489ebaa3 100644 --- a/tests/unit/test_project.py +++ b/tests/unit/test_project.py @@ -97,6 +97,16 @@ pytestmark = [pytest.mark.usefixtures("enable_overlay_feature")] +class DevelProject(Project): + """A Project subclass that always accepts CURRENT_DEVEL_BASE as a "base". + + Needed because we might not have a currently supported base that is still in + "development", but we want to test the behavior anyway. + """ + + base: str # type: ignore + + @pytest.fixture() def yaml_data(): return ROCKCRAFT_YAML @@ -601,7 +611,7 @@ def test_project_generate_metadata(yaml_loaded_data): def test_metadata_base_devel(yaml_loaded_data): - yaml_loaded_data["base"] = CURRENT_DEVEL_BASE + yaml_loaded_data["base"] = "ubuntu@24.04" yaml_loaded_data["build-base"] = "devel" project = Project.unmarshal(yaml_loaded_data) @@ -727,7 +737,7 @@ def test_project_devel_base(yaml_loaded_data): yaml_loaded_data["build-base"] = "ubuntu@22.04" with pytest.raises(CraftValidationError) as err: - _ = Project.unmarshal(yaml_loaded_data) + _ = DevelProject.unmarshal(yaml_loaded_data) expected = ( f'To use the unstable base "{CURRENT_DEVEL_BASE}", ' @@ -737,7 +747,7 @@ def test_project_devel_base(yaml_loaded_data): def test_get_effective_devel_base(yaml_loaded_data): - yaml_loaded_data["base"] = CURRENT_DEVEL_BASE + yaml_loaded_data["base"] = "ubuntu@24.04" yaml_loaded_data["build-base"] = "devel" project = Project.unmarshal(yaml_loaded_data) @@ -750,6 +760,6 @@ def test_devel_base_warning(yaml_loaded_data, emitter): yaml_loaded_data["base"] = CURRENT_DEVEL_BASE yaml_loaded_data["build-base"] = "devel" del yaml_loaded_data["entrypoint-service"] - _ = Project.unmarshal(yaml_loaded_data) + _ = DevelProject.unmarshal(yaml_loaded_data) emitter.assert_message(DEVEL_BASE_WARNING)