Skip to content

petri: add and publish log viewer web tool #1413

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

Merged
merged 3 commits into from
May 27, 2025
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
26 changes: 24 additions & 2 deletions .github/workflows/openvmm-docs-ci.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ impl SimpleFlowNode for Node {

fn imports(ctx: &mut ImportCtx<'_>) {
ctx.import::<flowey_lib_common::copy_to_artifact_dir::Node>();
ctx.import::<crate::git_checkout_openvmm_repo::Node>();
}

fn process_request(request: Self::Request, ctx: &mut NodeCtx<'_>) -> anyhow::Result<()> {
Expand All @@ -42,14 +43,18 @@ impl SimpleFlowNode for Node {
output,
} = request;

let repo = ctx.reqv(crate::git_checkout_openvmm_repo::req::GetRepoDir);

let consolidated_html = ctx.emit_rust_stepv("generate consolidated gh pages html", |ctx| {
let rendered_guide = rendered_guide.claim(ctx);
let rustdoc_windows = rustdoc_windows.claim(ctx);
let rustdoc_linux = rustdoc_linux.claim(ctx);
let repo = repo.claim(ctx);
|rt| {
let rendered_guide = rt.read(rendered_guide);
let rustdoc_windows = rt.read(rustdoc_windows);
let rustdoc_linux = rt.read(rustdoc_linux);
let repo = rt.read(repo);

let consolidated_html = std::env::current_dir()?.join("out").absolute()?;
fs_err::create_dir(&consolidated_html)?;
Expand Down Expand Up @@ -78,6 +83,12 @@ impl SimpleFlowNode for Node {
consolidated_html.join("rustdoc/linux"),
)?;

// Make petri logview available under `openvmm.dev/test-results/`
flowey_lib_common::_util::copy_dir_all(
repo.join("petri/logview"),
consolidated_html.join("test-results"),
)?;

// as we do not currently have any form of "landing page",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it's time for a 'landing page', or at least a page very early on in the guide with links to this and rustdoc? I think we have one in the guide right now but it's very far down the table of contents.

// redirect `openvmm.dev` to `openvmm.dev/guide`
fs_err::write(consolidated_html.join("index.html"), REDIRECT)?;
Expand Down
175 changes: 175 additions & 0 deletions petri/logview/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<title>Petri test results</title>
<style type="text/css">
body {
font-family: monospace;
font-size: 14px;
}
</style>
<script>
const baseUrl = "https://openvmmghtestresults.blob.core.windows.net/results";

const cross = "&#10060;"; // Cross for failed tests
const check = "&#9989;"; // Check for passed tests

function parseBlobs(xmlText) {
const parser = new DOMParser();
const xmlDoc = parser.parseFromString(xmlText, "text/xml");
const blobs = xmlDoc.getElementsByTagName("Blob");
let blobNames = [];
for (const blob of blobs) {
const name = blob.getElementsByTagName("Name")[0].textContent;
const date = new Date(blob.getElementsByTagName("Creation-Time")[0].textContent);
let metadata = {};
for (const meta of blob.getElementsByTagName("Metadata")) {
const child = meta.children[0];
metadata[child.tagName] = child.textContent;
}
blobNames.push({
name: name,
creationTime: date,
metadata: metadata,
});
}
return blobNames;
}

// Get the blob list, which is in XML via a GET request.
function getTestList(runName) {
const url = `${baseUrl}?restype=container&comp=list&showonly=files&prefix=${encodeURIComponent(runName)}`;
fetch(url)
.then(response => response.text())
.then(data => {
let blobs = parseBlobs(data);
let run = {};
for (const blob of blobs) {
const nameParts = blob.name.split("/");
let fileName = nameParts[nameParts.length - 1];
let failed;
if (fileName === "petri.passed") {
failed = false;
} else if (fileName === "petri.failed") {
failed = true;
} else {
continue; // Not a test result file.
}
const testName = nameParts[nameParts.length - 2];
const jobName = nameParts[nameParts.length - 3];
const path = nameParts.slice(0, -3).join("/");
const url = `test.html?run=${path}&job=${jobName}&test=${testName}`;
if (!run[jobName]) {
run[jobName] = {
failed: false,
tests: [],
};
}
let job = run[jobName];
job.failed |= failed;
job.tests.push({
name: testName,
url: url,
failed: failed,
});
}

let failedHtml = "";
let passingHtml = "";

for (const job in run) {
run[job].tests.sort((a, b) => {
if (a.failed !== b.failed) {
return a.failed ? -1 : 1; // Failed tests first.
}
return a.name.localeCompare(b.name); // Then by name.
});
let thisHtml = `<li>${job}<ul>`;
for (const test of run[job].tests) {
let icon = test.failed ? cross : check;
thisHtml += `<li><a href="${test.url}">${icon} ${test.name}</a></li>`;
}
thisHtml += "</ul></li>";
if (run[job].failed) {
failedHtml += thisHtml;
} else {
passingHtml += thisHtml;
}
}

let html = `<h2>Failed jobs</h2>
<ul>${failedHtml}</ul>
<h2>Passing jobs</h2>
<ul>${passingHtml}</ul>`;

document.getElementById("runList").innerHTML = html;
})
.catch(error => console.error('Error fetching blob list:', error));
}

function getRunList() {
const url = `${baseUrl}?restype=container&comp=list&showonly=files&include=metadata&prefix=runs/`;
fetch(url)
.then(response => response.text())
.then(data => {
const blobs = parseBlobs(data);
const runs = blobs.map(blob => {
// Remove runs/ prefix.
return {
name: blob.name.replace(/^runs\//, ''),
creationTime: blob.creationTime,
failed: blob.metadata["petrifailed"],
};
});
runs.sort((a, b) => b.creationTime - a.creationTime); // Sort by creation time, newest first.
let html = `<table>
<thead>
<tr>
<th>Time</th>
<th>Run</th>
<th>Failed</th>
</tr>
</thead>
<tbody>`;
for (const run of runs) {
const marker = run.failed > 0 ? cross : check;
html += `<tr>
<td>${run.creationTime.toLocaleString()}</td>
<td><a href="?run=${encodeURIComponent(run.name)}">${run.name} ${marker}</a></td>
<td>${run.failed}</td>
</tr>`;
}
html += "</table>";
if (runs.length === 0) {
html = "No runs found.";
}
document.getElementById("runList").innerHTML = html;
})
.catch(error => console.error('Error fetching run list:', error));
}

window.onload = function () {
const urlParams = new URLSearchParams(window.location.search);
const run = urlParams.get('run');
document.getElementById("runList").innerText = "Loading...";
if (run) {
document.getElementById("runName").innerText = run;
document.getElementById("backToRuns").innerHTML = `<a href="?">All runs</a>`;
getTestList(run);
} else {
document.getElementById("runName").innerText = "Runs";
getRunList();
}
};
</script>
</head>

<body>
<h1 id="runName">Loading</h1>
<div id="backToRuns"></div>
<div id="runList"></div>
</body>

</html>
Loading