ci: reduce pytest job stdout log

This commit is contained in:
igor udot (horw) 2023-10-31 19:01:40 +08:00 committed by igor.udot
parent 859d9a89e1
commit b887f476da
2 changed files with 39 additions and 2 deletions

View File

@ -448,3 +448,41 @@ def pytest_unconfigure(config: Config) -> None:
if _pytest_embedded: if _pytest_embedded:
del config.stash[IDF_PYTEST_EMBEDDED_KEY] del config.stash[IDF_PYTEST_EMBEDDED_KEY]
config.pluginmanager.unregister(_pytest_embedded) config.pluginmanager.unregister(_pytest_embedded)
dut_artifacts_url = []
@pytest.hookimpl(hookwrapper=True)
def pytest_runtest_makereport(item, call): # type: ignore
outcome = yield
report = outcome.get_result()
report.sections = []
if report.failed:
_dut = item.funcargs.get('dut')
if not _dut:
return
job_id = os.getenv('CI_JOB_ID', 0)
url = os.getenv('CI_PAGES_URL', '').replace('esp-idf', '-/esp-idf')
template = f'{url}/-/jobs/{job_id}/artifacts/pytest_embedded_log/{{}}'
logs_files = []
def get_path(x: str) -> str:
return x.split('pytest_embedded_log/', 1)[1]
if isinstance(_dut, list):
logs_files.extend([template.format(get_path(d.logfile)) for d in _dut])
dut_artifacts_url.append('{}:'.format(_dut[0].test_case_name))
else:
logs_files.append(template.format(get_path(_dut.logfile)))
dut_artifacts_url.append('{}:'.format(_dut.test_case_name))
for file in logs_files:
dut_artifacts_url.append(' - {}'.format(file))
def pytest_terminal_summary(terminalreporter, exitstatus, config): # type: ignore
if dut_artifacts_url:
terminalreporter.ensure_newline()
terminalreporter.section('Failed Test Artifacts URL', sep='-', red=True, bold=True)
terminalreporter.line('\n'.join(dut_artifacts_url))

View File

@ -5,7 +5,6 @@ python_files = pytest_*.py
# ignore PytestExperimentalApiWarning for record_xml_attribute # ignore PytestExperimentalApiWarning for record_xml_attribute
# set traceback to "short" to prevent the overwhelming tracebacks # set traceback to "short" to prevent the overwhelming tracebacks
addopts = addopts =
-s -vv
--embedded-services esp,idf --embedded-services esp,idf
--tb short --tb short
--strict-markers --strict-markers
@ -23,7 +22,7 @@ filterwarnings =
# log related # log related
log_cli = True log_cli = True
log_cli_level = INFO log_cli_level = WARNING
log_cli_format = %(asctime)s %(levelname)s %(message)s log_cli_format = %(asctime)s %(levelname)s %(message)s
log_cli_date_format = %Y-%m-%d %H:%M:%S log_cli_date_format = %Y-%m-%d %H:%M:%S