-
Notifications
You must be signed in to change notification settings - Fork 664
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
Add log folds/groups/sections for CI services #2967
Conversation
73b27f4
to
5fddbb4
Compare
b6f9eb8
to
2e52642
Compare
Tested on all 3 platforms. I think this is ready to merge. |
2e52642
to
91b1490
Compare
Just noticed a straggler TODO (already done) so I rewrote history and removed it. |
@cognifloyd I cannot state how happy I am to see this implemented as I wanted to see it myself for years. Sadly my iterm does not yet support this feature and very few terminals seems to support it. i am not surprised it became popular on CI systems as doing it in HTML is quite easy. I will be happy to list this as no1 feature of 3.2 release. Still, I would like to request few changes to prepare it for the future: mainly name the feature collapsable_sections, foldable_sections or similar and avoid naming it and the classes around "CI". While the current implementation works only with few particular CI systems, it is not something unique to CI and sooner or later will be enabled for terminals too. Make it generic and we enable it when we detect a context that supports it, and do nothing when is not supported. BTW. Can you please add a comment here with expected format used by all supported systems? I looked at the code and I am not very pleased around the extra conditionals used to render these. I wonder if we can make use of rich features to implement this in a less intrusive way. In fact I am current working on https://github.com/pycontribs/enrich which will be used by molecule and maybe we can make the folding a native support of the Console class, so the application would not need to add any logic specific to particular CI systems. The application would only need to mention that a message starts a section or ends it, rending being taking case at a different level. |
Following the chain of links: More description of the propsal in #4 is at http://per.bothner.com/blog/2019/shell-integration-proposal/ So there might be escape sequences at some point that can denote the start/end of output. Terminal emulators might add support for turning that into folding or collapsible sections. Support in CI environments would also need them to support that standardized sequence. So, maybe I'll call this
Or, instead of doing a function, we can actually expand this out into a more extensible command pattern. from abc import ABC, abstractmethod
class SectionMarker(ABC):
@classmethod
@abstractmethod
def can_handle():
""""Investigate environment to see if section markers are supported."""
@abstractmethod
def start(section_id: str, title: str = None):
""""Print the start marker. title may include markers and emoji."""
@abstractmethod
def end(section_id: str):
""""Print the end marker.""" in def subcommand_markers(func):
section_marker = None
for section_marker_class in get_section_marker_classes():
if section_marker_class.can_handle():
section_marker = section_marker_class()
break
if not section_marker:
return func
@functools.wraps(func)
def section_marker_wrapper(config, subcommand):
scenario = config.scenario.name
section_marker.start(
section_id=f"{scenario}.{subcommand}",
title=f"Molecule {scenario} > {subcommand}", # for section_marker handlers that handler markers internally
title_with_markers=f"[section_title]Molecule[/] [scenario]{scenario}[/] > [action]{subcommand}[/]",
)
try:
return func(config, subcommand)
finally:
section_marker.end(section_id=f"{scenario}.{subcommand}")
@subcommand_markers
def execute_subcommand(config, subcommand): This is a lot heavier weight in terms of objects. Do we need to go this far? |
91b1490
to
916d860
Compare
Uses a function wrapper around execute_subcommand
requires handling markup, and avoid emoji, and highlighter
916d860
to
01dcc72
Compare
I switched the target branch to devel - I'm guessing this is for 3.2 and master is for 3.1? |
@cognifloyd nope. the only branch receiving patches is the default branch (master). All the others are temporary and usually deleted after merge and reused later. This explains why I was surprised seeing your PR disappearing. BTW, As you probably seen I already merged the changes to logger. Now I am looking on how to make it easy for you to hook the section feature. I wonder if anyone supports nested sections or if everyone made them at a single level. I am asking this because single level sectioning could make it easier to implement as we can keep status in/out section inside the logger and close the current section before starting another one, not forcing user to close it. |
@cognifloyd Look at https://github.com/ansible-community/molecule/pull/2975/files which I created to facilitate your change. |
Add output when molecule is running in some CI services (Travis, Github Actions, GitLab Pipelines) to make the logs easier to jump through.
This is a follow up to #2851
PR Type
CI Docs:
Screenshots and Tests
Travis CI:
Github Actions:
GitLab Pipelines:
nb: The title in GitLab has to be all one color, or it ends up with funky output.