Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: error if no tests reports found #807

Merged
merged 1 commit into from
Jan 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions .github/scripts/tests/generate-summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@ def add_line(self, line: TestSummaryLine):
self.is_failed |= line.is_failed
self.lines.append(line)

@property
def is_empty(self):
return len(self.lines) == 0

def render_line(self, items):
return f"| {' | '.join(items)} |"

Expand Down Expand Up @@ -249,8 +253,12 @@ def write_summary(summary: TestSummary):
else:
fp = sys.stdout

for line in summary.render(add_footnote=True):
fp.write(f"{line}\n")
if summary.is_empty:
fp.write(":red_circle: Test run completed, no test results found. Please check build logs.")
else:
for line in summary.render(add_footnote=True):
fp.write(f"{line}\n")

fp.write("\n")

if summary_fn:
Expand All @@ -267,6 +275,9 @@ def gen_summary(summary_url_prefix, summary_out_folder, paths):
test_result = TestResult.from_junit(case)
summary_line.add(test_result)

if not summary_line.tests:
continue

report_url = f"{summary_url_prefix}{html_fn}"

render_testlist_html(summary_line.tests, os.path.join(summary_out_folder, html_fn))
Expand All @@ -277,8 +288,12 @@ def gen_summary(summary_url_prefix, summary_out_folder, paths):


def get_comment_text(pr: PullRequest, summary: TestSummary, build_preset: str, test_history_url: str):

if summary.is_failed:
if summary.is_empty:
return [
f":red_circle: **{build_preset}**: Test run completed, no test results found for commit {pr.head.sha}. "
f"Please check build logs."
]
elif summary.is_failed:
result = f":red_circle: **{build_preset}**: some tests FAILED"
else:
result = f":green_circle: **{build_preset}**: all tests PASSED"
Expand Down
Loading