9dfa06ffee
Docker image / Build (linux/amd64) (push) Has been cancelled
Docker image / Build (linux/arm64) (push) Has been cancelled
Docker image / Merge release multi-arch manifest (push) Has been cancelled
Docker image / Merge debug multi-arch manifest (push) Has been cancelled
Docker image / Build public push gateway (linux/amd64) (push) Has been cancelled
Docker image / Build public push gateway (linux/arm64) (push) Has been cancelled
Docker image / Publish public push gateway image (push) Has been cancelled
Sprig image / Build (linux/amd64) (push) Has been cancelled
Sprig image / Build (linux/arm64) (push) Has been cancelled
Sprig image / Merge multi-arch manifest (push) Has been cancelled
Harbor Buzz Orchestra / Python tests and lint (push) Has been cancelled
CI / Detect Changed Paths (push) Has been cancelled
CI / Rust Lint (push) Has been cancelled
CI / Unit Tests (push) Has been cancelled
CI / Desktop Core (push) Has been cancelled
CI / Desktop Smoke E2E (1) (push) Has been cancelled
CI / Desktop Smoke E2E (2) (push) Has been cancelled
CI / Desktop Smoke E2E (3) (push) Has been cancelled
CI / Desktop Smoke E2E (4) (push) Has been cancelled
CI / Desktop (push) Has been cancelled
CI / Desktop E2E Relay (push) Has been cancelled
CI / Desktop E2E Integration (1/2) (push) Has been cancelled
CI / Desktop E2E Integration (2/2) (push) Has been cancelled
CI / Desktop E2E Integration (push) Has been cancelled
CI / Backend Integration (relay e2e) (push) Has been cancelled
CI / Relay E2E (push) Has been cancelled
CI / Web (push) Has been cancelled
CI / Mobile (push) Has been cancelled
CI / Security (push) Has been cancelled
CI / Dead Token Reference Guard (push) Has been cancelled
CI / Server Cross-Compile (aarch64-unknown-linux-musl) (push) Has been cancelled
CI / Server Cross-Compile (x86_64-unknown-linux-musl) (push) Has been cancelled
CI / Windows Rust (x86_64-pc-windows-msvc) (push) Has been cancelled
CI / Desktop Build (macOS) (push) Has been cancelled
helm chart / lint + unittest + render matrix (push) Has been cancelled
helm chart / install on kind (gated) (push) Has been cancelled
helm chart / publish chart to GHCR (push) Has been cancelled
Mesh Lifecycle / Relay-Driven Mesh Lifecycle Smoke (push) Has been cancelled
Sprig / Build (aarch64-unknown-linux-musl) (push) Has been cancelled
Sprig / Build (x86_64-unknown-linux-musl) (push) Has been cancelled
Sprig / Publish rolling release (push) Has been cancelled
Sprig / Publish tagged release (push) Has been cancelled
Signed-off-by: cls_宁波本机 <908705107@qq.com>
72 lines
2.4 KiB
JavaScript
72 lines
2.4 KiB
JavaScript
import { appendFile, readFile } from "node:fs/promises";
|
||
|
||
// Playwright's `retries: 2` (desktop/playwright.config.ts) lets a test fail
|
||
// then pass on retry with no durable signal beyond a one-line "N flaky" in
|
||
// the console log — the exact gap that hid the stream.spec.ts membership
|
||
// race (#1798) for months. This walks the JSON reporter's suite tree
|
||
// (recursive: `describe` blocks nest as child `suites`) and appends any
|
||
// `status === "flaky"` test to the job's GitHub Actions summary so retried
|
||
// failures stay visible even when the shard ultimately goes green.
|
||
//
|
||
// Usage: node scripts/summarize-flaky-tests.mjs <report.json> <run-label>
|
||
|
||
function collectFlakyTests(suite, out) {
|
||
for (const spec of suite.specs ?? []) {
|
||
for (const test of spec.tests ?? []) {
|
||
if (test.status !== "flaky") continue;
|
||
out.push({
|
||
title: `${suite.file} › ${spec.title}`,
|
||
project: test.projectName,
|
||
attempts: test.results?.length ?? 0,
|
||
});
|
||
}
|
||
}
|
||
for (const child of suite.suites ?? []) {
|
||
collectFlakyTests(child, out);
|
||
}
|
||
}
|
||
|
||
const [reportPath, runLabel] = process.argv.slice(2);
|
||
if (!reportPath || !runLabel) {
|
||
console.error(
|
||
"Usage: node scripts/summarize-flaky-tests.mjs <report.json> <run-label>",
|
||
);
|
||
process.exit(1);
|
||
}
|
||
|
||
// This step runs `if: !cancelled()` purely to surface flaky tests — it must
|
||
// never fail the job on its own, so a malformed/unexpected report (from a
|
||
// Playwright version bump or a crashed run) is swallowed, not thrown.
|
||
try {
|
||
const report = JSON.parse(await readFile(reportPath, "utf8"));
|
||
|
||
const flaky = [];
|
||
for (const suite of report.suites ?? []) {
|
||
collectFlakyTests(suite, flaky);
|
||
}
|
||
|
||
if (flaky.length > 0) {
|
||
const escapeCell = (value) => String(value).replaceAll("|", "\\|");
|
||
const rows = flaky
|
||
.map(
|
||
(t) =>
|
||
`| ${escapeCell(t.title)} | ${escapeCell(t.project)} | ${t.attempts} |`,
|
||
)
|
||
.join("\n");
|
||
const summary =
|
||
`### Flaky tests — ${runLabel}\n\n` +
|
||
`${flaky.length} test(s) failed at least once before passing on retry:\n\n` +
|
||
"| Test | Project | Attempts |\n| --- | --- | --- |\n" +
|
||
`${rows}\n`;
|
||
|
||
console.log(summary);
|
||
|
||
const summaryFile = process.env.GITHUB_STEP_SUMMARY;
|
||
if (summaryFile) {
|
||
await appendFile(summaryFile, `${summary}\n`);
|
||
}
|
||
}
|
||
} catch (error) {
|
||
console.log(`Skipping flaky-test summary: ${error.message}`);
|
||
}
|