Skip to content

Commit 0633c21

Browse files
authored
Merge pull request #205 from JenySadadia/fix-validate-builds-cmd
`maestro validate builds` command fixes
2 parents 5e2b8e3 + 59d410c commit 0633c21

File tree

3 files changed

+46
-34
lines changed

3 files changed

+46
-34
lines changed

kcidev/libs/common.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,8 @@ 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)
132+
def kci_msg_bold(content, nl=True):
133+
click.secho(content, bold=True, nl=nl)
134134

135135

136136
def kci_msg_green(content, nl=True):

kcidev/subcommands/maestro/validate/builds.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,4 +179,4 @@ def builds(
179179
if table_output:
180180
print_table_stats(final_stats, headers, max_col_width, table_fmt)
181181
else:
182-
print_simple_list(final_stats, history)
182+
print_simple_list(final_stats, "builds", history)

kcidev/subcommands/maestro/validate/helper.py

Lines changed: 43 additions & 31 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_bold_nonl, kci_msg_json, kci_msg_red
8+
from kcidev.libs.common import kci_msg, kci_msg_bold, kci_msg_json, kci_msg_red
99
from kcidev.subcommands.maestro.results import results
1010
from kcidev.subcommands.results import boots, builds
1111

@@ -46,6 +46,8 @@ def get_builds(ctx, giturl, branch, commit, arch):
4646
return maestro_builds, None
4747
except click.ClickException as e:
4848
kci_msg_red(f"{branch}/{commit}: {e.message}")
49+
if "No builds available" in e.message:
50+
return maestro_builds, []
4951
return maestro_builds, None
5052
return maestro_builds, dashboard_builds
5153

@@ -132,7 +134,20 @@ def print_table_stats(data, headers, max_col_width, table_fmt):
132134
)
133135

134136

135-
def print_simple_list(data, history=False):
137+
def extract_validation_data(row: list):
138+
"""Extract information from validation stats"""
139+
try:
140+
tree_branch = row[0]
141+
commit = row[1] # Commit hash
142+
comparison = row[4] # Build/boot count comparison (✅ or ❌)
143+
missing_ids = row[5] # Missing build/boot IDs
144+
return tree_branch, commit, comparison, missing_ids
145+
except IndexError:
146+
kci_msg_red("Failed to extract data for list view report")
147+
raise ValueError()
148+
149+
150+
def print_simple_list(data, item_type, history=False):
136151
"""Print a simple list format showing tree/branch with status and missing IDs"""
137152

138153
if history:
@@ -142,47 +157,42 @@ def print_simple_list(data, history=False):
142157
tree_groups = defaultdict(list)
143158

144159
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-
160+
try:
161+
tree_branch, commit, comparison, missing_ids = extract_validation_data(
162+
row
163+
)
164+
except ValueError:
165+
continue
150166
tree_groups[tree_branch].append(
151167
{"commit": commit, "status": comparison, "missing_ids": missing_ids}
152168
)
153169

154170
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-
)
171+
kci_msg_bold(f"{tree_branch}: ")
172+
for commit in commits:
173+
if commit["status"] == "❌" and commit["missing_ids"]:
174+
kci_msg(f" Commit {commit['commit'][:12]}: ❌")
175+
kci_msg(f" Missing {item_type}: {len(commit['missing_ids'])}")
176+
for id in commit["missing_ids"]:
177+
kci_msg(f" - https://api.kernelci.org/viewer?node_id={id}")
178+
elif commit["status"] == "✅":
179+
kci_msg(f" Commit {commit['commit'][:12]}: ✅")
180+
172181
else:
173182
# For non-history mode, show each individual result
174183
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}: ")
184+
try:
185+
tree_branch, commit, comparison, missing_ids = extract_validation_data(
186+
row
187+
)
188+
except ValueError:
189+
continue
190+
kci_msg_bold(f"• {tree_branch}: ", nl=False)
181191
kci_msg(f"{comparison}")
182192
kci_msg(f" Commit: {commit}")
183193

184194
if comparison == "❌" and missing_ids:
185-
kci_msg(" Missing builds:")
195+
kci_msg(f" Missing {item_type}: {len(missing_ids)}")
186196
for id in missing_ids:
187197
kci_msg(f" - https://api.kernelci.org/viewer?node_id={id}")
188198
elif comparison == "❌":
@@ -382,4 +392,6 @@ def get_builds_history(ctx, checkouts, arch):
382392
kci_msg_red(f"{branch}/{commit}: Aborted while fetching dashboard builds")
383393
except click.ClickException as e:
384394
kci_msg_red(f"{branch}/{commit}: {e.message}")
395+
if "No builds available" in e.message:
396+
builds_history.append([commit, maestro_builds, []])
385397
return builds_history

0 commit comments

Comments
 (0)