Coverage for src / competitive_verifier / github / print.py: 91%
11 statements
« prev ^ index » next coverage.py v7.13.1, created at 2026-03-05 16:00 +0000
« prev ^ index » next coverage.py v7.13.1, created at 2026-03-05 16:00 +0000
1import pathlib
2from typing import Literal, TextIO
5def debug(message: str, *, stream: TextIO | None = None):
6 print("::debug::" + message.replace("\n", "\\n"), file=stream)
9def message(
10 command: Literal["error", "warning", "notice"],
11 message: str,
12 *,
13 title: str | None = None,
14 file: str | pathlib.Path | None = None,
15 col: int | None = None,
16 end_column: int | None = None,
17 line: int | None = None,
18 end_line: int | None = None,
19 stream: TextIO | None = None,
20) -> None:
21 """Print Github Actions style message.
23 https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions
25 Args:
26 command: Command name (e.g., "error", "warning", "debug")
27 message: Message body
28 Keyword Args:
29 title: Custom title
30 file: Filename
31 col: Column number, starting at 1
32 end_column: End column number
33 line: Line number, starting at 1
34 end_line: End line number
35 stream: Output stream
36 """
37 annotation = ",".join(
38 f"{name}={value}"
39 for name, value in (
40 ("title", title),
41 ("file", file.absolute() if isinstance(file, pathlib.Path) else file),
42 ("col", col),
43 ("endColumn", end_column),
44 ("line", line),
45 ("endLine", end_line),
46 )
47 if value is not None
48 )
50 print(f"::{command} {annotation}::{message}", file=stream)
53def begin_group(title: str, *, stream: TextIO | None = None):
54 print(f"::group::{title}", file=stream)
57def end_group(*, stream: TextIO | None = None):
58 print("::endgroup::", file=stream)