Skip to content

Commit ba88717

Browse files
gustavoliraclaude
andcommitted
test: lock the {{inherit}} safety guarantee + tidy helper comment
Add a test proving a DPDY plugin resolves to {{inherit}} and is never swapped to a __coverage tag even with E2E_NIGHTLY_COVERAGE on — the core safety guarantee, since {{inherit}} points at RHDH's catalog image, which we can't instrument. Also fix a sentence fragment in the toCoverageImageRef comment. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 33fc3f8 commit ba88717

2 files changed

Lines changed: 33 additions & 2 deletions

File tree

src/utils/plugin-metadata.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,9 @@ function toDisplayName(packageName: string): string {
207207
}
208208

209209
// Append the __coverage suffix to an OCI image tag, before the optional
210-
// !<extractPath>. The instrumented variant the overlay builds. The regex is
211-
// greedy up to the first `!`, so the suffix always lands at the end of the tag.
210+
// !<extractPath> — the instrumented variant the overlay's release publish
211+
// builds. The tag group is greedy up to the first `!`, so the suffix always
212+
// lands at the end of the tag.
212213
function toCoverageImageRef(ref: string): string {
213214
return ref.replace(/(:[^!]+)/, "$1__coverage");
214215
}

src/utils/tests/plugin-metadata.nightly.test.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1075,4 +1075,34 @@ describe("processPluginsForDeployment — nightly coverage swap", () => {
10751075
await fs.remove(path.resolve(metadataDir, ".."));
10761076
}
10771077
});
1078+
1079+
it("does not swap a DPDY plugin (resolves to {{inherit}}) even when opted in", async () => {
1080+
// Safety guarantee: a plugin in default.packages.yaml resolves via the
1081+
// {{inherit}} branch (RHDH's catalog image, which we can't instrument), so
1082+
// the coverage swap must never reach it — otherwise the nightly would point
1083+
// at a __coverage tag that doesn't exist.
1084+
process.env.E2E_NIGHTLY_COVERAGE = "true";
1085+
const metadataDir = await createCoverageWorkspace({
1086+
rolledOut: true,
1087+
role: "frontend-plugin",
1088+
});
1089+
try {
1090+
const result = await processPluginsForDeployment(
1091+
config,
1092+
metadataDir,
1093+
new Set(["@red-hat-developer-hub/backstage-plugin-theme"]), // in DPDY
1094+
);
1095+
assert.strictEqual(
1096+
result.plugins![0].package,
1097+
"oci://registry.access.redhat.com/rhdh/red-hat-developer-hub-backstage-plugin-theme:{{inherit}}",
1098+
"DPDY plugin must resolve to {{inherit}}, never to a __coverage tag",
1099+
);
1100+
assert.ok(
1101+
!result.plugins![0].package.includes("__coverage"),
1102+
"{{inherit}} ref must not be swapped to a __coverage image",
1103+
);
1104+
} finally {
1105+
await fs.remove(path.resolve(metadataDir, ".."));
1106+
}
1107+
});
10781108
});

0 commit comments

Comments
 (0)