feat: run all PostgreSQL live tests in isolated advisory CI with failure and skip summaries

This commit is contained in:
Matthew Meszaros
2026-10-30 14:01:41 +01:00
parent f412edc492
commit ca73a18459
3 changed files with 169 additions and 0 deletions
+62
View File
@@ -0,0 +1,62 @@
import { appendFileSync, existsSync, readFileSync } from "node:fs";
import { pathToFileURL } from "node:url";
export function summarizeLiveTests(input, outcome) {
const tests = new Map();
const failedPackages = new Set();
for (const line of input.split("\n")) {
let event;
try {
event = JSON.parse(line);
} catch {
continue; // Compiler diagnostics can be plain text alongside go test JSON.
}
if (!event || typeof event !== "object") continue;
if (event.Action === "fail" && typeof event.Package === "string" && !event.Test) {
failedPackages.add(event.Package);
}
if (typeof event.Test !== "string" || !event.Test.startsWith("TestLive") || event.Test.includes("/")) continue;
if (!["pass", "fail", "skip"].includes(event.Action)) continue;
tests.set(`${event.Package}/${event.Test}`, event.Action);
}
const names = (action) => [...tests].filter(([, result]) => result === action).map(([name]) => name).sort();
const passed = names("pass");
const failed = names("fail");
const skipped = names("skip");
const list = (heading, entries) => [
`### ${heading}`,
"",
...(entries.length ? entries.slice(0, 200).map((name) => `- \`${name.replaceAll("`", "\\`")}\``) : ["None recorded."]),
...(entries.length > 200 ? ["", "Showing the first 200 entries; see the complete output artifact."] : []),
"",
];
return {
needsAttention: outcome !== "success" || tests.size === 0 || failed.length > 0 || skipped.length > 0 || failedPackages.size > 0,
markdown: [
"## PostgreSQL catch-all (advisory)",
"",
`Test step outcome: **${outcome || "not started"}**. This job is outside the required CI Status aggregate while #1078 is triaged.`,
"",
"| Top-level TestLive results | Count |",
"| --- | ---: |",
`| Passed | ${passed.length} |`,
`| Failed | ${failed.length} |`,
`| Skipped | ${skipped.length} |`,
"",
...(tests.size === 0 ? ["No completed TestLive results were recorded. Check setup, compilation and timeouts.", ""] : []),
...list("Failed packages (including setup or build failures)", [...failedPackages].sort()),
...list("Failed tests", failed),
...list("Skipped tests", skipped),
"Full JSON events and compiler output are retained in the postgres-live-advisory artifact. Subtests are included there; counts above include each top-level test once.",
"",
].join("\n"),
};
}
if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
const file = process.argv[2];
const report = summarizeLiveTests(file && existsSync(file) ? readFileSync(file, "utf8") : "", process.env.LIVE_TEST_OUTCOME);
if (process.env.GITHUB_STEP_SUMMARY) appendFileSync(process.env.GITHUB_STEP_SUMMARY, report.markdown);
else process.stdout.write(report.markdown);
if (report.needsAttention) console.log("::warning::Advisory PostgreSQL coverage needs triage. See the job summary and complete output artifact.");
}
@@ -0,0 +1,38 @@
import assert from "node:assert/strict";
import test from "node:test";
import { summarizeLiveTests } from "./live-tests-summary.mjs";
const events = (...rows) => rows.map((row) => JSON.stringify(row)).join("\n");
test("reports failures, skips and failed packages without counting subtests twice", () => {
const report = summarizeLiveTests(events(
{ Action: "pass", Package: "app", Test: "TestLivePassed/child" },
{ Action: "pass", Package: "app", Test: "TestLivePassed" },
{ Action: "fail", Package: "repository", Test: "TestLiveFailed/child" },
{ Action: "fail", Package: "repository", Test: "TestLiveFailed" },
{ Action: "fail", Package: "repository" },
{ Action: "skip", Package: "app", Test: "TestLiveSkipped" },
{ Action: "pass", Package: "app", Test: "TestOther" },
), "failure");
assert.equal(report.needsAttention, true);
assert.match(report.markdown, /\| Passed \| 1 \|/);
assert.match(report.markdown, /\| Failed \| 1 \|/);
assert.match(report.markdown, /\| Skipped \| 1 \|/);
assert.match(report.markdown, /`repository\/TestLiveFailed`/);
assert.match(report.markdown, /`app\/TestLiveSkipped`/);
assert.doesNotMatch(report.markdown, /\/child/);
});
test("empty, interrupted and compile-only output cannot look like passing coverage", () => {
for (const input of ["", "# app\ncompiler error", 'null\n{"Action":"fail","Package":"app"}']) {
const report = summarizeLiveTests(input, "failure");
assert.equal(report.needsAttention, true);
assert.match(report.markdown, /No completed TestLive results/);
}
assert.equal(summarizeLiveTests(events({ Action: "pass", Package: "app", Test: "TestLiveOK" }), "cancelled").needsAttention, true);
});
test("successful coverage is clean only when completed tests contain no skips", () => {
assert.equal(summarizeLiveTests(events({ Action: "pass", Package: "app", Test: "TestLiveOK" }), "success").needsAttention, false);
assert.equal(summarizeLiveTests(events({ Action: "skip", Package: "app", Test: "TestLiveSkipped" }), "success").needsAttention, true);
});