Skip to content

Commit e2b35a5

Browse files
committed
compute: a failure implicates only toolchains no successful build of the release used
1 parent 6aa6cd7 commit e2b35a5

2 files changed

Lines changed: 39 additions & 2 deletions

File tree

‎shared/compute.ts‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,15 +199,26 @@ export function verifiedPairs(
199199
]);
200200
}
201201

202+
/**
203+
* A failed build pins several toolchains at once and cannot say which one is
204+
* to blame, so a failure only implicates a toolchain version that no
205+
* successful build of the same release used.
206+
*/
202207
function verifiedFor(
203208
packageName: string,
204209
version: string,
205210
verified: VerificationResult[],
206211
outcome: ResultClass,
207212
): VersionCompatibility["verified"] {
213+
const forThisVersion = (pairs: ReturnType<typeof verifiedPairs>) =>
214+
pairs.filter((pair) => pair.package === packageName && pair.version === version);
215+
const successes = forThisVersion(verifiedPairs(verified, "success"));
216+
const provenToWork = (pair: (typeof successes)[number]) =>
217+
successes.some((ok) => ok.toolchain === pair.toolchain && sameLine(ok.toolchainVersion, pair.toolchainVersion));
218+
208219
const result: VersionCompatibility["verified"] = {};
209-
for (const pair of verifiedPairs(verified, outcome)) {
210-
if (pair.package !== packageName || pair.version !== version) {
220+
for (const pair of forThisVersion(verifiedPairs(verified, outcome))) {
221+
if (outcome !== "success" && provenToWork(pair)) {
211222
continue;
212223
}
213224
const list = (result[pair.toolchain] ??= []);

‎test/compute.test.ts‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,3 +256,29 @@ describe("inferred failures", () => {
256256
expect(doc.packages["@nativescript/android"].versions["9.1.1"].inferred).toBeUndefined();
257257
});
258258
});
259+
260+
describe("failure attribution", () => {
261+
it("blames only the toolchain no successful build of the release used", () => {
262+
const doc = buildDocument({
263+
generatedAt: "2026-09-09T00:00:00.000Z",
264+
toolchains: { xcode: [], cocoapods: [], compileSdk: [{ version: "37" }], buildTools: [{ version: "37.0.0" }], jdk: [{ version: "25" }, { version: "21" }], node: [] },
265+
packages: [
266+
{
267+
spec: { name: "@nativescript/android", toolchains: ["compileSdk", "buildTools", "jdk"], keep: 5 },
268+
document: { distTags: {}, manifests: [{ version: "9.1.1", requirements: { jdk: ">=17" } }, { version: "9.0.5", requirements: { jdk: ">=17" } }] },
269+
},
270+
],
271+
overrides: { requirements: [], advisories: [] },
272+
verified: [
273+
{ package: "@nativescript/android", version: "9.1.1", toolchains: { compileSdk: "37", buildTools: "37.0.0", jdk: "25" }, with: { nativescript: "9.1.1", node: "24" }, outcome: "failure", attempts: 2, recordedAt: "2026-09-09T00:00:00Z" },
274+
{ package: "@nativescript/android", version: "9.1.1", toolchains: { compileSdk: "37", buildTools: "37.0.0", jdk: "21" }, with: { nativescript: "9.1.1", node: "24" }, recordedAt: "2026-09-09T00:00:00Z" },
275+
],
276+
});
277+
const v911 = doc.packages["@nativescript/android"].versions["9.1.1"];
278+
expect(v911.failed).toEqual({ jdk: ["25"] });
279+
expect(v911.verified).toEqual({ compileSdk: ["37"], buildTools: ["37.0.0"], jdk: ["21"] });
280+
expect(cellFor(doc, "@nativescript/android", "9.0.5", "compileSdk", "37").state).toBe("unverified");
281+
expect(cellFor(doc, "@nativescript/android", "9.0.5", "buildTools", "37.0.0").state).toBe("unverified");
282+
expect(cellFor(doc, "@nativescript/android", "9.0.5", "jdk", "25").state).toBe("unsupported");
283+
});
284+
});

0 commit comments

Comments
 (0)