From b3529aa327026472798a5f0971dcb325d221ddc6 Mon Sep 17 00:00:00 2001 From: morluto <76467478+morluto@users.noreply.github.com> Date: Tue, 29 Sep 2026 08:44:41 +0800 Subject: [PATCH] test: replace brittle workflow and readme checks --- package-lock.json | 3 +- package.json | 3 +- .../ghidra/realGhidraWindowsWorkflow.test.ts | 56 ++++++++++++------- tests/conformance/readmeConsistency.test.ts | 43 -------------- 4 files changed, 39 insertions(+), 66 deletions(-) diff --git a/package-lock.json b/package-lock.json index 72aa01b0e..5d41e7345 100644 --- a/package-lock.json +++ b/package-lock.json @@ -56,7 +56,8 @@ "turbo": "2.10.5", "typedoc": "0.28.20", "typescript": "5.9.3", - "vitest": "4.1.10" + "vitest": "4.1.10", + "yaml": "2.9.0" }, "engines": { "node": "^22.19.0 || >=24.11.0" diff --git a/package.json b/package.json index 1f985bc67..b8541620d 100644 --- a/package.json +++ b/package.json @@ -200,6 +200,7 @@ "turbo": "2.10.5", "typedoc": "0.28.20", "typescript": "5.9.3", - "vitest": "4.1.10" + "vitest": "4.1.10", + "yaml": "2.9.0" } } diff --git a/tests/conformance/providers/ghidra/realGhidraWindowsWorkflow.test.ts b/tests/conformance/providers/ghidra/realGhidraWindowsWorkflow.test.ts index 1740e512d..b7da7e4c5 100644 --- a/tests/conformance/providers/ghidra/realGhidraWindowsWorkflow.test.ts +++ b/tests/conformance/providers/ghidra/realGhidraWindowsWorkflow.test.ts @@ -1,32 +1,46 @@ import { readFile } from "node:fs/promises"; import { describe, expect, it } from "vitest"; +import { parse } from "yaml"; describe("real Windows Ghidra workflow trust boundary", () => { it("runs only default-branch code on the fixed self-hosted environment", async () => { - const workflow = await readFile( - new URL( - "../../../../.github/workflows/real-ghidra-windows.yml", - import.meta.url, + const workflow = parse( + await readFile( + new URL( + "../../../../.github/workflows/real-ghidra-windows.yml", + import.meta.url, + ), + "utf8", ), - "utf8", ); - expect(workflow).toContain("types: [real-ghidra-windows]"); - expect(workflow).not.toContain("workflow_dispatch:"); - expect(workflow).toContain("contents: read"); - expect(workflow).toContain("if: github.ref == 'refs/heads/main'"); - expect(workflow).toContain("environment: real-ghidra-windows"); - expect(workflow).toContain( - "runs-on: [self-hosted, Windows, x64, ghidra-12-1-2]", - ); - expect(workflow).not.toMatch( - /\$\{\{\s*(?:inputs|github\.event\.(?:inputs|client_payload))\b/u, - ); - expect(workflow).toContain("REA_ANALYSIS_PROVIDER: ghidra"); - expect(workflow).not.toContain("cache: npm"); - expect(workflow).not.toContain("npm run rebuild:native"); - expect(workflow).toContain("npm run verify:ghidra:windows"); - expect(workflow).toContain("windows-ghidra-proof.log"); + expect(workflow.on).toEqual({ + repository_dispatch: { types: ["real-ghidra-windows"] }, + }); + expect(workflow.permissions).toEqual({ contents: "read" }); + expect(workflow).toMatchObject({ + jobs: { + verify: { + if: "github.ref == 'refs/heads/main'", + environment: "real-ghidra-windows", + "runs-on": ["self-hosted", "Windows", "x64", "ghidra-12-1-2"], + steps: [ + {}, + { uses: "actions/setup-node@v4" }, + { run: "npm ci" }, + { + env: { REA_ANALYSIS_PROVIDER: "ghidra" }, + run: "npm run verify:ghidra:windows | Tee-Object -FilePath windows-ghidra-proof.log", + }, + { + uses: "actions/upload-artifact@v4", + with: { path: "windows-ghidra-proof.log" }, + }, + ], + }, + }, + }); + expect(workflow.jobs.verify.steps).toHaveLength(5); }); }); diff --git a/tests/conformance/readmeConsistency.test.ts b/tests/conformance/readmeConsistency.test.ts index 18b15c11f..2afbe3557 100644 --- a/tests/conformance/readmeConsistency.test.ts +++ b/tests/conformance/readmeConsistency.test.ts @@ -2,19 +2,6 @@ import { readFile } from "node:fs/promises"; import { resolve } from "node:path"; import { describe, expect, it } from "vitest"; -import { - ENHANCED_TOOL_CONTRACTS, - OFFICIAL_TOOL_CONTRACTS, - SESSION_TOOL_CONTRACTS, -} from "../../src/contracts/toolContracts.js"; -import { NATIVE_TOOL_CONTRACTS } from "../../src/contracts/nativeToolContracts.js"; -import { ARTIFACT_TOOL_CONTRACTS } from "../../src/contracts/artifactToolContracts.js"; -import { MANAGED_TOOL_CONTRACTS } from "../../src/contracts/managedToolContracts.js"; -import { MANAGED_WORKFLOW_TOOL_CONTRACTS } from "../../src/contracts/managedWorkflowToolContracts.js"; -import { BROWSER_PROVIDER_TOOL_CONTRACTS } from "../../src/contracts/browserProviderToolContracts.js"; -import { ELECTRON_TOOL_CONTRACTS } from "../../src/contracts/electronToolContracts.js"; -import { JAVASCRIPT_RUNTIME_OBSERVATION_TOOL_CONTRACTS } from "../../src/contracts/javascriptRuntimeObservationToolContracts.js"; -import { APPLICATION_TOOL_CONTRACTS } from "../../src/contracts/applicationToolContracts.js"; import { SUPPORTED_CLIENT_DEFINITIONS } from "../../src/application/SupportedClients.js"; import { PRODUCT_IDENTITY } from "../../src/identity.js"; @@ -26,35 +13,6 @@ const readmes = [ "README_ar.md", ] as const; -const expectedToolCounts = [ - OFFICIAL_TOOL_CONTRACTS.length, - ENHANCED_TOOL_CONTRACTS.length, - NATIVE_TOOL_CONTRACTS.length, - ARTIFACT_TOOL_CONTRACTS.length, - MANAGED_TOOL_CONTRACTS.length + MANAGED_WORKFLOW_TOOL_CONTRACTS.length, - BROWSER_PROVIDER_TOOL_CONTRACTS.length, - ELECTRON_TOOL_CONTRACTS.length, - JAVASCRIPT_RUNTIME_OBSERVATION_TOOL_CONTRACTS.length, - APPLICATION_TOOL_CONTRACTS.length, - SESSION_TOOL_CONTRACTS.length, -] as const; - -const toolCountsFromReadme = (content: string, path: string): number[] => { - const lines = content.split(/\r?\n/u); - for (const [index, line] of lines.entries()) { - if (!/^\|\s*-/u.test(line)) continue; - const counts: number[] = []; - for (const row of lines.slice(index + 1)) { - if (!row.trim().startsWith("|")) break; - const count = Number(row.split("|")[2]?.trim()); - if (!Number.isInteger(count)) break; - counts.push(count); - } - if (counts.length === expectedToolCounts.length) return counts; - } - throw new Error(`Missing tool-family inventory table in ${path}`); -}; - const normalizedProse = (content: string): string => content.replace(/\s+/gu, " ").trim(); @@ -83,7 +41,6 @@ describe("localized README product facts", () => { if (path === "README_ar.md") expect(content).toContain("Windows غير مدعوم حاليًا"); expect(content).toContain("MCP-tool_catalog"); - expect(toolCountsFromReadme(content, path)).toEqual(expectedToolCounts); }, );