Track HiveGrid Cloud planning reference
This commit is contained in:
1 parent
b3d5ea6764
commit
e341c5938a
5784 files changed
+1104929
-3
No files matched your search
@@ -0,0 +1,221 @@
|
||||
import { mkdtemp, mkdir, rm, writeFile } from "node:fs/promises";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import {
|
||||
failureCount,
|
||||
gates,
|
||||
productionDocsDocumentationInventoryScanRoots,
|
||||
productionDocsDocumentationInventoryPatterns,
|
||||
renderReport,
|
||||
reportPath,
|
||||
runProductionDocsDocumentationInventory,
|
||||
} from "./verify-production-docs-baseline.mjs";
|
||||
|
||||
const focusedTargets = ["scripts/verify-production-docs-baseline.test.mjs", "scripts/verify-ci-baseline.test.mjs", "scripts/verify-gitea-ci-workflow.test.mjs"];
|
||||
const forbiddenCommandPattern = /playwright|cypress|browser|e2e/i;
|
||||
|
||||
describe("Production Docs baseline runner configuration", () => {
|
||||
it("defines the required non-E2E gates and report path", () => {
|
||||
expect(reportPath).toMatch(/\.tc\/baselines\/production-docs\/baseline-health\.md$/);
|
||||
expect(gates.map((gate) => gate.id)).toEqual(["typecheck", "lint", "vitest-productionDocs-focused", "productionDocs-production-docs-inventory"]);
|
||||
expect(gates.some((gate) => [gate.command, ...(gate.args ?? [])].some((arg) => forbiddenCommandPattern.test(arg)))).toBe(false);
|
||||
expect(productionDocsDocumentationInventoryScanRoots).toEqual([
|
||||
"README.md",
|
||||
"docs/new-project.md",
|
||||
"docs/configuration.md",
|
||||
"docs/db-ci.md",
|
||||
"docs/mail-auth.md",
|
||||
"docs/deployment.md",
|
||||
"docs/security/runbook.md",
|
||||
"packages/db/README.md",
|
||||
"packages/mail/README.md",
|
||||
"apps/api/README.md",
|
||||
"apps/worker/README.md",
|
||||
".github/workflows/cla.yml",
|
||||
]);
|
||||
});
|
||||
|
||||
it("keeps exact focused Vitest targets and excludes browser/E2E commands", () => {
|
||||
const vitestGate = gates.find((gate) => gate.id === "vitest-productionDocs-focused");
|
||||
|
||||
expect(vitestGate?.args).toEqual(["exec", "vitest", "run", ...focusedTargets]);
|
||||
expect(vitestGate?.args?.join(" ")).not.toMatch(forbiddenCommandPattern);
|
||||
});
|
||||
|
||||
it("defines production-doc inventory term buckets", () => {
|
||||
expect(productionDocsDocumentationInventoryPatterns.map(({ id }) => id)).toEqual([
|
||||
"quickstart-new-project-local-dev",
|
||||
"env-config",
|
||||
"database-migration",
|
||||
"mail",
|
||||
"worker-queue",
|
||||
"api",
|
||||
"deployment",
|
||||
"security",
|
||||
"observability",
|
||||
"plugins",
|
||||
"upgrades",
|
||||
"troubleshooting",
|
||||
"link-check-command",
|
||||
"todo-tbd-marker",
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Production Docs baseline runner failure counting", () => {
|
||||
it("counts failed typecheck diagnostics conservatively", () => {
|
||||
expect(failureCount("typecheck", "src/a.ts(1,1): error TS2307: Cannot find module\nsrc/b.ts(2,2): error TS2322: Type mismatch", "", 1)).toBe(2);
|
||||
expect(failureCount("typecheck", "Build failed", "", 1)).toBe(1);
|
||||
});
|
||||
|
||||
it("counts failed ESLint diagnostics conservatively", () => {
|
||||
expect(failureCount("lint", "✖ 4 problems (3 errors, 1 warning)", "", 1)).toBe(3);
|
||||
expect(failureCount("lint", "2 errors and 0 warnings", "", 1)).toBe(2);
|
||||
expect(failureCount("lint", "Lint crashed", "", 1)).toBe(1);
|
||||
});
|
||||
|
||||
it("counts failed Vitest diagnostics conservatively", () => {
|
||||
expect(failureCount("vitest-productionDocs-focused", "Tests 2 failed | 8 passed", "", 1)).toBe(2);
|
||||
expect(failureCount("vitest-productionDocs-focused", "Test Files 1 failed | 2 passed", "", 1)).toBe(1);
|
||||
expect(failureCount("vitest-productionDocs-focused", "Vitest crashed", "", 1)).toBe(1);
|
||||
});
|
||||
|
||||
it("returns zero for clean exits and read-only inventory gates", () => {
|
||||
expect(failureCount("lint", "warning only", "", 0)).toBe(0);
|
||||
expect(failureCount("productionDocs-production-docs-inventory", "total matches: 12", "", 1)).toBe(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Production Docs production docs inventory scan", () => {
|
||||
it("scans configured roots, counts readiness terms, and ignores dependency/generated/TC paths", async () => {
|
||||
const root = await mkdtemp(join(tmpdir(), "productionDocs-baseline-inventory-"));
|
||||
await mkdir(join(root, "docs", "security"), { recursive: true });
|
||||
await mkdir(join(root, "packages", "db"), { recursive: true });
|
||||
await mkdir(join(root, "packages", "mail"), { recursive: true });
|
||||
await mkdir(join(root, "apps", "api"), { recursive: true });
|
||||
await mkdir(join(root, "docs", "node_modules", "ignored"), { recursive: true });
|
||||
await mkdir(join(root, "docs", ".tc"), { recursive: true });
|
||||
await mkdir(join(root, "docs", "generated"), { recursive: true });
|
||||
|
||||
await writeFile(
|
||||
join(root, "README.md"),
|
||||
[
|
||||
"# Quickstart",
|
||||
"New project setup and local dev installation use `.env` and `pnpm run typecheck`.",
|
||||
"DATABASE_URL PostgreSQL Prisma migration seed.",
|
||||
"MailerSend email webhook signing Svix.",
|
||||
"Worker queue job BullMQ Redis background.",
|
||||
"API endpoint OpenAPI request response authentication authorization.",
|
||||
"Deployment Docker Gitea Coolify registry production CI.",
|
||||
"Security secret token csrf rate limit runbook.",
|
||||
"Observability logging metrics tracing monitoring alert healthcheck.",
|
||||
"Plugin extension MCP integration hook.",
|
||||
"Upgrade migration guide breaking change version release.",
|
||||
"Troubleshooting debug failure error known issue FAQ problem.",
|
||||
"See [docs](docs/new-project.md) and https://example.com.",
|
||||
"TODO TBD FIXME XXX follow-up Follow-up",
|
||||
].join("\n"),
|
||||
"utf8",
|
||||
);
|
||||
await writeFile(join(root, "docs", "new-project.md"), "new-project local development config API", "utf8");
|
||||
await writeFile(join(root, "docs", "configuration.md"), "configuration .env API_KEY SECRET", "utf8");
|
||||
await writeFile(join(root, "docs", "db-ci.md"), "database migrate schema", "utf8");
|
||||
await writeFile(join(root, "docs", "security", "runbook.md"), "security runbook observability", "utf8");
|
||||
await writeFile(join(root, "packages", "db", "README.md"), "Postgres Prisma migration", "utf8");
|
||||
await writeFile(join(root, "packages", "mail", "README.md"), "mail SMTP transactional", "utf8");
|
||||
await writeFile(join(root, "apps", "api", "README.md"), "REST route endpoint", "utf8");
|
||||
await writeFile(join(root, "docs", "node_modules", "ignored", "ignored.md"), "TODO API mail worker", "utf8");
|
||||
await writeFile(join(root, "docs", ".tc", "ignored.md"), "TODO API mail worker", "utf8");
|
||||
await writeFile(join(root, "docs", "generated", "ignored.md"), "TODO API mail worker", "utf8");
|
||||
|
||||
const inventory = await runProductionDocsDocumentationInventory(root);
|
||||
const allMatches = inventory.matches.join("\n");
|
||||
|
||||
expect(inventory.roots).toEqual([
|
||||
"README.md",
|
||||
"docs/new-project.md",
|
||||
"docs/configuration.md",
|
||||
"docs/db-ci.md",
|
||||
"docs/security/runbook.md",
|
||||
"packages/db/README.md",
|
||||
"packages/mail/README.md",
|
||||
"apps/api/README.md",
|
||||
]);
|
||||
expect(inventory.missingRoots).toEqual(["docs/mail-auth.md", "docs/deployment.md", "apps/worker/README.md", ".github/workflows/cla.yml"]);
|
||||
expect(inventory.filesScanned).toBe(8);
|
||||
expect(inventory.counts).toMatchObject({
|
||||
"quickstart-new-project-local-dev": 8,
|
||||
"env-config": 7,
|
||||
"database-migration": 11,
|
||||
mail: 7,
|
||||
"worker-queue": 6,
|
||||
api: 11,
|
||||
deployment: 7,
|
||||
security: 9,
|
||||
observability: 8,
|
||||
plugins: 5,
|
||||
upgrades: 5,
|
||||
troubleshooting: 7,
|
||||
"link-check-command": 3,
|
||||
"todo-tbd-marker": 6,
|
||||
});
|
||||
expect(allMatches).toContain("README.md");
|
||||
expect(allMatches).toContain("docs/new-project.md");
|
||||
expect(allMatches).not.toContain("node_modules/ignored/ignored.md");
|
||||
expect(allMatches).not.toContain(".tc/ignored.md");
|
||||
expect(allMatches).not.toContain("generated/ignored.md");
|
||||
});
|
||||
|
||||
it("records absent documentation roots without failing the read-only inventory gate", async () => {
|
||||
const root = await mkdtemp(join(tmpdir(), "productionDocs-baseline-missing-"));
|
||||
await mkdir(join(root, "docs"), { recursive: true });
|
||||
await writeFile(join(root, "README.md"), "Quickstart", "utf8");
|
||||
await rm(join(root, "README.md"));
|
||||
|
||||
const inventory = await runProductionDocsDocumentationInventory(root);
|
||||
|
||||
expect(inventory.roots).toEqual([]);
|
||||
expect(inventory.missingRoots).toEqual(productionDocsDocumentationInventoryScanRoots);
|
||||
expect(inventory.filesScanned).toBe(0);
|
||||
expect(inventory.totalMatches).toBe(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Production Docs report rendering", () => {
|
||||
it("renders gate metadata, fingerprints, and inventory counts", () => {
|
||||
const report = renderReport([
|
||||
{ id: "typecheck", command: "pnpm run typecheck", exitCode: 2, durationMs: 1500, failureCount: 7, fingerprint: { hash: "abc123def456", excerpt: "error TS2322" } },
|
||||
{
|
||||
id: "productionDocs-production-docs-inventory",
|
||||
command: "read-only Production Docs production docs inventory",
|
||||
exitCode: 0,
|
||||
durationMs: 42,
|
||||
failureCount: 0,
|
||||
inventory: {
|
||||
roots: ["README.md"],
|
||||
missingRoots: ["docs/deployment.md"],
|
||||
filesScanned: 1,
|
||||
counts: { "quickstart-new-project-local-dev": 1, mail: 2 },
|
||||
totalMatches: 3,
|
||||
matches: [],
|
||||
},
|
||||
fingerprint: { hash: "fed456abc123", excerpt: "quickstart-new-project-local-dev: 1" },
|
||||
},
|
||||
]);
|
||||
|
||||
expect(report).toContain("# Production Docs Baseline Health");
|
||||
expect(report).toContain("non-E2E baseline gates for Production Docs baseline");
|
||||
expect(report).toContain("production-doc readiness terms");
|
||||
expect(report).toContain("## typecheck");
|
||||
expect(report).toContain("## productionDocs-production-docs-inventory");
|
||||
expect(report).toContain("- Exitcode: 2");
|
||||
expect(report).toContain("- Failure Count: 7");
|
||||
expect(report).toContain("- Output Fingerprint: abc123def456");
|
||||
expect(report).toContain("- Inventory Roots: README.md");
|
||||
expect(report).toContain("- Missing Roots Skipped: docs/deployment.md");
|
||||
expect(report).toContain(" - quickstart-new-project-local-dev: 1");
|
||||
expect(report).toContain("- Total Inventory Matches: 3");
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user