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 3245c6f commit 1edd167
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 16 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,9 @@ jobs:
--tb=no \
--capture=no \
--verbose \
--github-ci-sections \
-m integration \
--distribution ${{ matrix.distro }} \
--tools-tree-distribution ${{ matrix.tools }} \
tests/
env:
MKOSI_CI_SECTION: "github"
8 changes: 5 additions & 3 deletions tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,11 @@ def suspend_capture_stdin(pytestconfig: Any) -> Iterator[None]:


def begin_group(s: str) -> None:
print("", flush=True)
print(f"::group::{s}", flush=True)
if os.getenv("MKOSI_CI_SECTION") == "github":
print("", flush=True)
print(f"::group::{s}", flush=True)


def end_group() -> None:
print("::endgroup::", flush=True)
if os.getenv("MKOSI_CI_SECTION") == "github":
print("::endgroup::", flush=True)
14 changes: 3 additions & 11 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,6 @@ def pytest_addoption(parser: Any) -> None:
help="Pass --debug-shell when running mkosi",
action="store_true",
)
parser.addoption(
"--github-ci-sections",
help="Print GitHub Workflow section markers before and after each test",
action="store_true",
)


@pytest.fixture(scope="session")
Expand All @@ -59,9 +54,6 @@ def config(request: Any) -> Image.Config:

@pytest.fixture(autouse=True)
def github_ci_sections(request: Any) -> Any:
if request.config.getoption("--github-ci-sections"):
begin_group(request.node.name)
yield
end_group()
else:
yield
begin_group(request.node.name)
yield
end_group()
9 changes: 8 additions & 1 deletion 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
from . import Image, begin_group, end_group

pytestmark = pytest.mark.integration

Expand All @@ -40,6 +40,12 @@ 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(
f"Initrd image {config.distribution}/{config.release} using {config.tools_tree_distribution} tools tree"
)
with Image(
config,
options=[
Expand All @@ -52,6 +58,7 @@ def initrd(config: Image.Config) -> Iterator[Image]:

initrd.build()
yield initrd
end_group()


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

0 comments on commit 1edd167

Please sign in to comment.