Skip to content

Commit

Permalink
Remove prepare/install fields leaking into prepare step data (teemtee…
Browse files Browse the repository at this point in the history
…#2986)

* Remove prepare/install fields leaking into prepare step data
  • Loading branch information
happz authored and The-Mule committed Oct 14, 2024
1 parent 1ef7482 commit d8f030c
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 15 deletions.
7 changes: 7 additions & 0 deletions tmt/steps/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,9 @@ class _RawStepData(TypedDict, total=False):
how: Optional[str]
name: Optional[str]

summary: Optional[str]
order: Optional[int]


RawStepDataArgument = Union[_RawStepData, list[_RawStepData]]

Expand Down Expand Up @@ -302,6 +305,10 @@ def from_spec( # type: ignore[override]
return data


class RawWhereableStepData(TypedDict, total=False):
where: Union[str, list[str]]


@dataclasses.dataclass
class WhereableStepData:
"""
Expand Down
5 changes: 3 additions & 2 deletions tmt/steps/execute/upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
from tmt.steps.discover.fmf import DiscoverFmf, DiscoverFmfStepData, normalize_ref
from tmt.steps.execute import ExecutePlugin
from tmt.steps.execute.internal import ExecuteInternal, ExecuteInternalData
from tmt.steps.prepare import PreparePlugin, _RawPrepareStepData
from tmt.steps.prepare import PreparePlugin
from tmt.steps.prepare.install import _RawPrepareInstallStepData
from tmt.utils import Environment, EnvVarValue, Path, field

STATUS_VARIABLE = 'IN_PLACE_UPGRADE'
Expand Down Expand Up @@ -266,7 +267,7 @@ def _install_dependencies(
recommends: bool = False) -> None:
""" Install packages required/recommended for upgrade """
phase_name = 'recommended' if recommends else 'required'
data: _RawPrepareStepData = {
data: _RawPrepareInstallStepData = {
'how': 'install',
'name': f'{phase_name}-packages-upgrade',
'summary': f'Install packages {phase_name} by the upgrade',
Expand Down
15 changes: 5 additions & 10 deletions tmt/steps/prepare/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import collections
import copy
import dataclasses
from typing import (
Expand Down Expand Up @@ -48,14 +47,8 @@ class PrepareStepData(tmt.steps.WhereableStepData, tmt.steps.StepData):
PrepareStepDataT = TypeVar('PrepareStepDataT', bound=PrepareStepData)


class _RawPrepareStepData(tmt.steps._RawStepData, total=False):
where: Optional[list[str]]
package: list[str]
missing: str
roles: collections.defaultdict[str, list[str]]
hosts: dict[str, str]
order: int
summary: str
class _RawPrepareStepData(tmt.steps._RawStepData, tmt.steps.RawWhereableStepData, total=False):
pass


class PreparePlugin(tmt.steps.Plugin[PrepareStepDataT]):
Expand Down Expand Up @@ -277,6 +270,8 @@ def as_key(self) -> frozenset['tmt.base.DependencySimple']:
#
# 1. make the list of requirements unique,
# 2. group guests with same requirements.
from tmt.steps.prepare.install import _RawPrepareInstallStepData

pruned_requires: dict[frozenset[tmt.base.DependencySimple], DependencyCollection] = {}
pruned_recommends: dict[frozenset[tmt.base.DependencySimple], DependencyCollection] = {}

Expand All @@ -302,7 +297,7 @@ def as_key(self) -> frozenset['tmt.base.DependencySimple']:
if not collection.dependencies:
continue

data: _RawPrepareStepData = {
data: _RawPrepareInstallStepData = {
'how': 'install',
'name': 'requires',
'summary': 'Install required packages',
Expand Down
7 changes: 4 additions & 3 deletions tmt/steps/prepare/distgit.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
import tmt.steps.prepare
import tmt.utils
from tmt.package_managers import Package
from tmt.steps.prepare import PreparePlugin, _RawPrepareStepData
from tmt.steps.prepare import PreparePlugin
from tmt.steps.prepare.install import _RawPrepareInstallStepData
from tmt.steps.provision import Guest
from tmt.utils import Command, Path, ShellScript, field, uniq

Expand Down Expand Up @@ -53,7 +54,7 @@ def insert_to_prepare_step(
prepare_step = discover_plugin.step.plan.prepare
where = cast(tmt.steps.discover.DiscoverStepData, discover_plugin.data).where
# Future install require
data_require: _RawPrepareStepData = {
data_require: _RawPrepareInstallStepData = {
'how': 'install',
'name': 'requires (dist-git)',
'summary': 'Install required packages of tests detected by dist-git',
Expand All @@ -66,7 +67,7 @@ def insert_to_prepare_step(
prepare_step._phases.append(future_requires)

# Future install recommend
data_recommend: _RawPrepareStepData = {
data_recommend: _RawPrepareInstallStepData = {
'how': 'install',
'name': 'recommends (dist-git)',
'summary': 'Install recommended packages of tests detected by dist-git',
Expand Down
8 changes: 8 additions & 0 deletions tmt/steps/prepare/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,14 @@ def install_debuginfo(self) -> None:
'installing debuginfo packages.')


class _RawPrepareInstallStepData(tmt.steps.prepare._RawPrepareStepData, total=False):
package: Union[str, list[str]]
directory: Union[str, list[str]]
copr: Union[str, list[str]]
exclude: Union[str, list[str]]
missing: str


@dataclasses.dataclass
class PrepareInstallData(tmt.steps.prepare.PrepareStepData):
package: list[tmt.base.DependencySimple] = field(
Expand Down

0 comments on commit d8f030c

Please sign in to comment.