Skip to content
Draft
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: 1 addition & 1 deletion .packit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ _:
- &copr-under-packit
job: copr_build
additional_repos:
- copr://@teemtee/stable
- copr://packit/teemtee-fmf-293

# Copr jobs under the teemtee project
- &copr-under-teemtee
Expand Down
26 changes: 13 additions & 13 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -254,16 +254,16 @@ repos:
- '--rst-directives'
- 'versionadded,versionchanged'

- repo: https://github.com/astral-sh/uv-pre-commit
rev: 0.10.9
hooks:
# Keep pyproject.toml and uv.lock in sync
- id: uv-lock
# Keep pylock.toml in sync
- id: uv-export
args:
- "--frozen"
- "--format=pylock.toml"
- "--output-file=pylock.toml"
- "--all-extras"
- "--quiet"
# - repo: https://github.com/astral-sh/uv-pre-commit
# rev: 0.10.9
# hooks:
# # Keep pyproject.toml and uv.lock in sync
# - id: uv-lock
# # Keep pylock.toml in sync
# - id: uv-export
# args:
# - "--frozen"
# - "--format=pylock.toml"
# - "--output-file=pylock.toml"
# - "--all-extras"
# - "--quiet"
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ dependencies = [
"importlib-resources; python_version < '3.12'", # MultiplexedPath is broken on earlier versions
"click>=8.0.3",
"docutils>=0.16",
"fmf>=1.7.0",
"fmf>=1.8.0",
"jinja2>=2.11.3",
"packaging>=20.9",
"pint>=0.16.1",
Expand Down
8 changes: 3 additions & 5 deletions tmt/base/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@

import fmf
import fmf.base
import fmf.context
import fmf.utils
import jsonschema
from click import confirm, echo
Expand Down Expand Up @@ -60,6 +59,7 @@
container_fields,
field,
)
from tmt.context import TmtContext
from tmt.lint import LinterOutcome, LinterReturn
from tmt.result import ResultInterpret
from tmt.utils import (
Expand Down Expand Up @@ -2387,8 +2387,7 @@ def tree(self) -> fmf.Tree:
raise tmt.utils.GeneralError("Invalid yaml syntax.") from error
# Adjust metadata for current fmf context
self._tree.adjust(
fmf.context.Context(**self.fmf_context),
case_sensitive=False,
TmtContext(**self.fmf_context),
decision_callback=create_adjust_callback(self._logger),
additional_rules=self._additional_rules,
)
Expand Down Expand Up @@ -3532,8 +3531,7 @@ def resolve_dynamic_ref(
if not plan:
raise tmt.utils.FileError("Cannot get plan fmf context to evaluate dynamic ref.")
reference_tree.adjust(
fmf.context.Context(**plan.fmf_context),
case_sensitive=False,
TmtContext(**plan.fmf_context),
decision_callback=create_adjust_callback(logger),
)
# Also temporarily build a plan so that env and context variables are expanded
Expand Down
5 changes: 2 additions & 3 deletions tmt/base/plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from typing import TYPE_CHECKING, Any, ClassVar, Optional, Union, cast

import fmf
import fmf.context
import fmf.utils
from click import echo
from fmf.utils import listed # pyright: ignore[reportUnknownVariableType]
Expand Down Expand Up @@ -47,6 +46,7 @@
)
from tmt.base.run import Run
from tmt.container import SpecBasedContainer, container, field
from tmt.context import TmtContext
from tmt.lint import LinterOutcome, LinterReturn
from tmt.utils import (
Command,
Expand Down Expand Up @@ -1530,8 +1530,7 @@ def _convert_node(node: fmf.Tree) -> 'Plan':
# Adjust the imported tree, to let any `adjust` rules defined in it take
# action, including the adjust-plans rules.
node.adjust(
fmf.context.Context(**alteration_fmf_context),
case_sensitive=False,
TmtContext(**alteration_fmf_context),
additional_rules=reference.adjust_plans,
)

Expand Down
2 changes: 2 additions & 0 deletions tmt/cli/about.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ def _render_plugins_list_rest(logger: tmt.log.Logger) -> str:
r'prepare.feature': 'prepare/feature plugins',
r'prepare.install': 'prepare/install plugins',
r'prepare.artifact.providers': 'prepare/artifact provider plugins',
r'context': 'Fmf context plugins',
r'context.distro': 'Distro context plugins',
r'step\.([a-z]+)': '{{ MATCH.group(1).capitalize() }} step plugins',
}

Expand Down
31 changes: 31 additions & 0 deletions tmt/context/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from typing import Generic, TypeVar

from fmf.context import Context, ContextDimension, DefaultContextDimension

import tmt.utils
from tmt.plugins import PluginRegistry

T = TypeVar("T")


class ContextError(tmt.utils.GeneralError):
"""
Error trying to create a context
"""


class TmtDefaultContextDimension(DefaultContextDimension):
case_sensitive = False


class TmtContextDimension(ContextDimension[T], Generic[T]):
_default_dimension_cls = TmtDefaultContextDimension
_registrar = {}


class TmtContext(Context):
_context_dimensions = TmtContextDimension


_CONTEXT_REGISTRY = PluginRegistry('context')
provides_context = _CONTEXT_REGISTRY.create_decorator()
Loading
Loading