Skip to content

Commit

Permalink
Create run.yaml for tmt try (#2889)
Browse files Browse the repository at this point in the history
  • Loading branch information
skycastlelily committed Jul 31, 2024
1 parent 615b4a1 commit 67e2006
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions tmt/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3491,6 +3491,7 @@ def show_runner(self, logger: tmt.log.Logger) -> None:
def prepare_for_try(self, tree: Tree) -> None:
""" Prepare the run for the try command """
self.tree = tree
self._save_tree(self.tree)
self._workdir_load(self._workdir_path)
self.config.last_run = self.workdir
self.info(str(self.workdir), color='magenta')
Expand Down
17 changes: 17 additions & 0 deletions tmt/trying.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import tmt.templates
import tmt.utils
from tmt import Plan
from tmt.base import RunData
from tmt.utils import MetadataError, Path

USER_PLAN_NAME = "/user/plan"
Expand Down Expand Up @@ -234,6 +235,19 @@ def welcome(self) -> None:

self.print(" ".join(parts) + ".")

def save(self) -> None:
""" Save list of selected plans and enabled steps """
assert self.tree is not None # narrow type
assert self._cli_context_object is not None # narrow type
data = RunData(
root=str(self.tree.root) if self.tree.root else None,
plans=[plan.name for plan in self.plans],
steps=list(self._cli_context_object.steps),
environment=self.environment,
remove=self.opt('remove')
)
self.write(Path('run.yaml'), tmt.utils.dict_to_yaml(data.to_serialized()))

def choose_action(self) -> Action:
""" Print menu, get next action """

Expand Down Expand Up @@ -394,12 +408,15 @@ def go(self) -> None:
# Create run, prepare it for testing
run = tmt.base.Run(tree=self.tree, logger=self._logger, parent=self)
run.prepare_for_try(self.tree)
self._workdir = run.workdir
self.environment = run.environment

# Check tree, plans and tests, welcome summary
self.check_tree()
self.check_plans(run=run)
self.check_tests()
self.welcome()
self.save()

# Set the default verbosity level
for plan in self.plans:
Expand Down

0 comments on commit 67e2006

Please sign in to comment.