Skip to content

Commit 9d1b334

Browse files
authored
Merge pull request #202 from padovan/validate-simple-print
validate builds: improve output format with simple list view
2 parents 44b365b + 540e555 commit 9d1b334

4 files changed

Lines changed: 84 additions & 7 deletions

File tree

kcidev/libs/common.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,10 @@ def kci_msg_nonl(content):
129129
click.echo(content, nl=False)
130130

131131

132+
def kci_msg_bold_nonl(content):
133+
click.secho(content, bold=True, nl=False)
134+
135+
132136
def kci_msg_green(content, nl=True):
133137
click.secho(content, fg="green", nl=nl)
134138

kcidev/subcommands/maestro/validate/boots.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from kcidev.libs.git_repo import get_tree_name, set_giturl_branch_commit
44
from kcidev.subcommands.results import trees
55

6-
from .helper import get_boot_stats, print_stats
6+
from .helper import get_boot_stats, print_table_stats
77

88

99
@click.command(
@@ -121,4 +121,4 @@ def boots(
121121
]
122122
max_col_width = [None, 40, 3, 3, 2, 30, 30]
123123
table_fmt = "simple_grid"
124-
print_stats(final_stats, headers, max_col_width, table_fmt)
124+
print_table_stats(final_stats, headers, max_col_width, table_fmt)

kcidev/subcommands/maestro/validate/builds.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@
33
from kcidev.libs.git_repo import get_tree_name, set_giturl_branch_commit
44
from kcidev.subcommands.results import trees
55

6-
from .helper import get_build_stats, get_builds_history_stats, print_stats
6+
from .helper import (
7+
get_build_stats,
8+
get_builds_history_stats,
9+
print_simple_list,
10+
print_table_stats,
11+
)
712

813

914
@click.command(
@@ -27,7 +32,7 @@
2732
Examples:
2833
# Build validation
2934
kci-dev validate builds --all-checkouts --days <number-of-days>
30-
kci-dev validate builds -commit <git-commit> --giturl <git-url> --branch <git-branch>
35+
kci-dev validate builds --commit <git-commit> --giturl <git-url> --branch <git-branch>
3136
# Build history validation
3237
kci-dev validate builds --history --all-checkouts --days <number-of-days>
3338
kci-dev validate builds --history --giturl <git-url> --branch <git-branch> --days <number-of-days>
@@ -82,6 +87,12 @@
8287
default=False,
8388
help="Get detailed output",
8489
)
90+
@click.option(
91+
"--table-output",
92+
is_flag=True,
93+
default=False,
94+
help="Display results in table format instead of simple list",
95+
)
8596
@click.pass_context
8697
def builds(
8798
ctx,
@@ -96,6 +107,7 @@ def builds(
96107
days,
97108
history,
98109
verbose,
110+
table_output,
99111
):
100112
final_stats = []
101113
print("Fetching build information...")
@@ -164,4 +176,7 @@ def builds(
164176
]
165177
max_col_width = [None, 40, 3, 3, 2, 30, 30]
166178
table_fmt = "simple_grid"
167-
print_stats(final_stats, headers, max_col_width, table_fmt)
179+
if table_output:
180+
print_table_stats(final_stats, headers, max_col_width, table_fmt)
181+
else:
182+
print_simple_list(final_stats, history)

kcidev/subcommands/maestro/validate/helper.py

Lines changed: 60 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import click
66
from tabulate import tabulate
77

8-
from kcidev.libs.common import kci_msg, kci_msg_json, kci_msg_red
8+
from kcidev.libs.common import kci_msg, kci_msg_bold_nonl, kci_msg_json, kci_msg_red
99
from kcidev.subcommands.maestro.results import results
1010
from kcidev.subcommands.results import boots, builds
1111

@@ -124,14 +124,72 @@ def get_build_stats(ctx, giturl, branch, commit, tree_name, verbose, arch):
124124
return stats
125125

126126

127-
def print_stats(data, headers, max_col_width, table_fmt):
127+
def print_table_stats(data, headers, max_col_width, table_fmt):
128128
"""Print build statistics in tabular format"""
129129
print("Creating a stats report...")
130130
print(
131131
tabulate(data, headers=headers, maxcolwidths=max_col_width, tablefmt=table_fmt)
132132
)
133133

134134

135+
def print_simple_list(data, history=False):
136+
"""Print a simple list format showing tree/branch with status and missing IDs"""
137+
138+
if history:
139+
# For history mode, group by tree/branch and show overall status
140+
from collections import defaultdict
141+
142+
tree_groups = defaultdict(list)
143+
144+
for row in data:
145+
tree_branch = row[0] # tree/branch
146+
comparison = row[4] # Build count comparison (✅ or ❌)
147+
missing_ids = row[5] # Missing build IDs
148+
commit = row[1] # Commit hash
149+
150+
tree_groups[tree_branch].append(
151+
{"commit": commit, "status": comparison, "missing_ids": missing_ids}
152+
)
153+
154+
for tree_branch, commits in tree_groups.items():
155+
# Check if any commit has issues
156+
has_issues = any(commit["status"] == "❌" for commit in commits)
157+
status_icon = "❌" if has_issues else "✅"
158+
159+
kci_msg_bold_nonl(f"{tree_branch}: ")
160+
kci_msg(f"{status_icon}")
161+
162+
if has_issues:
163+
for commit in commits:
164+
if commit["status"] == "❌" and commit["missing_ids"]:
165+
kci_msg(f" Commit {commit['commit'][:12]}:")
166+
for id in commit["missing_ids"]:
167+
kci_msg(f" - https://api.kernelci.org/viewer?node_id={id}")
168+
elif commit["status"] == "❌":
169+
kci_msg(
170+
f" Commit {commit['commit'][:12]}: Has mismatch but no missing IDs listed"
171+
)
172+
else:
173+
# For non-history mode, show each individual result
174+
for row in data:
175+
tree_branch = row[0] # tree/branch
176+
commit = row[1] # commit
177+
comparison = row[4] # Build count comparison (✅ or ❌)
178+
missing_ids = row[5] # Missing build IDs
179+
180+
kci_msg_bold_nonl(f"• {tree_branch}: ")
181+
kci_msg(f"{comparison}")
182+
kci_msg(f" Commit: {commit}")
183+
184+
if comparison == "❌" and missing_ids:
185+
kci_msg(" Missing builds:")
186+
for id in missing_ids:
187+
kci_msg(f" - https://api.kernelci.org/viewer?node_id={id}")
188+
elif comparison == "❌":
189+
kci_msg(f" Has mismatch but no missing IDs listed")
190+
kci_msg("")
191+
192+
135193
def validate_boot_status(maestro_boots, dashboard_boots):
136194
"""
137195
Validate if the boot status of dashboard pulled boot

0 commit comments

Comments
 (0)