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
7 changes: 6 additions & 1 deletion scripts/license_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@
"CHANGELOG.md",
]

IGNORE_SUFFIXES = [".lock"]
IGNORE_SUFFIXES = [
".lock", # lock files are generated files
".min.js", # Vendored in JS files
".bundle.min.js", # Vendored in JS files
".min.css", # Vendored in CSS files
]

OPTIONAL_TRAILING_NEWLINE = [".nix", ".md"]

Expand Down
36 changes: 36 additions & 0 deletions scripts/update_js.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env bash
# Copyright lowRISC contributors (OpenTitan project).
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0

# Find the Git repository root directory
GIT_ROOT=$(git rev-parse --show-toplevel 2>/dev/null)

if [ -z "$GIT_ROOT" ]; then
echo "Error: This script must be run from within a Git repository."
exit 1
fi

# Define the target directory relative to the Git root
TARGET_DIR="$GIT_ROOT/src/dvsim/templates/static"

# Create the directory (and any missing parents) if it doesn't exist
mkdir -p "$TARGET_DIR/css" "$TARGET_DIR/js"
echo "Downloading latest Bootstrap and htmx to $TARGET_DIR..."

# Bootstrap CSS (latest 5.x)
curl -L -o "$TARGET_DIR/css/bootstrap.min.css" \
https://cdn.jsdelivr.net/npm/bootstrap@5/dist/css/bootstrap.min.css

# Bootstrap JS Bundle (includes Popper, latest 5.x)
curl -L -o "$TARGET_DIR/js/bootstrap.bundle.min.js" \
https://cdn.jsdelivr.net/npm/bootstrap@5/dist/js/bootstrap.bundle.min.js

# htmx (latest version via @latest tag)
curl -L -o "$TARGET_DIR/js/htmx.min.js" \
https://cdn.jsdelivr.net/npm/htmx.org@latest/dist/htmx.min.js

echo "Done! Files saved to:"
echo " - $TARGET_DIR/css/bootstrap.min.css"
echo " - $TARGET_DIR/js/bootstrap.bundle.min.js"
echo " - $TARGET_DIR/js/htmx.min.js"
11 changes: 3 additions & 8 deletions src/dvsim/cli/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@

import click

from dvsim.report.data import ResultsSummary
from dvsim.report.generate import gen_block_report


@click.group()
def cli() -> None:
Expand Down Expand Up @@ -38,11 +35,9 @@ def report() -> None:
)
def gen(json_path: Path, output_dir: Path) -> None:
"""Generate a report from a existing results JSON."""
from dvsim.report.generate import gen_summary_report
from dvsim.report.data import ResultsSummary
from dvsim.report.generate import gen_reports

results: ResultsSummary = ResultsSummary.load(path=json_path)

gen_summary_report(summary=results, path=output_dir)

for flow_result in results.flow_results.values():
gen_block_report(flow_result, path=output_dir)
gen_reports(summary=results, path=output_dir)
8 changes: 4 additions & 4 deletions src/dvsim/flow/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from dvsim.launcher.factory import get_launcher_cls
from dvsim.logging import log
from dvsim.report.data import FlowResults, IPMeta, ResultsSummary
from dvsim.report.generate import gen_block_report, gen_summary_report
from dvsim.report.generate import gen_block_report, gen_reports
from dvsim.scheduler import Scheduler
from dvsim.utils import (
find_and_substitute_wildcards,
Expand Down Expand Up @@ -480,7 +480,7 @@ def gen_results(self, results: Sequence[CompletedJobStatus]) -> None:

all_flow_results[block_result_index] = flow_results

# Write results to the report area.
# Generate the block's JSON/HTML reports to the report area.
gen_block_report(
results=flow_results,
path=reports_dir,
Expand Down Expand Up @@ -511,8 +511,8 @@ def gen_results(self, results: Sequence[CompletedJobStatus]) -> None:
report_path=reports_dir,
)

# Write results to the report area.
gen_summary_report(
# Generate all the JSON/HTML reports to the report area.
gen_reports(
summary=results_summary,
path=reports_dir,
)
Expand Down
34 changes: 32 additions & 2 deletions src/dvsim/report/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@

from dvsim.logging import log
from dvsim.report.data import FlowResults, ResultsSummary
from dvsim.templates.render import render_template
from dvsim.templates.render import render_static, render_template

__all__ = (
"gen_block_report",
"gen_reports",
"gen_summary_report",
)

Expand Down Expand Up @@ -61,12 +62,41 @@ def gen_summary_report(summary: ResultsSummary, path: Path) -> None:
# Save the JSON version
(path / "index.json").write_text(summary.model_dump_json())

# Generate style CSS
for name in (
"css/style.css",
"css/bootstrap.min.css",
"js/bootstrap.bundle.min.js",
"js/htmx.min.js",
):
output = path / name

output.parent.mkdir(parents=True, exist_ok=True)
output.write_text(render_static(path=name))

# HTMX wrapper
(path / "index.html").write_text(render_template(path="reports/wrapper.html"))

# Generate HTML report
(path / "index.html").write_text(
(path / "summary.html").write_text(
render_template(
path="reports/summary_report.html",
data={
"summary": summary,
},
),
)


def gen_reports(summary: ResultsSummary, path: Path) -> None:
"""Generate a full set of reports for the given regression run.

Args:
summary: overview of the block results
path: output directory path

"""
gen_summary_report(summary=summary, path=path)

for flow_result in summary.flow_results.values():
gen_block_report(results=flow_result, path=path)
19 changes: 18 additions & 1 deletion src/dvsim/templates/render.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"""

from collections.abc import Mapping
from importlib import resources

from jinja2 import Environment, PackageLoader, select_autoescape

Expand All @@ -17,6 +18,22 @@
_env: Environment | None = None


def render_static(path: str) -> str:
"""Render static files packaged with DVSim.

Args:
path: relative path to the DVSim template directory

Returns:
string containing the static file content

"""
return resources.read_text(
"dvsim",
f"templates/static/{path}",
)


def render_template(path: str, data: Mapping[str, object] | None = None) -> str:
"""Render a template packaged with DVSim.

Expand All @@ -38,4 +55,4 @@ def render_template(path: str, data: Mapping[str, object] | None = None) -> str:

template = _env.get_template(path)

return template.render(data)
return template.render(data or {})
46 changes: 0 additions & 46 deletions src/dvsim/templates/reports/block_report.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,52 +4,12 @@
# SPDX-License-Identifier: Apache-2.0

-->

{% set block = results.block %}
{% set tool = results.tool %}
{% set timestamp = results.timestamp %}
{% set stages = results.stages %}
{% set coverage = results.coverage %}
{% set failed_jobs = results.failed_jobs %}

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{{ block.name }} Simulation Results</title>
<script src="https://unpkg.com/htmx.org@2.0.4"></script>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css"
rel="stylesheet"
integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH"
crossorigin="anonymous">
<style>
td.c0 { color: #ffffff; background-color: #EF5757; }
td.c1 { color: #ffffff; background-color: #EF6D57; }
td.c2 { color: #000000; background-color: #EF8357; }
td.c3 { color: #000000; background-color: #EF9957; }
td.c4 { color: #000000; background-color: #EFAF57; }
td.c5 { color: #000000; background-color: #EFC557; }
td.c6 { color: #000000; background-color: #EFDB57; }
td.c7 { color: #000000; background-color: #ECEF57; }
td.c8 { color: #000000; background-color: #D6EF57; }
td.c9 { color: #000000; background-color: #C0EF57; }
td.c10 { color: #000000; background-color: #57EF57; }
</style>
</head>
<body>

<nav class="navbar navbar-expand-lg bg-body-tertiary">
<div class="container-fluid">
<a class="navbar-brand" href="#">Nightly Reports</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse"
data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent"
aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
</div>
</nav>

<div class="container-md">
<div class="row">
<div class="col">
Expand Down Expand Up @@ -262,9 +222,3 @@ <h3>Error Messages</h3>
</div>
</div>
</div>

<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"
integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz"
crossorigin="anonymous"></script>
</body>
</html>
64 changes: 10 additions & 54 deletions src/dvsim/templates/reports/summary_report.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,49 +4,9 @@
# SPDX-License-Identifier: Apache-2.0

-->

{% set top = summary.top %}
{% set timestamp = summary.timestamp %}

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{{ top.name }} Simulation Results</title>
<script src="https://unpkg.com/htmx.org@2.0.4"></script>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css"
rel="stylesheet"
integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH"
crossorigin="anonymous">
<style>
td.c0 { color: #ffffff; background-color: #EF5757; }
td.c1 { color: #ffffff; background-color: #EF6D57; }
td.c2 { color: #000000; background-color: #EF8357; }
td.c3 { color: #000000; background-color: #EF9957; }
td.c4 { color: #000000; background-color: #EFAF57; }
td.c5 { color: #000000; background-color: #EFC557; }
td.c6 { color: #000000; background-color: #EFDB57; }
td.c7 { color: #000000; background-color: #ECEF57; }
td.c8 { color: #000000; background-color: #D6EF57; }
td.c9 { color: #000000; background-color: #C0EF57; }
td.c10 { color: #000000; background-color: #57EF57; }
</style>
</head>
<body>

<nav class="navbar navbar-expand-lg bg-body-tertiary">
<div class="container-fluid">
<a class="navbar-brand" href="#">Nightly Reports</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse"
data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent"
aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
</div>
</nav>

<div class="container-md">
<div class="container-md">
<div class="row">
<div class="col">
{% if breadcrumbs %}
Expand Down Expand Up @@ -77,25 +37,25 @@ <h2>Simulation Results: {{ top.name }}</h2>
{{ timestamp.strftime("%d/%m/%Y %H:%M:%S") }}
</span>
<a class="badge text-bg-secondary link-underline link-underline-opacity-0"
href="{{ top.url }}">
href="{{ top.url }}">
sha: {{ top.commit[:7] }}
</a>
<a class="badge text-bg-secondary link-underline link-underline-opacity-0"
href="index.json">json</a>
href="index.json">json</a>
<span class="badge text-bg-secondary">
Branch: {{ top.branch }}
</span>
</div>
</div>

{% macro coverage_cell(cov, kind) %}
{% macro coverage_cell(cov, kind) %}
{% if cov and cov|attr(kind) is not none %}
{% set value = cov|attr(kind) %}
<td class="c{{ (value / 10)|int }}">{{ "%.2f"|format(value) }}</td>
{% else %}
<td class="text-muted">-</td>
{% endif %}
{% endmacro %}
{% endmacro %}

<div class="row py-3">
<div class="col">
Expand Down Expand Up @@ -132,10 +92,12 @@ <h2>Simulation Results: {{ top.name }}</h2>
{% for block_name in summary.flow_results.keys()|sort %}
{% set flow = summary.flow_results[block_name] %}
<tr>
<td>
<a href="{{ block_name }}.html">
<td class="btn"
hx-get="{{ block_name }}.html"
hx-trigger="click"
hx-push-url="true"
hx-target="#report-content">
{{ block_name | upper }}
</a>
</td>
<td>{{ flow.passed }}</td>
<td>{{ flow.total }}</td>
Expand Down Expand Up @@ -163,9 +125,3 @@ <h2>Simulation Results: {{ top.name }}</h2>
</div>
</div>
</div>

<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"
integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz"
crossorigin="anonymous"></script>
</body>
</html>
Loading
Loading