feat: add summary to Action (#2469)
* chore: add summary to Action * refactor: new summary table * fix: fixup tests and formatting Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> * fix: pyodide missing some logging Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> * fix: nicer printout, nicer in-place summary Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> * fix: use summary for everything Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> * fix: support only one output wheel from repair Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> * Add new Github summary format * Remove a couple of humanize uses * fix: filter ANSI codes in summary Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> * fix: add sha256 Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> * fix: nicer wheel/wheels depending on how many are present Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> --------- Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> Co-authored-by: Joe Rickerby <joerick@mac.com>
This commit is contained in:
co-authored by
Joe Rickerby
parent
a2c263d4ab
commit
d0e4aded3e
@@ -6,7 +6,8 @@ from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
from cibuildwheel import __main__, architecture
|
||||
from cibuildwheel import architecture
|
||||
from cibuildwheel.logger import Logger
|
||||
from cibuildwheel.platforms import linux, macos, pyodide, windows
|
||||
from cibuildwheel.util import file
|
||||
|
||||
@@ -58,7 +59,7 @@ def disable_print_wheels(monkeypatch):
|
||||
def empty_cm(*args, **kwargs):
|
||||
yield
|
||||
|
||||
monkeypatch.setattr(__main__, "print_new_wheels", empty_cm)
|
||||
monkeypatch.setattr(Logger, "print_summary", empty_cm)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
||||
@@ -45,7 +45,7 @@ def mock_build_container(monkeypatch):
|
||||
"cibuildwheel.platforms.linux.build_in_container",
|
||||
mock.Mock(spec=platforms.linux.build_in_container),
|
||||
)
|
||||
monkeypatch.setattr("cibuildwheel.__main__.print_new_wheels", ignore_context_call)
|
||||
monkeypatch.setattr("cibuildwheel.logger.Logger.print_summary", ignore_context_call)
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_build_container", "fake_package_dir")
|
||||
|
||||
@@ -1,34 +1,39 @@
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
from cibuildwheel.__main__ import print_new_wheels
|
||||
from cibuildwheel.logger import BuildInfo, Logger
|
||||
from cibuildwheel.options import CommandLineArguments, Options
|
||||
|
||||
OPTIONS_DEFAULTS = Options("linux", CommandLineArguments.defaults(), {}, defaults=True)
|
||||
FILE = Path(__file__)
|
||||
|
||||
|
||||
def test_printout_wheels(tmp_path, capsys):
|
||||
tmp_path.joinpath("example.0").touch()
|
||||
with print_new_wheels("TEST_MSG: {n}", tmp_path):
|
||||
tmp_path.joinpath("example.1").write_bytes(b"0" * 1023)
|
||||
tmp_path.joinpath("example.2").write_bytes(b"0" * 1025)
|
||||
def test_printout_wheels(capsys):
|
||||
log = Logger()
|
||||
log.fold_mode = "disabled"
|
||||
log.colors_enabled = False
|
||||
|
||||
with log.print_summary(options=OPTIONS_DEFAULTS):
|
||||
log.summary = [
|
||||
BuildInfo(identifier="id1", filename=None, duration=3),
|
||||
BuildInfo(identifier="id2", filename=FILE, duration=2),
|
||||
]
|
||||
|
||||
captured = capsys.readouterr()
|
||||
assert captured.err == ""
|
||||
|
||||
assert "example.0" not in captured.out
|
||||
assert "example.1 1 kB\n" in captured.out
|
||||
assert "example.2 2 kB\n" in captured.out
|
||||
assert "TEST_MSG:" in captured.out
|
||||
assert "TEST_MSG: 2\n" in captured.out
|
||||
assert "id1" in captured.out
|
||||
assert "id2" in captured.out
|
||||
assert "wheels produced in" in captured.out
|
||||
assert "SHA256=" in captured.out
|
||||
|
||||
|
||||
def test_no_printout_on_error(tmp_path, capsys):
|
||||
tmp_path.joinpath("example.0").touch()
|
||||
with pytest.raises(RuntimeError), print_new_wheels("TEST_MSG: {n}", tmp_path): # noqa: PT012
|
||||
tmp_path.joinpath("example.1").touch()
|
||||
def test_no_printout_on_error(capsys):
|
||||
log = Logger()
|
||||
with pytest.raises(RuntimeError), log.print_summary(options=OPTIONS_DEFAULTS):
|
||||
raise RuntimeError()
|
||||
|
||||
captured = capsys.readouterr()
|
||||
assert captured.err == ""
|
||||
|
||||
assert "example.0" not in captured.out
|
||||
assert "example.1" not in captured.out
|
||||
assert "example.2" not in captured.out
|
||||
assert "TEST_MSG:" not in captured.out
|
||||
assert captured.out == ""
|
||||
|
||||
Reference in New Issue
Block a user