Skip to content
Snippets Groups Projects
Commit e6464f06 authored by Filippo Cremonese's avatar Filippo Cremonese
Browse files

Improved graphs, signalling if an action can run

parent 09d79c9c
No related branches found
No related tags found
No related merge requests found
from collections import OrderedDict
from loguru import logger
from typing import Set
from loguru import logger
from .util import run_script
......@@ -56,6 +57,10 @@ class Action:
"""Returns true if the action is satisfied, false if it needs to run."""
raise NotImplementedError()
def can_run(self):
"""Returns true if the action can be run (i.e. all its dependencies are satisfied)"""
return all(d.is_satisfied() for d in self.dependencies)
@property
def environment(self) -> OrderedDict:
"""Returns additional environment variables provided to the script to be run"""
......
......@@ -4,7 +4,8 @@ from ..model.configuration import Configuration
def install_subcommand(sub_argparser):
cmd_parser = sub_argparser.add_parser("graph", handler=handle_graph)
cmd_parser.add_argument("component", nargs="?")
cmd_parser.add_argument("--all-builds", action="store_true", help="Include all builds instead of only the default one.")
cmd_parser.add_argument("--all-builds", action="store_true",
help="Include all builds instead of only the default one.")
def handle_graph(args, config: Configuration):
......@@ -32,7 +33,13 @@ def print_dependencies(actions):
if action in already_visited_actions:
return
color = "green" if action.is_satisfied(recursively=True) else "red"
if action.is_satisfied(recursively=True):
color = "green"
elif action.can_run():
color = "orange"
else:
color = "red"
rows.add(f' "{action.name_for_graph}"[ shape=box, style=filled, color={color} ];')
for d in action.dependencies:
rows.add(f' "{d.name_for_graph}" -> "{action.name_for_graph}";')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment