|
@@ -7,7 +7,7 @@ import os
|
|
|
import tempfile
|
|
import tempfile
|
|
|
|
|
|
|
|
from contextlib import contextmanager
|
|
from contextlib import contextmanager
|
|
|
-from typing import Any, Callable, Iterable, Iterator, Literal, TypeVar, overload
|
|
|
|
|
|
|
+from typing import Any, Callable, Iterable, Iterator, TypeVar, overload
|
|
|
|
|
|
|
|
from colored import Style
|
|
from colored import Style
|
|
|
from dotenv import dotenv_values
|
|
from dotenv import dotenv_values
|
|
@@ -15,11 +15,9 @@ from dotenv import dotenv_values
|
|
|
import cipy.common
|
|
import cipy.common
|
|
|
from cipy.common import Context, Status, _validate
|
|
from cipy.common import Context, Status, _validate
|
|
|
|
|
|
|
|
-import cipy._logging as _logging
|
|
|
|
|
-
|
|
|
|
|
Action = TypeVar("Action", bound=cipy.common.Action)
|
|
Action = TypeVar("Action", bound=cipy.common.Action)
|
|
|
type Run[Action] = Callable[[Action, Context], Status]
|
|
type Run[Action] = Callable[[Action, Context], Status]
|
|
|
-type GetLines[Action] = Callable[[Action], Iterable[str]]
|
|
|
|
|
|
|
+type GetLines[Action] = Callable[[Action], str | Iterable[str]]
|
|
|
type ExtraFormatting[Action] = list[tuple[str, GetLines[Action]]]
|
|
type ExtraFormatting[Action] = list[tuple[str, GetLines[Action]]]
|
|
|
|
|
|
|
|
|
|
|
|
@@ -129,14 +127,20 @@ def preamble(
|
|
|
for key, value in inputs:
|
|
for key, value in inputs:
|
|
|
self.logger.info(" %s: %s", key, value)
|
|
self.logger.info(" %s: %s", key, value)
|
|
|
|
|
|
|
|
|
|
+ def log_extra(self: Action, color: str, lines: str | Iterable[str]) -> None:
|
|
|
|
|
+ fmt = f"{color}%s{Style.reset}"
|
|
|
|
|
+ if isinstance(lines, str):
|
|
|
|
|
+ self.logger.info(fmt, lines)
|
|
|
|
|
+ else:
|
|
|
|
|
+ for line in lines:
|
|
|
|
|
+ self.logger.info(fmt, line)
|
|
|
|
|
+
|
|
|
@functools.wraps(func)
|
|
@functools.wraps(func)
|
|
|
def wrapper(self: Action, context: Context) -> Status:
|
|
def wrapper(self: Action, context: Context) -> Status:
|
|
|
self.logger.info("##[group] Run %s", self.name)
|
|
self.logger.info("##[group] Run %s", self.name)
|
|
|
log_inputs(self)
|
|
log_inputs(self)
|
|
|
for color, get_lines in extra:
|
|
for color, get_lines in extra:
|
|
|
- fmt = f"{color}%s{Style.reset}"
|
|
|
|
|
- for line in get_lines(self):
|
|
|
|
|
- self.logger.info(fmt, line)
|
|
|
|
|
|
|
+ log_extra(self, color, get_lines(self))
|
|
|
self.logger.info("##[endgroup]")
|
|
self.logger.info("##[endgroup]")
|
|
|
return func(self, context)
|
|
return func(self, context)
|
|
|
|
|
|