mirror of
https://github.com/bitbaum/fleet.git
synced 2026-12-04 05:07:28 +01:00
actions/runs?head_sha= answers 100 runs a page, and three scripts read only the first. A tip that stays the tip collects a sweep dispatch every quarter hour on the same commit, so after about a day its own CI falls to page two. On 2026-11-12 kivvi's e64eaec carried 129 runs, its green ci.yml and browser-smoke.yml at positions 124 and 125, and the package rollout gate held every @bitbaum/limitkit consumer (solon #569) behind 'wait for bitbaum/kivvi to deploy this artifact and pass CI/browser checks' on a canary that had deployed, matched its receipt and passed both. - runs-for-sha.mjs: everyRunForSha reads every page, newest first, and throws past ten pages instead of answering from a cut list. - The rollout gate, the Git package currency check and the deploy freshness audit read through it. - runs-for-sha.test.mjs: the kivvi shape (127 newer dispatches) counts the buried green runs; a run created mid-read neither hides nor invents one. Checked against live data: the gate on solon #569 exits 1 with the message above before this change and 0 after it. Claude-Session: https://claude.ai/code/session_019MDtmup8GiNe1XJoj1caTC Co-authored-by: Claude <noreply@anthropic.com>
176 lines
4.7 KiB
JavaScript
176 lines
4.7 KiB
JavaScript
import { test } from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import {
|
|
registeredGitDependency,
|
|
planGitUpdate,
|
|
planRegistryMigration,
|
|
latestVerifiedGitRelease,
|
|
} from "./git-package-currency.mjs";
|
|
const sha = "a".repeat(40),
|
|
old = "b".repeat(40);
|
|
const registry = {
|
|
packages: [
|
|
{
|
|
name: "@bitbaum/accountkit",
|
|
repo: "https://github.com/bitbaum/accountkit",
|
|
},
|
|
],
|
|
};
|
|
test("immutable registered Git dependencies are recognized across supported spellings", () => {
|
|
for (const spec of [
|
|
`github:bitbaum/accountkit#v0.2.1`,
|
|
`git+https://github.com/bitbaum/accountkit.git#${old}`,
|
|
])
|
|
assert.equal(
|
|
registeredGitDependency(spec, registry).repo,
|
|
"bitbaum/accountkit",
|
|
);
|
|
for (const spec of [
|
|
"github:someone/accountkit#v1.0.0",
|
|
"github:bitbaum/accountkit#main",
|
|
"workspace:*",
|
|
"^0.5.0",
|
|
])
|
|
assert.equal(registeredGitDependency(spec, registry), null);
|
|
});
|
|
test("Git updates preserve the dependency alias and pin immutable commits without downgrades", () => {
|
|
const target = {
|
|
name: "@bitbaum/accountkit",
|
|
sha,
|
|
version: "0.6.0",
|
|
currentVersion: "0.2.1",
|
|
};
|
|
const update = planGitUpdate(
|
|
"app",
|
|
"frontend/package.json",
|
|
"account-alias",
|
|
"github:bitbaum/accountkit#v0.2.1",
|
|
target,
|
|
);
|
|
assert.equal(update.name, "account-alias");
|
|
assert.equal(update.to, `github:bitbaum/accountkit#${sha}`);
|
|
for (const currentVersion of ["0.6.0", "0.7.0", undefined])
|
|
assert.equal(
|
|
planGitUpdate(
|
|
"app",
|
|
"package.json",
|
|
"x",
|
|
`github:bitbaum/accountkit#${old}`,
|
|
{ ...target, currentVersion },
|
|
),
|
|
null,
|
|
);
|
|
});
|
|
test("only matching stable versions with successful exact-commit CI are eligible", () => {
|
|
const responses =
|
|
(conclusion, declaredVersion = "0.6.0") =>
|
|
(path) => {
|
|
if (path.includes("matching-refs"))
|
|
return [
|
|
{ ref: "refs/tags/v0.6.0" },
|
|
{ ref: "refs/tags/v0.7.0-beta.1" },
|
|
];
|
|
if (path.includes("/commits/")) return { sha };
|
|
if (path.includes("contents"))
|
|
return {
|
|
content: Buffer.from(
|
|
JSON.stringify({ version: declaredVersion }),
|
|
).toString("base64"),
|
|
};
|
|
return {
|
|
workflow_runs: [
|
|
{ path: ".github/workflows/ci.yml", event: "push", conclusion },
|
|
],
|
|
};
|
|
};
|
|
assert.equal(
|
|
latestVerifiedGitRelease("bitbaum/accountkit", responses("success")).sha,
|
|
sha,
|
|
);
|
|
for (const state of [null, "failure", "cancelled"])
|
|
assert.equal(
|
|
latestVerifiedGitRelease("bitbaum/accountkit", responses(state)),
|
|
null,
|
|
);
|
|
assert.equal(
|
|
latestVerifiedGitRelease(
|
|
"bitbaum/accountkit",
|
|
responses("success", "0.5.2"),
|
|
),
|
|
null,
|
|
);
|
|
});
|
|
test("production Git release discovery uses remote tags and raw source, not three REST reads", () => {
|
|
const object = "c".repeat(40), commit = "d".repeat(40), latest = "e".repeat(40);
|
|
const gitCalls = [];
|
|
const run = (_command, args) => {
|
|
gitCalls.push(args);
|
|
return `${object}\trefs/tags/v0.6.0\n${commit}\trefs/tags/v0.6.0^{}\n${latest}\trefs/tags/v0.7.0\n`;
|
|
};
|
|
const sourceReads = [];
|
|
const result = latestVerifiedGitRelease(
|
|
"bitbaum/accountkit",
|
|
undefined,
|
|
run,
|
|
(_repo, ref) => { sourceReads.push(ref); return "0.7.0"; },
|
|
(path) => {
|
|
assert.equal(path, `repos/bitbaum/accountkit/actions/runs?head_sha=${latest}&per_page=100&page=1`);
|
|
return { workflow_runs: [{ path: ".github/workflows/ci.yml", event: "push", conclusion: "success" }] };
|
|
},
|
|
);
|
|
assert.deepEqual(gitCalls[0].slice(0, 2), ["ls-remote", "--tags"]);
|
|
assert.deepEqual(sourceReads, [latest]);
|
|
assert.deepEqual(result, { tag: "v0.7.0", version: "0.7.0", sha: latest });
|
|
});
|
|
test("published packages migrate from Git without changing aliases or downgrading", () => {
|
|
const identity = { name: "@bitbaum/chatkit", npm: true };
|
|
assert.equal(
|
|
planRegistryMigration(
|
|
"app",
|
|
"package.json",
|
|
"chat",
|
|
"github:bitbaum/chatkit#v0.1.0",
|
|
identity,
|
|
"0.1.0",
|
|
"0.15.2",
|
|
).to,
|
|
"npm:@bitbaum/chatkit@^0.15.2",
|
|
);
|
|
assert.equal(
|
|
planRegistryMigration(
|
|
"app",
|
|
"package.json",
|
|
identity.name,
|
|
"git",
|
|
identity,
|
|
"0.15.2",
|
|
"0.15.2",
|
|
).to,
|
|
"^0.15.2",
|
|
);
|
|
assert.equal(
|
|
planRegistryMigration(
|
|
"app",
|
|
"package.json",
|
|
identity.name,
|
|
"git",
|
|
identity,
|
|
"0.16.0",
|
|
"0.15.2",
|
|
),
|
|
null,
|
|
);
|
|
assert.equal(
|
|
planRegistryMigration(
|
|
"app",
|
|
"package.json",
|
|
"listkit",
|
|
"git",
|
|
{ name: "listkit", npm: false },
|
|
"0.1.0",
|
|
"1.0.0",
|
|
),
|
|
null,
|
|
);
|
|
});
|