Coverage for src/bioimageio/spec/_internal/gh_utils.py: 78%
9 statements
« prev ^ index » next coverage.py v7.15.4, created at 2026-08-18 09:17 +0000
« prev ^ index » next coverage.py v7.15.4, created at 2026-08-18 09:17 +0000
1import inspect
2import os
4from loguru import logger
7def set_github_warning(title: str, message: str):
8 if (
9 not os.getenv("GITHUB_ACTIONS")
10 or (current_frame := inspect.currentframe()) is None
11 or (caller_frame := current_frame.f_back) is None
12 ):
13 # fallback to regular logging
14 logger.opt(depth=1).warning("{}: {}", title, message)
15 return
17 frameinfo = inspect.getframeinfo(caller_frame)
19 # log according to
20 # https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions#setting-a-warning-message
21 print(
22 f"::warning file={frameinfo.filename},"
23 + f"line={frameinfo.lineno},endLine={frameinfo.lineno + 1},"
24 + f"title={title}::{message}"
25 )