Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions kcidev/libs/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ def kci_msg_nonl(content):
click.echo(content, nl=False)


def kci_msg_bold_nonl(content):
click.secho(content, bold=True, nl=False)


def kci_msg_green(content, nl=True):
click.secho(content, fg="green", nl=nl)

Expand Down
4 changes: 2 additions & 2 deletions kcidev/subcommands/maestro/validate/boots.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from kcidev.libs.git_repo import get_tree_name, set_giturl_branch_commit
from kcidev.subcommands.results import trees

from .helper import get_boot_stats, print_stats
from .helper import get_boot_stats, print_table_stats


@click.command(
Expand Down Expand Up @@ -121,4 +121,4 @@ def boots(
]
max_col_width = [None, 40, 3, 3, 2, 30, 30]
table_fmt = "simple_grid"
print_stats(final_stats, headers, max_col_width, table_fmt)
print_table_stats(final_stats, headers, max_col_width, table_fmt)
21 changes: 18 additions & 3 deletions kcidev/subcommands/maestro/validate/builds.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@
from kcidev.libs.git_repo import get_tree_name, set_giturl_branch_commit
from kcidev.subcommands.results import trees

from .helper import get_build_stats, get_builds_history_stats, print_stats
from .helper import (
get_build_stats,
get_builds_history_stats,
print_simple_list,
print_table_stats,
)


@click.command(
Expand All @@ -27,7 +32,7 @@
Examples:
# Build validation
kci-dev validate builds --all-checkouts --days <number-of-days>
kci-dev validate builds -commit <git-commit> --giturl <git-url> --branch <git-branch>
kci-dev validate builds --commit <git-commit> --giturl <git-url> --branch <git-branch>
# Build history validation
kci-dev validate builds --history --all-checkouts --days <number-of-days>
kci-dev validate builds --history --giturl <git-url> --branch <git-branch> --days <number-of-days>
Expand Down Expand Up @@ -82,6 +87,12 @@
default=False,
help="Get detailed output",
)
@click.option(
"--table-output",
is_flag=True,
default=False,
help="Display results in table format instead of simple list",
)
@click.pass_context
def builds(
ctx,
Expand All @@ -96,6 +107,7 @@ def builds(
days,
history,
verbose,
table_output,
):
final_stats = []
print("Fetching build information...")
Expand Down Expand Up @@ -164,4 +176,7 @@ def builds(
]
max_col_width = [None, 40, 3, 3, 2, 30, 30]
table_fmt = "simple_grid"
print_stats(final_stats, headers, max_col_width, table_fmt)
if table_output:
print_table_stats(final_stats, headers, max_col_width, table_fmt)
else:
print_simple_list(final_stats, history)
62 changes: 60 additions & 2 deletions kcidev/subcommands/maestro/validate/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import click
from tabulate import tabulate

from kcidev.libs.common import kci_msg, kci_msg_json, kci_msg_red
from kcidev.libs.common import kci_msg, kci_msg_bold_nonl, kci_msg_json, kci_msg_red
from kcidev.subcommands.maestro.results import results
from kcidev.subcommands.results import boots, builds

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


def print_stats(data, headers, max_col_width, table_fmt):
def print_table_stats(data, headers, max_col_width, table_fmt):
"""Print build statistics in tabular format"""
print("Creating a stats report...")
print(
tabulate(data, headers=headers, maxcolwidths=max_col_width, tablefmt=table_fmt)
)


def print_simple_list(data, history=False):
"""Print a simple list format showing tree/branch with status and missing IDs"""

if history:
# For history mode, group by tree/branch and show overall status
from collections import defaultdict

tree_groups = defaultdict(list)

for row in data:
tree_branch = row[0] # tree/branch
comparison = row[4] # Build count comparison (✅ or ❌)
missing_ids = row[5] # Missing build IDs
commit = row[1] # Commit hash

tree_groups[tree_branch].append(
{"commit": commit, "status": comparison, "missing_ids": missing_ids}
)

for tree_branch, commits in tree_groups.items():
# Check if any commit has issues
has_issues = any(commit["status"] == "❌" for commit in commits)
status_icon = "❌" if has_issues else "✅"

kci_msg_bold_nonl(f"{tree_branch}: ")
kci_msg(f"{status_icon}")

if has_issues:
for commit in commits:
if commit["status"] == "❌" and commit["missing_ids"]:
kci_msg(f" Commit {commit['commit'][:12]}:")
for id in commit["missing_ids"]:
kci_msg(f" - https://api.kernelci.org/viewer?node_id={id}")
elif commit["status"] == "❌":
kci_msg(
f" Commit {commit['commit'][:12]}: Has mismatch but no missing IDs listed"
)
else:
# For non-history mode, show each individual result
for row in data:
tree_branch = row[0] # tree/branch
commit = row[1] # commit
comparison = row[4] # Build count comparison (✅ or ❌)
missing_ids = row[5] # Missing build IDs

kci_msg_bold_nonl(f"• {tree_branch}: ")
kci_msg(f"{comparison}")
kci_msg(f" Commit: {commit}")

if comparison == "❌" and missing_ids:
kci_msg(" Missing builds:")
for id in missing_ids:
kci_msg(f" - https://api.kernelci.org/viewer?node_id={id}")
elif comparison == "❌":
kci_msg(f" Has mismatch but no missing IDs listed")
kci_msg("")


def validate_boot_status(maestro_boots, dashboard_boots):
"""
Validate if the boot status of dashboard pulled boot
Expand Down