diff options
author | nkozlovskiy <nmk@ydb.tech> | 2023-09-04 13:57:55 +0300 |
---|---|---|
committer | nkozlovskiy <nmk@ydb.tech> | 2023-09-04 14:18:33 +0300 |
commit | 2e98e2ce03fecaf115db4a5973a020f4a53f6931 (patch) | |
tree | b15cbc0607a7f0da25eeada985d9e48d0829974b /.github | |
parent | 0b17e1e09fcfd681baa045307cd3d96e67407238 (diff) | |
download | ydb-2e98e2ce03fecaf115db4a5973a020f4a53f6931.tar.gz |
ci: print test duration in the html reports
Diffstat (limited to '.github')
-rwxr-xr-x | .github/scripts/tests/generate-summary.py | 25 | ||||
-rw-r--r-- | .github/scripts/tests/templates/summary.html | 5 |
2 files changed, 26 insertions, 4 deletions
diff --git a/.github/scripts/tests/generate-summary.py b/.github/scripts/tests/generate-summary.py index d3f88a28b5..391572dd06 100755 --- a/.github/scripts/tests/generate-summary.py +++ b/.github/scripts/tests/generate-summary.py @@ -9,7 +9,7 @@ from github.PullRequest import PullRequest from enum import Enum from operator import attrgetter from typing import List, Optional -from jinja2 import Environment, FileSystemLoader +from jinja2 import Environment, FileSystemLoader, StrictUndefined from junit_utils import get_property_value, iter_xml_files @@ -30,6 +30,7 @@ class TestResult: name: str status: TestStatus log_url: Optional[str] + elapsed: float @property def status_display(self): @@ -41,6 +42,15 @@ class TestResult: TestStatus.MUTE: "MUTE", }[self.status] + @property + def elapsed_display(self): + m, s = divmod(self.elapsed, 60) + parts = [] + if m > 0: + parts.append(f'{int(m)}m') + parts.append(f"{s:.3f}s") + return ' '.join(parts) + def __str__(self): return f"{self.full_name:<138} {self.status_display}" @@ -51,6 +61,7 @@ class TestResult: @classmethod def from_junit(cls, testcase): classname, name = testcase.get("classname"), testcase.get("name") + if testcase.find("failure") is not None: status = TestStatus.FAIL elif testcase.find("error") is not None: @@ -61,9 +72,17 @@ class TestResult: status = TestStatus.SKIP else: status = TestStatus.PASS + log_url = get_property_value(testcase, "url:Log") + elapsed = testcase.get("time") + + try: + elapsed = float(elapsed) + except (TypeError, ValueError): + elapsed = 0 + print(f"Unable to cast elapsed time for {classname}::{name} value={elapsed!r}") - return cls(classname, name, status, log_url) + return cls(classname, name, status, log_url, elapsed) class TestSummaryLine: @@ -173,7 +192,7 @@ def render_pm(value, url, diff=None): def render_testlist_html(rows, fn): TEMPLATES_PATH = os.path.join(os.path.dirname(__file__), "templates") - env = Environment(loader=FileSystemLoader(TEMPLATES_PATH)) + env = Environment(loader=FileSystemLoader(TEMPLATES_PATH), undefined=StrictUndefined) status_test = {} has_any_log = set() diff --git a/.github/scripts/tests/templates/summary.html b/.github/scripts/tests/templates/summary.html index de292f8740..7b61709dde 100644 --- a/.github/scripts/tests/templates/summary.html +++ b/.github/scripts/tests/templates/summary.html @@ -29,7 +29,8 @@ color: blue; } table > tbody > tr > td:nth-child(2), - table > tbody > tr > td:nth-child(3) { + table > tbody > tr > td:nth-child(3), + table > tbody > tr > td:nth-child(4) { text-align: center; } </style> @@ -41,6 +42,7 @@ <thead> <tr> <th>test name</th> + <th>elapsed</th> <th>status</th> {% if status in has_any_log %} <th>LOG</th> @@ -51,6 +53,7 @@ {% for t in tests[status] %} <tr> <td>{{ t.full_name }}</td> + <td><span title="{{ t.elapsed }}s">{{ t.elapsed_display }}</span></td> <td> <span class="test_status test_{{ t.status_display }}">{{ t.status_display }}</span> </td> |