Skip to content

Commit

Permalink
fixup! ci: print group section lines for GitHub workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
behrmann committed Mar 13, 2024
1 parent 1edd167 commit 3c02468
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 22 deletions.
8 changes: 4 additions & 4 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# SPDX-License-Identifier: LGPL-2.1+

import contextlib
import os
import subprocess
import sys
Expand Down Expand Up @@ -165,12 +166,11 @@ def suspend_capture_stdin(pytestconfig: Any) -> Iterator[None]:
capmanager.resume_global_capture()


def begin_group(s: str) -> None:
@contextlib.contextmanager
def ci_group(s: str) -> Iterator[None]:
if os.getenv("MKOSI_CI_SECTION") == "github":
print("", flush=True)
print(f"::group::{s}", flush=True)


def end_group() -> None:
yield
if os.getenv("MKOSI_CI_SECTION") == "github":
print("::endgroup::", flush=True)
7 changes: 3 additions & 4 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from mkosi.config import parse_config
from mkosi.distributions import Distribution, detect_distribution

from . import Image, begin_group, end_group
from . import Image, ci_group


def pytest_addoption(parser: Any) -> None:
Expand Down Expand Up @@ -54,6 +54,5 @@ def config(request: Any) -> Image.Config:

@pytest.fixture(autouse=True)
def github_ci_sections(request: Any) -> Any:
begin_group(request.node.name)
yield
end_group()
with ci_group(request.node.name):
yield
28 changes: 14 additions & 14 deletions tests/test_initrd.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from mkosi.user import INVOKING_USER
from mkosi.versioncomp import GenericVersion

from . import Image, begin_group, end_group
from . import Image, ci_group

pytestmark = pytest.mark.integration

Expand All @@ -40,25 +40,25 @@ def passphrase() -> Iterator[Path]:

@pytest.fixture(scope="module")
def initrd(config: Image.Config) -> Iterator[Image]:
if config.tools_tree_distribution:
begin_group(f"Initrd image {config.distribution}/{config.release} (no tools tree)")
else:
begin_group(
with (
ci_group(
f"Initrd image {config.distribution}/{config.release} using {config.tools_tree_distribution} tools tree"
)
with Image(
config,
options=[
"--directory", "",
"--include=mkosi-initrd/",
],
) as initrd:
if config.tools_tree_distribution else
f"Initrd image {config.distribution}/{config.release} (no tools tree)"
),
Image(
config,
options=[
"--directory", "",
"--include=mkosi-initrd/",
],
) as initrd
):
if initrd.config.distribution == Distribution.rhel_ubi:
pytest.skip("Cannot build RHEL-UBI initrds")

initrd.build()
yield initrd
end_group()


def test_initrd(initrd: Image) -> None:
Expand Down

0 comments on commit 3c02468

Please sign in to comment.