Skip to content

Commit 2b728ec

Browse files
cliffhallclaude
andcommitted
Route sweep warnings through an injectable sink, so tests keep them off the console
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: cliffhall <cliff@futurescale.com>
1 parent abb1c90 commit 2b728ec

7 files changed

Lines changed: 51 additions & 11 deletions

‎scripts/dependabot-alerts.mjs‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -810,6 +810,7 @@ function announcedAdvisories(repo, number, spawn) {
810810
* @param {boolean} [options.dryRun]
811811
* @param {string} [options.today]
812812
* @param {(line: string) => void} [options.log]
813+
* @param {(line: string) => void} [options.warn] for warnings and per-group failures
813814
*/
814815
export function main({
815816
repo = process.env.GITHUB_REPOSITORY,
@@ -819,6 +820,7 @@ export function main({
819820
dryRun = isDryRun(),
820821
today = new Date().toISOString().slice(0, 10),
821822
log = console.log,
823+
warn = console.warn,
822824
} = {}) {
823825
if (!repo) throw new Error("repo not specified (GITHUB_REPOSITORY unset)");
824826
const writer = issueWriter({ repo, spawn, dryRun, sweep: SWEEP, log });
@@ -834,6 +836,7 @@ export function main({
834836
state: "open",
835837
parseMarker,
836838
sweep: SWEEP,
839+
warn,
837840
})
838841
.map((issue) => ({ ...issue, marker: parseMarker(issue.body) }))
839842
.filter((issue) => issue.marker);

‎scripts/dependabot-alerts.test.mjs‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,15 @@ function fakeWorld(state = {}) {
557557
return s.files[file];
558558
};
559559
const lines = [];
560-
return { spawn, readFile, calls, lines, log: (l) => lines.push(l) };
560+
const warnings = [];
561+
return {
562+
spawn,
563+
readFile,
564+
calls,
565+
lines,
566+
warnings,
567+
log: (l) => lines.push(l),
568+
};
561569
}
562570

563571
const writes = (calls) =>
@@ -572,6 +580,7 @@ const run = (world, extra = {}) =>
572580
spawn: world.spawn,
573581
readFile: world.readFile,
574582
log: world.log,
583+
warn: (w) => world.warnings.push(w),
575584
dryRun: false,
576585
today: "2026-10-20",
577586
...extra,
@@ -742,6 +751,7 @@ test("a look-alike issue from an outsider does not suppress filing", () => {
742751
const world = fakeWorld({ alerts: [pipAlerts], issues: [issue] });
743752
run(world);
744753
assert.equal(writes(world.calls)[0].args[1], "create");
754+
assert.match(world.warnings.join("\n"), /"octocat"/);
745755
});
746756

747757
test("a new advisory is commented FIRST, then the issue rewritten", () => {

‎scripts/dependency-refresh.mjs‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,7 @@ function latestReleaseTag(action, spawn) {
532532
* @param {boolean} [options.dryRun]
533533
* @param {string} [options.today] `YYYY-MM-DD`
534534
* @param {(line: string) => void} [options.log]
535+
* @param {(line: string) => void} [options.warn] for warnings and per-group failures
535536
*/
536537
export function main({
537538
repo = process.env.GITHUB_REPOSITORY,
@@ -540,6 +541,7 @@ export function main({
540541
dryRun = isDryRun(),
541542
today = new Date().toISOString().slice(0, 10),
542543
log = console.log,
544+
warn = console.warn,
543545
} = {}) {
544546
if (!repo) throw new Error("repo not specified (GITHUB_REPOSITORY unset)");
545547
const writer = issueWriter({ repo, spawn, dryRun, sweep: SWEEP, log });
@@ -563,9 +565,12 @@ export function main({
563565
// Looked up before branching on the body: the nothing-behind case still
564566
// has to reach an open issue to clear it.
565567
const existing =
566-
sweepIssues(repo, spawn, { state: "open", parseMarker, sweep: SWEEP }).find(
567-
(i) => parseMarker(i.body),
568-
) ?? null;
568+
sweepIssues(repo, spawn, {
569+
state: "open",
570+
parseMarker,
571+
sweep: SWEEP,
572+
warn,
573+
}).find((i) => parseMarker(i.body)) ?? null;
569574
const body = buildIssueBody({ npm, uv, actions, unranked });
570575

571576
if (body === null) {

‎scripts/dependency-refresh.test.mjs‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,7 @@ test("main updates the open sweep issue instead of filing another", (t) => {
442442

443443
test("main ignores a look-alike issue an outsider wrote", (t) => {
444444
const root = fixtureRoot(t);
445+
const warnings = [];
445446
const { spawn, calls } = fakeTools({
446447
issues: [
447448
{
@@ -453,8 +454,16 @@ test("main ignores a look-alike issue an outsider wrote", (t) => {
453454
},
454455
],
455456
});
456-
main({ repo: "o/r", root, spawn, log: () => {} });
457+
main({
458+
repo: "o/r",
459+
root,
460+
spawn,
461+
log: () => {},
462+
warn: (w) => warnings.push(w),
463+
});
457464
assert.equal(writes(calls)[0].args[1], "create");
465+
// Marker and labels with an unknown author is flagged, not trusted.
466+
assert.match(warnings.join("\n"), /"octocat"/);
458467
});
459468

460469
test("main leaves an up-to-date issue alone", (t) => {

‎scripts/lib/sweep.mjs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -268,13 +268,13 @@ export function currentMilestone(repo, spawn) {
268268
*
269269
* @param {string} repo
270270
* @param {typeof spawnSync} spawn
271-
* @param {{state?: "open" | "all", parseMarker: (body: string | undefined) => unknown, sweep: string}} options
271+
* @param {{state?: "open" | "all", parseMarker: (body: string | undefined) => unknown, sweep: string, warn?: (msg: string) => void}} options
272272
* @returns {Array<{number: number, title: string, body: string, state: string, author: object, labels: object[]}>}
273273
*/
274274
export function sweepIssues(
275275
repo,
276276
spawn,
277-
{ state = "all", parseMarker, sweep },
277+
{ state = "all", parseMarker, sweep, warn = console.warn },
278278
) {
279279
const LIMIT = 500;
280280
const issues = ghJson(spawn, [
@@ -299,7 +299,7 @@ export function sweepIssues(
299299
`${sweep}: the issue listing hit its limit of ${LIMIT}, so it may be truncated; refusing to file against a partial view`,
300300
);
301301
}
302-
warnOnUnrecognizedAuthors(issues, parseMarker, sweep);
302+
warnOnUnrecognizedAuthors(issues, parseMarker, sweep, warn);
303303
return issues.filter(isSweepAuthored);
304304
}
305305

‎scripts/sdk-watch.mjs‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,7 @@ function latestPypi(pkg, spawn) {
524524
* @param {string | undefined} [options.output] the `$GITHUB_OUTPUT` file
525525
* @param {boolean} [options.dryRun]
526526
* @param {(line: string) => void} [options.log]
527+
* @param {(line: string) => void} [options.warn] for warnings and per-group failures
527528
*/
528529
export function main({
529530
repo = process.env.GITHUB_REPOSITORY,
@@ -534,6 +535,7 @@ export function main({
534535
output = process.env.GITHUB_OUTPUT,
535536
dryRun = isDryRun(),
536537
log = console.log,
538+
warn = console.warn,
537539
} = {}) {
538540
if (!repo) throw new Error("repo not specified (GITHUB_REPOSITORY unset)");
539541
const writer = issueWriter({ repo, spawn, dryRun, sweep: SWEEP, log });
@@ -571,6 +573,7 @@ export function main({
571573
state: "all",
572574
parseMarker,
573575
sweep: SWEEP,
576+
warn,
574577
})
575578
.map((issue) => ({ ...issue, marker: parseMarker(issue.body) }))
576579
.filter((issue) => issue.marker);
@@ -660,9 +663,7 @@ export function main({
660663
} catch (error) {
661664
// One group's failure must not cost another group its issue.
662665
failures.push(`${state.group.label}: ${error.message}`);
663-
console.error(
664-
`${SWEEP}: ${state.group.label} failed: ${error.message}`,
665-
);
666+
warn(`${SWEEP}: ${state.group.label} failed: ${error.message}`);
666667
}
667668
}
668669
} finally {

‎scripts/sdk-watch.test.mjs‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,10 +375,12 @@ function fakeWorld(state = {}) {
375375
throw new Error(`unexpected gh ${args.join(" ")}`);
376376
};
377377
const lines = [];
378+
const warnings = [];
378379
return {
379380
spawn,
380381
calls,
381382
lines,
383+
warnings,
382384
readFile: (p) => {
383385
if (!(p in s.files)) throw new Error(`no ${p}`);
384386
return s.files[p];
@@ -411,6 +413,7 @@ const run = (world, extra = {}) =>
411413
readFile: world.readFile,
412414
exists: world.exists,
413415
log: world.log,
416+
warn: (w) => world.warnings.push(w),
414417
dryRun: false,
415418
...extra,
416419
});
@@ -531,6 +534,7 @@ test("a forged marker from an outsider suppresses nothing", (t) => {
531534
});
532535
run(world, { output: outputFile(t) });
533536
assert.equal(writes(world.calls).length, 1);
537+
assert.match(world.warnings.join("\n"), /"octocat"/);
534538
});
535539

536540
test("a newer release supersedes the open older issue, once", (t) => {
@@ -575,6 +579,10 @@ test("a failure after filing still emits what was filed, then fails", (t) => {
575579
filedFrom(output).map((f) => f.issue),
576580
[600, 601],
577581
);
582+
assert.match(
583+
world.warnings.join("\n"),
584+
/MCP Python SDK failed: .*comment boom/,
585+
);
578586
});
579587

580588
test("one group's failure does not cost another its issue", (t) => {
@@ -590,6 +598,10 @@ test("one group's failure does not cost another its issue", (t) => {
590598
filedFrom(output).map((f) => f.label),
591599
["MCP Python SDK"],
592600
);
601+
assert.match(
602+
world.warnings.join("\n"),
603+
/\(v1\) failed: gh issue create failed/,
604+
);
593605
});
594606

595607
test("a registry failure fails the run before anything is filed", () => {

0 commit comments

Comments
 (0)