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

build(deps): bump craft-application to 2.7.0 #4796

Merged
merged 3 commits into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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: 1 addition & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
attrs==23.1.0
catkin-pkg==0.5.2
click==8.1.7
craft-application==2.6.3
craft-application==2.7.0
craft-archives==1.1.3
craft-cli==2.5.1
craft-grammar==1.2.0
Expand Down
2 changes: 1 addition & 1 deletion requirements-devel.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ click==8.1.7
codespell==2.2.6
colorama==0.4.6
coverage==7.4.4
craft-application==2.6.3
craft-application==2.7.0
craft-archives==1.1.3
craft-cli==2.5.1
craft-grammar==1.2.0
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ cffi==1.16.0
chardet==5.2.0
charset-normalizer==3.3.2
click==8.1.7
craft-application==2.6.3
craft-application==2.7.0
craft-archives==1.1.3
craft-cli==2.5.1
craft-grammar==1.2.0
Expand Down
20 changes: 20 additions & 0 deletions snapcraft/models/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
from craft_grammar.models import GrammarSingleEntryDictList, GrammarStr, GrammarStrList
from craft_providers import bases
from pydantic import PrivateAttr, constr
from typing_extensions import override

from snapcraft import utils
from snapcraft.const import SUPPORTED_ARCHS, SnapArch
Expand Down Expand Up @@ -602,6 +603,25 @@ class Project(models.Project):
provenance: Optional[str]
components: Optional[Dict[ProjectName, Component]]

@override
@classmethod
def _providers_base(cls, base: str) -> bases.BaseAlias | None:
"""Get a BaseAlias from snapcraft's base.

:param base: The application-specific base name.

:returns: The BaseAlias for the base.

:raises CraftValidationError: If the project's base cannot be determined.
"""
if base == "bare":
return None

try:
return SNAPCRAFT_BASE_TO_PROVIDER_BASE[base]
except KeyError as err:
raise CraftValidationError(f"Unknown base {base!r}") from err

@pydantic.validator("plugs")
@classmethod
def _validate_plugs(cls, plugs):
Expand Down
17 changes: 16 additions & 1 deletion tests/unit/models/test_projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from craft_providers.bases import BaseName

import snapcraft.models
from snapcraft import const, errors
from snapcraft import const, errors, providers
from snapcraft.models import (
MANDATORY_ADOPTABLE_FIELDS,
Architecture,
Expand Down Expand Up @@ -585,6 +585,21 @@ def test_project_build_base_devel_grade_stable_error(self, project_yaml_data):
with pytest.raises(errors.ProjectValidationError, match=error):
Project.unmarshal(project_yaml_data(build_base="devel", grade="stable"))

@pytest.mark.parametrize(
("base", "expected_base"),
[("bare", None), *providers.SNAPCRAFT_BASE_TO_PROVIDER_BASE.items()],
)
def test_provider_base(self, base, expected_base, project_yaml_data):
providers_base = Project._providers_base(base)

assert providers_base == expected_base

def test_provider_base_error(self, project_yaml_data):
with pytest.raises(CraftValidationError) as raised:
Project._providers_base("unknown")

assert "Unknown base 'unknown'" in str(raised.value)

def test_project_global_plugs_warning(self, project_yaml_data, emitter):
data = project_yaml_data(plugs={"desktop": None, "desktop-legacy": None})
Project.unmarshal(data)
Expand Down
Loading