mirror of
https://github.com/bitbaum/loki.git
synced 2026-12-04 07:02:29 +01:00
* chore: add a formatter, matching the style this repo already writes singleQuote=false was chosen by counting this repo's own imports, not by fleet decree. The fleet is genuinely split and the two repos that already had a .prettierrc disagreed with each other, so there was no standard to restore. Quote style does not cross repo boundaries; having a gate does. Markdown is ignored for now — prettier rewraps prose, which would bury the real diff. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * style: format with prettier (1062 files) Mechanical. No behaviour change. This SHA is listed in .git-blame-ignore-revs so `git blame` skips it. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * chore: teach git blame to skip the reformat Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * fix(lint): reattach two guards the reformat detached Both effects were one-liners, so a trailing eslint-disable-line covered the setState call: useEffect(() => { setSelected(new Set()); }, [q.length]); // eslint-disable-line ... prettier expanded the block. The comment stayed on the closing line while the call moved above it, so the guard protected nothing and the rule its author had deliberately silenced failed the build. This is the second shape of the same defect — hirnli had the eslint-disable-NEXT-line variant. Both come from the same fact: an eslint directive binds to a line number, so reformatting can silently unbind it, which makes 'mechanical, no behaviour change' false for any bulk reformat. * chore(desktop): bump the runner version the reformat requires desktop-release-drift enforces that anything built into Fleet Runner which differs from the last released tag must carry a version ahead of that tag — main read 0.8.15 and fleet-runner-v0.8.15 already shipped. A whole-repo reformat changes bytes under desktop/, so the gate fires. The alternative was adding desktop/ to .prettierignore, which would buy a quiet PR by carving a permanent hole in the formatter's coverage — the precise shape of silent drift this test was written to catch. Bumping is what the rule asks for and costs one patch release whose only content is whitespace. * chore: merge main and re-format A whole-repo reformat conflicts with any concurrent commit, and a conflicting PR runs no checks at all while reporting nothing. Conflicts resolved to main, which is correct because this branch changes formatting and nothing else. * chore: leave desktop/ out of this reformat desktop-release-drift is right to refuse this. Everything under desktop/ is built into Fleet Runner, so changing it means shipping: bump the version AND add a FLEET_RUNNER_RELEASES entry, whose stated audience is 'person who installed Fleet Runner and wants to know what changed'. For a whitespace-only build the honest answer is 'nothing', so that release should not exist — and I should not write release notes claiming otherwise. I had bumped to 0.8.16 to get the gate green. That was the wrong direction: publishing a build to three OS runners to keep a formatting PR quiet. Reverted. desktop/ is excluded in .prettierignore with the reasoning recorded there, to be formatted alongside the next real runner change, where the bump and the notes are true anyway. --------- Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
185 lines
7.2 KiB
JavaScript
185 lines
7.2 KiB
JavaScript
#!/usr/bin/env node
|
|
/**
|
|
* Fleet-wide audit: no workflow may reference an owner that GitHub only
|
|
* REDIRECTS to, and no file may name a retired handle.
|
|
*
|
|
* This exists because the same outage happened three times in three days:
|
|
*
|
|
* 2026-08-26 the account `maonakamoto` was renamed to `catomean`
|
|
* 2026-08-28 the repos moved to the organisation `bitbaum`
|
|
* ...and the 2026-08-27 repair, which pointed everything at `catomean`,
|
|
* was itself killed by the second move about ten hours later.
|
|
*
|
|
* Every time, every merge and every deploy stopped, and every time nothing
|
|
* looked wrong. GitHub follows a rename or transfer for the REST API and for
|
|
* git remotes — `gh api repos/<old>/dotfiles` answers, `git clone` works,
|
|
* `git push` works. The Actions `uses:` resolver is the one consumer that does
|
|
* NOT follow it. A run dies before any step exists: zero jobs, no log, and a
|
|
* bare "This run likely failed because of a workflow file issue".
|
|
*
|
|
* Pull requests stay GREEN, CLEAN and MERGEABLE throughout, because the
|
|
* workflow that would report the failure is the one that cannot start. Work
|
|
* simply stops shipping and nothing is marked broken.
|
|
*
|
|
* THE CHECK: ask REST what each referenced repo is really called. That is
|
|
* exactly the discrepancy — REST resolves the redirect and returns the
|
|
* canonical `full_name`, Actions does not resolve it at all. Disagreement means
|
|
* the workflow is already broken, whether or not it has run yet.
|
|
*
|
|
* A static allowlist cannot do this: after a rename the workflow file and the
|
|
* allowlist hold the same stale name and agree with each other.
|
|
*
|
|
* Generalised from orangecat's per-repo check to cover the WHOLE org, because a
|
|
* per-repo copy only protects repos that already have CI — petvity's deploy was
|
|
* broken for exactly that reason, and had no auto-merge.yml to notice.
|
|
*/
|
|
|
|
import { retiredHandleMatches, USES, verdictFor, pathVerdictFor } from "./fleet-refs-audit-lib.mjs";
|
|
|
|
const ORG = process.env.FLEET_ORG || "bitbaum";
|
|
const RETIRED = (process.env.RETIRED_HANDLES || "maonakamoto")
|
|
.split(",")
|
|
.map((s) => s.trim())
|
|
.filter(Boolean);
|
|
const token = process.env.GITHUB_TOKEN || process.env.GH_TOKEN;
|
|
if (!token) {
|
|
console.log("[fleet-refs-audit] no token — skipping");
|
|
process.exit(0);
|
|
}
|
|
|
|
const api = async (path) => {
|
|
const res = await fetch(`https://api.github.com${path}`, {
|
|
headers: {
|
|
authorization: `Bearer ${token}`,
|
|
accept: "application/vnd.github+json",
|
|
"user-agent": "fleet-refs-audit",
|
|
},
|
|
});
|
|
return { ok: res.ok, status: res.status, body: res.ok ? await res.json() : null };
|
|
};
|
|
|
|
const canonical = new Map(); // "owner/repo" -> canonical full_name | null
|
|
async function resolve(slug) {
|
|
if (canonical.has(slug)) return canonical.get(slug);
|
|
const r = await api(`/repos/${slug}`);
|
|
const v = r.ok ? r.body.full_name : r.status === 404 ? null : undefined;
|
|
canonical.set(slug, v);
|
|
return v;
|
|
}
|
|
|
|
const paths = new Map(); // "owner/repo/path@ref" -> true | false | undefined
|
|
/** Does the referenced file (or action directory) still exist at that ref?
|
|
* A directory answers 200 with an array, which is what a composite action
|
|
* reference points at, so both shapes work. */
|
|
async function pathExists(slug, subpath, ref) {
|
|
const rel = subpath.replace(/^\//, "");
|
|
const key = `${slug}/${rel}@${ref}`;
|
|
if (paths.has(key)) return paths.get(key);
|
|
const r = await api(`/repos/${slug}/contents/${rel}?ref=${encodeURIComponent(ref)}`);
|
|
const v = r.ok ? true : r.status === 404 ? false : undefined;
|
|
paths.set(key, v);
|
|
return v;
|
|
}
|
|
|
|
const repos = [];
|
|
for (let page = 1; ; page++) {
|
|
const r = await api(`/orgs/${ORG}/repos?per_page=100&type=all&page=${page}`);
|
|
if (!r.ok) {
|
|
console.error(`::error::cannot list ${ORG} repos (HTTP ${r.status})`);
|
|
process.exit(1);
|
|
}
|
|
repos.push(...r.body.filter((x) => !x.archived));
|
|
if (r.body.length < 100) break;
|
|
}
|
|
|
|
const stale = [],
|
|
retired = [],
|
|
unreadable = [];
|
|
let checkedRepos = 0,
|
|
checkedFiles = 0;
|
|
|
|
for (const repo of repos) {
|
|
const dir = await api(
|
|
`/repos/${repo.full_name}/contents/.github/workflows?ref=${repo.default_branch}`,
|
|
);
|
|
if (!dir.ok) {
|
|
// 404 == no workflows dir (fine). Anything else == we could not look, which
|
|
// is NOT the same as "clean" and must never be reported as a pass.
|
|
if (dir.status !== 404) unreadable.push(`${repo.full_name} (HTTP ${dir.status})`);
|
|
continue;
|
|
}
|
|
checkedRepos++;
|
|
for (const f of dir.body.filter((x) => x.type === "file" && /\.ya?ml$/.test(x.name))) {
|
|
const file = await api(
|
|
`/repos/${repo.full_name}/contents/.github/workflows/${f.name}?ref=${repo.default_branch}`,
|
|
);
|
|
if (!file.ok) {
|
|
unreadable.push(`${repo.full_name}/${f.name} (HTTP ${file.status})`);
|
|
continue;
|
|
}
|
|
const text = Buffer.from(file.body.content, "base64").toString("utf8");
|
|
checkedFiles++;
|
|
|
|
// See fleet-refs-audit-lib.mjs: comments and this audit's own
|
|
// RETIRED_HANDLES declaration are excluded, because neither is a
|
|
// reference that needs correcting. Line-level, not file-level: an
|
|
// earlier version of this fix exempted this whole file by repo+filename
|
|
// (SELF_REPO/SELF_WORKFLOW), which stops working the moment this
|
|
// tooling moves to a different repo — already planned, see
|
|
// bitbaum/fleet — and silently re-opens the exact bug it fixed.
|
|
for (const h of retiredHandleMatches(text, RETIRED)) {
|
|
retired.push(`${repo.full_name}/.github/workflows/${f.name} names "${h}" in a live line`);
|
|
}
|
|
for (const [, owner, name, subpath, ref] of text.matchAll(USES)) {
|
|
const slug = `${owner}/${name}`;
|
|
const where = `${repo.full_name}/.github/workflows/${f.name}`;
|
|
const real = await resolve(slug);
|
|
const verdict = verdictFor(slug, real);
|
|
if (verdict.kind === "unreadable") {
|
|
unreadable.push(verdict.message);
|
|
continue;
|
|
}
|
|
if (verdict.kind === "stale") {
|
|
stale.push(`${where}: ${verdict.message}`);
|
|
continue;
|
|
}
|
|
// Owner is canonical. Now the other half: is the file still there?
|
|
const pv = pathVerdictFor(
|
|
slug,
|
|
subpath,
|
|
ref,
|
|
subpath ? await pathExists(slug, subpath, ref) : true,
|
|
);
|
|
if (pv.kind === "unreadable") unreadable.push(pv.message);
|
|
else if (pv.kind === "stale") stale.push(`${where}: ${pv.message}`);
|
|
}
|
|
}
|
|
}
|
|
|
|
console.log(
|
|
`[fleet-refs-audit] ${checkedRepos} repos, ${checkedFiles} workflow files, ${canonical.size} distinct refs`,
|
|
);
|
|
|
|
// A floor: if the sweep silently stops seeing repos, "0 problems" is not a pass.
|
|
const FLOOR = Number(process.env.MIN_REPOS || 10);
|
|
if (checkedRepos < FLOOR) {
|
|
console.error(
|
|
`::error::only ${checkedRepos} repos had workflows (floor ${FLOOR}) — this audit is not seeing the fleet`,
|
|
);
|
|
process.exit(1);
|
|
}
|
|
|
|
for (const u of [...new Set(unreadable)]) console.log(`::warning::could not check ${u}`);
|
|
for (const s of stale) console.log(`::error::${s}`);
|
|
for (const r of retired) console.log(`::error::${r}`);
|
|
|
|
if (stale.length || retired.length) {
|
|
console.error(
|
|
`\nFAIL: ${stale.length} broken reference(s) (wrong owner or missing file), ${retired.length} retired-handle reference(s).`,
|
|
);
|
|
process.exit(1);
|
|
}
|
|
console.log(
|
|
"OK: every workflow reference names its canonical owner, and every referenced file exists.",
|
|
);
|