CI: tighten bundled plugin boundary ratchet
This commit is contained in:
parent
1f11ff2eab
commit
70265fcc7e
@ -70,7 +70,10 @@ export function classifyPluginBoundaryImport(specifier, filePath, options = {})
|
||||
return null;
|
||||
}
|
||||
|
||||
if (normalizedSpecifier.includes("plugin-sdk-internal")) {
|
||||
if (
|
||||
normalizedSpecifier === "openclaw/plugin-sdk-internal" ||
|
||||
normalizedSpecifier.startsWith("openclaw/plugin-sdk-internal/")
|
||||
) {
|
||||
return {
|
||||
kind: "plugin-sdk-internal",
|
||||
reason: "imports non-public plugin-sdk-internal surface",
|
||||
@ -314,13 +317,16 @@ export async function collectCurrentViolations(options = {}) {
|
||||
|
||||
const deduped = [...new Map(violations.map((entry) => [toBaselineKey(entry), entry])).values()];
|
||||
|
||||
return deduped.toSorted((left, right) => {
|
||||
const pathCompare = left.path.localeCompare(right.path);
|
||||
if (pathCompare !== 0) {
|
||||
return pathCompare;
|
||||
}
|
||||
return left.specifier.localeCompare(right.specifier);
|
||||
});
|
||||
return {
|
||||
files,
|
||||
violations: deduped.toSorted((left, right) => {
|
||||
const pathCompare = left.path.localeCompare(right.path);
|
||||
if (pathCompare !== 0) {
|
||||
return pathCompare;
|
||||
}
|
||||
return left.specifier.localeCompare(right.specifier);
|
||||
}),
|
||||
};
|
||||
}
|
||||
|
||||
function printViolations(header, violations) {
|
||||
@ -337,8 +343,7 @@ function printViolations(header, violations) {
|
||||
}
|
||||
|
||||
async function main() {
|
||||
const files = await collectBundledPluginSourceFiles(repoRoot);
|
||||
const currentViolations = await collectCurrentViolations({ repoRoot });
|
||||
const { files, violations: currentViolations } = await collectCurrentViolations({ repoRoot });
|
||||
const baseline = await loadViolationBaseline();
|
||||
const { newViolations, resolvedViolations } = compareViolationBaseline(
|
||||
currentViolations,
|
||||
@ -353,7 +358,7 @@ async function main() {
|
||||
if (resolvedViolations.length > 0) {
|
||||
console.error("");
|
||||
console.error(
|
||||
`Note: ${resolvedViolations.length} baseline violation(s) were removed; delete them from ${path.relative(repoRoot, baselinePath)} after this change lands.`,
|
||||
`Note: ${resolvedViolations.length} baseline violation(s) are already resolved. While fixing the above, also remove them from ${path.relative(repoRoot, baselinePath)}.`,
|
||||
);
|
||||
}
|
||||
console.error("");
|
||||
|
||||
@ -36,6 +36,12 @@ describe("check-plugin-boundary-ratchet", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("does not reject same-plugin files that merely contain plugin-sdk-internal in the filename", () => {
|
||||
expect(
|
||||
classifyPluginBoundaryImport("./plugin-sdk-internal-fixture.js", extensionFile, { repoRoot }),
|
||||
).toBeNull();
|
||||
});
|
||||
|
||||
it("rejects direct core src imports", () => {
|
||||
expect(
|
||||
classifyPluginBoundaryImport(
|
||||
@ -87,7 +93,7 @@ describe("check-plugin-boundary-ratchet", () => {
|
||||
line: 3,
|
||||
preferredReplacement:
|
||||
"Use openclaw/plugin-sdk/* or openclaw/plugin-sdk/compat temporarily.",
|
||||
reason: "imports non-public plugin-sdk-internal surface",
|
||||
reason: "reaches into non-public plugin-sdk-internal implementation",
|
||||
specifier: "../../../src/plugin-sdk-internal/discord.js",
|
||||
},
|
||||
{
|
||||
@ -125,7 +131,7 @@ describe("check-plugin-boundary-ratchet", () => {
|
||||
line: 3,
|
||||
preferredReplacement:
|
||||
"Use openclaw/plugin-sdk/* or openclaw/plugin-sdk/compat temporarily.",
|
||||
reason: "imports non-public plugin-sdk-internal surface",
|
||||
reason: "reaches into non-public plugin-sdk-internal implementation",
|
||||
specifier: "../../../src/plugin-sdk-internal/discord.js",
|
||||
},
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user