mirror of
https://github.com/morluto/rea.git
synced 2026-11-18 04:34:13 +00:00
fix(ci): classify static/doc script inputs in change-plan and trace URL fixtures
This commit is contained in:
1 parent
237b1ea5b3
commit
8749adefe5
5 files changed
+140
-5
No files matched your search
@@ -46,6 +46,42 @@ const PORTABLE_CI_REPORTERS = new Set([
|
||||
"scripts/ci/test-timing-reporter.mjs",
|
||||
"scripts/ci/test-history.mjs",
|
||||
]);
|
||||
// Static architecture/lint/schema/test-project verifiers and baselines run in
|
||||
// static/build/portable lanes (`code: true`) without requiring host package lanes.
|
||||
const STATIC_CODE_ONLY_INPUTS = [
|
||||
"scripts/lib/module-layers.baseline.json",
|
||||
"scripts/lib/module-layers.*",
|
||||
"scripts/lib/module-boundaries.*",
|
||||
"scripts/verify-module-boundaries.mjs",
|
||||
"scripts/verify/architecture-guards.mjs",
|
||||
"scripts/verify/*-guard.*",
|
||||
"scripts/verify/rea-numeric-limits.mjs",
|
||||
"scripts/verify/source-tokens.*",
|
||||
"scripts/verify/keyed-first-match.*",
|
||||
"scripts/verify/reason-marker.*",
|
||||
"scripts/verify/baselines/*.json",
|
||||
"scripts/lint/**",
|
||||
".oxlintrc.json",
|
||||
".oxfmtrc.json",
|
||||
".jscpd.json",
|
||||
"knip.json",
|
||||
"tsconfig.scripts.json",
|
||||
"scripts/verify-advertised-schemas.mjs",
|
||||
"scripts/verify/advertised-schemas/**",
|
||||
"scripts/verify/mcp-client-validation.*",
|
||||
"scripts/verify-test-discovery.mjs",
|
||||
"scripts/verify-test-temp-hygiene.mjs",
|
||||
"scripts/lib/test-projects.mjs",
|
||||
];
|
||||
// Documentation and product-catalog verifiers/generators exercised by `docs:check`
|
||||
// and portable tests without changing packaged host behavior.
|
||||
const DOCS_AND_CODE_INPUTS = [
|
||||
"scripts/check-doc-facts.mjs",
|
||||
"scripts/generate-error-schema.mjs",
|
||||
"scripts/lib/product-catalog.*",
|
||||
"scripts/lib/catalog-core.*",
|
||||
"scripts/lib/catalog-cli.*",
|
||||
];
|
||||
const matchesAny = (file, patterns) =>
|
||||
patterns.some((pattern) => matchesGlob(file, pattern));
|
||||
|
||||
@@ -234,6 +270,15 @@ export function planChanges(request, repository) {
|
||||
selected.code = true;
|
||||
return;
|
||||
}
|
||||
if (matchesAny(file, DOCS_AND_CODE_INPUTS)) {
|
||||
selected.docs = true;
|
||||
selected.code = true;
|
||||
return;
|
||||
}
|
||||
if (matchesAny(file, STATIC_CODE_ONLY_INPUTS)) {
|
||||
selected.code = true;
|
||||
return;
|
||||
}
|
||||
// A shared boundary is not evidence that every provider or host changed.
|
||||
// One lane that names the file is path evidence; a lane that only covers
|
||||
// it through a `**` directory glob is not. Several naming lanes means the
|
||||
@@ -293,7 +338,10 @@ export function planChanges(request, repository) {
|
||||
// full qualification retains every native host.
|
||||
selected.runtime = true;
|
||||
reasons.push(`Unowned runtime source: ${file}`);
|
||||
} else if (file.startsWith(".agents/skills/")) {
|
||||
} else if (
|
||||
file.startsWith(".agents/skills/") ||
|
||||
file.startsWith(".cursor-plugin/skills/")
|
||||
) {
|
||||
selected.runtime = true;
|
||||
selected.docs = true;
|
||||
} else {
|
||||
|
||||
@@ -813,4 +813,6 @@ export const MANUAL_VERIFIERS = [
|
||||
"scripts/verify-packaged-ghidra-windows.mjs",
|
||||
"scripts/verify-wasm-artifact.mjs",
|
||||
"scripts/verify-packaged-wasm-artifact.mjs",
|
||||
"scripts/lib/ghidra-*-snapshot-e2e.mjs",
|
||||
"scripts/lib/real-ghidra-snapshot-lifecycle.mjs",
|
||||
];
|
||||
@@ -58,6 +58,7 @@ const LAUNCHES_BUILT_RUNTIME =
|
||||
const isCheckerInput = (path) =>
|
||||
/\.d\.m?ts$/u.test(path) ||
|
||||
path === "scripts/lib/module-layers.baseline.json" ||
|
||||
path === "scripts/check-doc-facts.mjs" ||
|
||||
path === ".git-blame-ignore-revs" ||
|
||||
path === "scripts/run-python-tests.py" ||
|
||||
/^tests\/support\/analysis-efficiency\/.+\.py$/u.test(path) ||
|
||||
@@ -126,6 +127,12 @@ const isProse = (path) =>
|
||||
!DOCS_CODE.test(path) &&
|
||||
!path.endsWith("/package.json")) ||
|
||||
path.startsWith("licenses/");
|
||||
const isNonModuleFixture = (path) =>
|
||||
path.startsWith("tests/fixtures/") &&
|
||||
!isModule(path) &&
|
||||
!isProse(path) &&
|
||||
!isCheckerInput(path) &&
|
||||
explicitFixtureOwners(path).length === 0;
|
||||
/** Why a changed path cannot be traced to tests, if it cannot. */
|
||||
const untracedInput = (path) =>
|
||||
!isTest(path) && SHARED_BOUNDARY.test(path)
|
||||
@@ -133,6 +140,7 @@ const untracedInput = (path) =>
|
||||
: !isModule(path) &&
|
||||
!isProse(path) &&
|
||||
!isCheckerInput(path) &&
|
||||
!isNonModuleFixture(path) &&
|
||||
explicitFixtureOwners(path).length === 0
|
||||
? `Input is not traced to tests: ${path}`
|
||||
: undefined;
|
||||
@@ -181,6 +189,7 @@ export function traceAffectedTests({ files, snapshot }) {
|
||||
const changedModules = files.filter(
|
||||
(path) => isModule(path) && !isTest(path),
|
||||
);
|
||||
const changedNonModuleFixtures = files.filter(isNonModuleFixture);
|
||||
for (const path of files) {
|
||||
if (isTest(path)) select(path, "changed");
|
||||
for (const owner of explicitFixtureOwners(path)) {
|
||||
@@ -208,7 +217,10 @@ export function traceAffectedTests({ files, snapshot }) {
|
||||
};
|
||||
// Close over test-only helpers, verifiers and shared script modules, then
|
||||
// take the tests that import a change.
|
||||
const affected = throughHelpers(changedModules);
|
||||
const affected = throughHelpers([
|
||||
...changedModules,
|
||||
...changedNonModuleFixtures,
|
||||
]);
|
||||
for (const test of tests)
|
||||
if (imports.get(test).some((target) => affected.has(target)))
|
||||
select(test, "imports");
|
||||
@@ -223,6 +235,25 @@ export function traceAffectedTests({ files, snapshot }) {
|
||||
const names = (test, paths) =>
|
||||
paths.some((path) => (sources.get(test) ?? "").includes(path));
|
||||
|
||||
// A changed non-module fixture under tests/fixtures/ that no test reaches
|
||||
// via URL/import or path literal (for example, a directory-scanned asset)
|
||||
// fails closed to the complete suite.
|
||||
for (const fixture of changedNonModuleFixtures) {
|
||||
const reached = throughHelpers([fixture]);
|
||||
const paths = [
|
||||
fixture,
|
||||
...[...reached].filter((path) => path.startsWith("scripts/")),
|
||||
];
|
||||
if (
|
||||
!tests.some(
|
||||
(test) =>
|
||||
imports.get(test).some((target) => reached.has(target)) ||
|
||||
names(test, paths),
|
||||
)
|
||||
)
|
||||
untraced.push(`Input is not traced to tests: ${fixture}`);
|
||||
}
|
||||
|
||||
// A changed shared module that no test reaches has no coverage in a
|
||||
// selection, even when other changes select tests.
|
||||
for (const library of changedModules.filter(isScriptLibrary)) {
|
||||
@@ -240,13 +271,14 @@ export function traceAffectedTests({ files, snapshot }) {
|
||||
|
||||
// A shared script module that another script, configuration file, hook or
|
||||
// workflow imports or names as a standalone file name can shape every run.
|
||||
// Require a token boundary before the basename so `verify-module-boundaries.mjs`
|
||||
// in package.json does not falsely match `scripts/lib/module-boundaries.mjs`.
|
||||
// Ignore single-line comments and require a non-hyphen token boundary before
|
||||
// the basename so hyphenated wrapper names do not match shared library names.
|
||||
const namesScriptBasename = (source, libraryPath) => {
|
||||
const code = source.replace(/^\s*(?:\/\/|#).*$/gmu, "");
|
||||
const escaped = posix
|
||||
.basename(libraryPath)
|
||||
.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&");
|
||||
return new RegExp(`(?<![\\w-])${escaped}(?![\\w.-])`, "u").test(source);
|
||||
return new RegExp(`(?<![\\w-])${escaped}(?![\\w.-])`, "u").test(code);
|
||||
};
|
||||
const libraries = [...affected].filter(isScriptLibrary);
|
||||
if (libraries.length) {
|
||||
|
||||
@@ -556,6 +556,39 @@ it("routes license inventories to docs checks and keeps blame-ignore edits forma
|
||||
runtime: false,
|
||||
package: false,
|
||||
});
|
||||
for (const staticOnly of [
|
||||
"scripts/lib/module-layers.baseline.json",
|
||||
"scripts/verify/architecture-guards.mjs",
|
||||
"scripts/verify/baselines/incur-import.json",
|
||||
"tsconfig.scripts.json",
|
||||
]) {
|
||||
expect(await classifyPaths([staticOnly]), staticOnly).toMatchObject({
|
||||
code: true,
|
||||
docs: false,
|
||||
runtime: false,
|
||||
package: false,
|
||||
});
|
||||
}
|
||||
for (const docsAndCode of [
|
||||
"scripts/check-doc-facts.mjs",
|
||||
"scripts/lib/product-catalog.mjs",
|
||||
]) {
|
||||
expect(await classifyPaths([docsAndCode]), docsAndCode).toMatchObject({
|
||||
code: true,
|
||||
docs: true,
|
||||
runtime: false,
|
||||
package: false,
|
||||
});
|
||||
}
|
||||
expect(
|
||||
await classifyPaths([
|
||||
".cursor-plugin/skills/reverse-engineer-anything/SKILL.md",
|
||||
]),
|
||||
).toMatchObject({
|
||||
docs: true,
|
||||
runtime: true,
|
||||
package: false,
|
||||
});
|
||||
});
|
||||
|
||||
it("passes the workflow environment through the entrypoint unchanged", async () => {
|
||||
|
||||
@@ -273,6 +273,7 @@ it("traces shared script modules to their tests and falls back for other consume
|
||||
'{"scripts":{"verify:shared":"node scripts/verify-shared.mjs"}}',
|
||||
"tsconfig.scripts.json": '{"include":["scripts/lib/shared.mjs"]}',
|
||||
"stryker.config.mjs": 'import "./scripts/lib/shared.mjs";',
|
||||
"scripts/check-doc-facts.mjs": 'import "./lib/shared.mjs";',
|
||||
"scripts/ci/scopes.mjs":
|
||||
'export const S = ["scripts/lib/shared.mjs"];',
|
||||
},
|
||||
@@ -282,6 +283,25 @@ it("traces shared script modules to their tests and falls back for other consume
|
||||
"tests/boundary/filesystem/shared.test.ts",
|
||||
"tests/boundary/filesystem/verifier.test.ts",
|
||||
]);
|
||||
expect(
|
||||
selectedFiles(
|
||||
plan(["tests/fixtures/card.json"], {
|
||||
"tests/fixtures/card.json": '{"ok":true}',
|
||||
"tests/boundary/mcp/card.test.ts":
|
||||
'new URL("../../fixtures/card.json", import.meta.url);',
|
||||
"tests/boundary/mcp/unrelated.test.ts": 'import "../../../src/a.js";',
|
||||
}),
|
||||
),
|
||||
).toEqual(["tests/boundary/mcp/card.test.ts"]);
|
||||
expect(
|
||||
plan(["tests/fixtures/unreferenced.bin"], {
|
||||
"tests/fixtures/unreferenced.bin": "raw",
|
||||
"tests/boundary/mcp/unrelated.test.ts": 'import "../../../src/a.js";',
|
||||
}),
|
||||
).toMatchObject({
|
||||
mode: "full",
|
||||
reason: "Input is not traced to tests: tests/fixtures/unreferenced.bin",
|
||||
});
|
||||
expect(
|
||||
plan(["scripts/lib/shared.mjs"], {
|
||||
...sources,
|
||||
|
||||
Reference in new issue
Block a user