From 5f9db987c1502c4068bc2a2a279a8a727a44d444 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20=C3=81ngel?= Date: Mon, 12 Oct 2026 00:46:27 +0000 Subject: [PATCH] fix(ci): catalog publishing skips runs whose only change is vector noise (#5480) --- scripts/catalog-publication.test.mjs | 42 +++++++++++++++++++++++++--- scripts/publish-catalog.mjs | 2 +- 2 files changed, 39 insertions(+), 5 deletions(-) diff --git a/scripts/catalog-publication.test.mjs b/scripts/catalog-publication.test.mjs index 30a556d831..e289633ccf 100644 --- a/scripts/catalog-publication.test.mjs +++ b/scripts/catalog-publication.test.mjs @@ -124,9 +124,9 @@ if (endpoint === "graphql") console.log("c".repeat(40)); else if (endpoint.includes("/runs?")) console.log(JSON.stringify({ workflow_runs: JSON.parse(process.env.WORKFLOW_RUNS || "[]") })); else if (endpoint.endsWith("/dispatches") && process.env.DISPATCH_FAIL) process.exit(1); else if (endpoint.endsWith("/ref/heads/main")) console.log(process.env.BASE); -else if (endpoint.includes("/matching-refs/")) console.log("refs/heads/bot/catalog-publish"); +else if (endpoint.includes("/matching-refs/")) console.log(process.env.NO_BRANCH ? "" : "refs/heads/bot/catalog-publish"); else if (endpoint.includes("/ref/heads/bot/catalog-publish")) console.log("a".repeat(40)); -else if (endpoint.includes("/pulls?")) console.log("42"); +else if (endpoint.includes("/pulls?")) console.log(process.env.NO_OPEN_PR ? "" : "42"); `, { mode: 0o755 }, ); @@ -370,8 +370,8 @@ const rewrites = (fixture) => .calls() .some((call) => call.endpoint === "graphql" || call.endpoint.includes("/refs/heads/bot/")); -function vectorFixture(t) { - const fixture = publicationFixture(t, true, { PUBLISH_SUCCESS: "1" }); +function vectorFixture(t, changed = true, apiEnv = {}) { + const fixture = publicationFixture(t, changed, { PUBLISH_SUCCESS: "1", ...apiEnv }); writeFileSync(join(fixture.root, VECTOR_META), JSON.stringify({ dimensions: 2 })); writeFileSync(join(fixture.root, VECTOR_BIN), vectors(1, 0, 0, 1)); return fixture; @@ -399,6 +399,40 @@ test("regenerated vectors replace the publication only when they point elsewhere } }); +function regenerateOverMain(t, regenerated, apiEnv, onMain) { + const fixture = vectorFixture(t, false, { NO_OPEN_PR: "1", ...apiEnv }); + commitPaths(fixture.git, "main carries the catalog", [VECTOR_META, VECTOR_BIN]); + onMain(fixture); + writeFileSync(join(fixture.root, VECTOR_BIN), regenerated); + fixture.run(); + return { fixture, writes: fixture.calls().filter((call) => call.method !== "GET") }; +} + +const noise = vectors(1, 0.001, 0.001, 1); + +test("vector noise over a standing branch already in main opens no empty PR", (t) => { + const { fixture, writes } = regenerateOverMain(t, noise, {}, (main) => { + main.git("push", "-q", "-f", "origin", "HEAD:bot/catalog-publish"); + commitToMain(main, "notes.txt", "unrelated"); + }); + assert.deepEqual(writes, [ + { + endpoint: "repos/test/catalog/git/refs/heads/bot/catalog-publish", + method: "PATCH", + body: { sha: fixture.git("rev-parse", "HEAD"), force: true }, + }, + ]); +}); + +test("vector noise after the publish branch was deleted opens no PR", (t) => { + assert.deepEqual(regenerateOverMain(t, noise, { NO_BRANCH: "1" }, () => {}).writes, []); +}); + +test("vectors that point elsewhere than main's still publish", (t) => { + const { writes } = regenerateOverMain(t, vectors(1, 0, 1, 0), { NO_BRANCH: "1" }, () => {}); + assert.ok(writes.some((call) => call.endpoint === "graphql")); +}); + test("vectors the publication lacks replace it", (t) => { const fixture = vectorFixture(t); rmSync(join(fixture.root, VECTOR_BIN)); diff --git a/scripts/publish-catalog.mjs b/scripts/publish-catalog.mjs index 00c8cf5c12..4544e6d577 100644 --- a/scripts/publish-catalog.mjs +++ b/scripts/publish-catalog.mjs @@ -348,7 +348,7 @@ export function publish(root) { "\n", ); const exists = refs.includes(`refs/heads/${BRANCH}`); - if (batches.length === 0) return clearObsoletePublication(repository, base, exists); + if (sameGenerated(root, base)) return clearObsoletePublication(repository, base, exists); const kept = keptSnapshotBase(root, exists); if (kept) { openPublishPr(repository, kept);