aboutsummaryrefslogtreecommitdiffstats
path: root/.github
diff options
context:
space:
mode:
authorNikita Kozlovskiy <nikitka@gmail.com>2023-08-29 20:10:26 +0300
committernkozlovskiy <nmk@ydb.tech>2023-08-30 01:44:40 +0300
commita81aa11915b2075c4c0436914432e01102271042 (patch)
tree5f937c0489f8c26d4afecf5886b9519cc2fad1be /.github
parentceceba290c64860e966669c727f88d35fd4c2f42 (diff)
downloadydb-a81aa11915b2075c4c0436914432e01102271042.tar.gz
CI: fail test log links in HTML test lists
CI: fail test log links in HTML test lists Pull Request resolved: #350
Diffstat (limited to '.github')
-rwxr-xr-x.github/scripts/tests/generate-summary.py55
-rw-r--r--.github/scripts/tests/templates/summary.html28
2 files changed, 61 insertions, 22 deletions
diff --git a/.github/scripts/tests/generate-summary.py b/.github/scripts/tests/generate-summary.py
index 1dae6aba4b..9ce5b32807 100755
--- a/.github/scripts/tests/generate-summary.py
+++ b/.github/scripts/tests/generate-summary.py
@@ -5,7 +5,7 @@ import os, sys
from enum import Enum
from itertools import groupby
from operator import attrgetter
-from typing import List
+from typing import List, Optional
from jinja2 import Environment, FileSystemLoader
from junit_utils import get_property_value, iter_xml_files
@@ -26,6 +26,7 @@ class TestResult:
classname: str
name: str
status: TestStatus
+ log_url: Optional[str]
@property
def status_display(self):
@@ -69,13 +70,27 @@ def render_testlist_html(rows, fn):
env = Environment(loader=FileSystemLoader(TEMPLATES_PATH))
- rows.sort(key=attrgetter('full_name'))
- rows.sort(key=attrgetter('status'), reverse=True)
+ status_test = {}
+ has_any_log = set()
- rows = groupby(rows, key=attrgetter('status'))
- content = env.get_template("summary.html").render(test_results=rows)
+ for t in rows:
+ status_test.setdefault(t.status, []).append(t)
+ if t.log_url:
+ has_any_log.add(t.status)
- with open(fn, 'w') as fp:
+ for status in status_test.keys():
+ status_test[status].sort(key=attrgetter("full_name"))
+
+ status_order = [TestStatus.FAIL, TestStatus.SKIP, TestStatus.MUTE, TestStatus.PASS]
+
+ # remove status group without tests
+ status_order = [s for s in status_order if s in status_test]
+
+ content = env.get_template("summary.html").render(
+ status_order=status_order, tests=status_test, has_any_log=has_any_log
+ )
+
+ with open(fn, "w") as fp:
fp.write(content)
@@ -94,7 +109,11 @@ def write_summary(lines: List[str]):
fp.close()
-def gen_summary(summary_url_prefix, summary_out_folder, paths, ):
+def gen_summary(
+ summary_url_prefix,
+ summary_out_folder,
+ paths,
+):
summary = [
"| | TESTS | PASSED | ERRORS | FAILED | SKIPPED | MUTED[^1] |",
"| :--- | ---: | -----: | -----: | -----: | ------: | ----: |",
@@ -123,10 +142,12 @@ def gen_summary(summary_url_prefix, summary_out_folder, paths, ):
passed += 1
status = TestStatus.PASS
- test_result = TestResult(classname=classname, name=name, status=status)
+ log_url = get_property_value(case, "url:Log")
+
+ test_result = TestResult(classname=classname, name=name, status=status, log_url=log_url)
test_results.append(test_result)
- report_url = f'{summary_url_prefix}{html_fn}'
+ report_url = f"{summary_url_prefix}{html_fn}"
render_testlist_html(test_results, os.path.join(summary_out_folder, html_fn))
@@ -134,18 +155,18 @@ def gen_summary(summary_url_prefix, summary_out_folder, paths, ):
" | ".join(
[
title,
- render_pm(tests, f'{report_url}', 0),
- render_pm(passed, f'{report_url}#PASS', 0),
- render_pm(errors, f'{report_url}#ERROR', 0),
- render_pm(failed, f'{report_url}#FAIL', 0),
- render_pm(skipped, f'{report_url}#SKIP', 0),
- render_pm(muted, f'{report_url}#MUTE', 0),
+ render_pm(tests, f"{report_url}", 0),
+ render_pm(passed, f"{report_url}#PASS", 0),
+ render_pm(errors, f"{report_url}#ERROR", 0),
+ render_pm(failed, f"{report_url}#FAIL", 0),
+ render_pm(skipped, f"{report_url}#SKIP", 0),
+ render_pm(muted, f"{report_url}#MUTE", 0),
]
)
)
- github_srv = os.environ.get('GITHUB_SERVER_URL', 'https://github.com')
- repo = os.environ.get('GITHUB_REPOSITORY', 'ydb-platform/ydb')
+ github_srv = os.environ.get("GITHUB_SERVER_URL", "https://github.com")
+ repo = os.environ.get("GITHUB_REPOSITORY", "ydb-platform/ydb")
summary.append("\n")
summary.append(f"[^1]: All mute rules are defined [here]({github_srv}/{repo}/tree/main/.github/config).")
diff --git a/.github/scripts/tests/templates/summary.html b/.github/scripts/tests/templates/summary.html
index 7098edaf13..de292f8740 100644
--- a/.github/scripts/tests/templates/summary.html
+++ b/.github/scripts/tests/templates/summary.html
@@ -28,23 +28,41 @@
span.test_mute {
color: blue;
}
+ table > tbody > tr > td:nth-child(2),
+ table > tbody > tr > td:nth-child(3) {
+ text-align: center;
+ }
</style>
</head>
<body>
-{% for status, rows in test_results %}
-<h1 id="{{ status.name}}">{{ status.name }}</h1>
-<table style="width:90%;" border="1">
+{% for status in status_order %}
+<h1 id="{{ status.name}}">{{ status.name }} ({{ tests[status] | length }})</h1>
+<table style="width:100%;" border="1">
<thead>
<tr>
<th>test name</th>
<th>status</th>
+ {% if status in has_any_log %}
+ <th>LOG</th>
+ {% endif %}
</tr>
</thead>
<tbody>
- {% for t in rows %}
+ {% for t in tests[status] %}
<tr>
<td>{{ t.full_name }}</td>
- <td><span class="test_status test_{{ t.status_display }}">{{ t.status_display }}</span></td>
+ <td>
+ <span class="test_status test_{{ t.status_display }}">{{ t.status_display }}</span>
+ </td>
+ {% if status in has_any_log %}
+ <td>
+ {% if t.log_url %}
+ <a href="{{ t.log_url }}">LOG</a>
+ {% else %}
+ &nbsp;
+ {% endif %}
+ </td>
+ {% endif %}
</tr>
{% endfor %}
</tbody>