From fa220093144e989aaedc3c4f1ca658472a5a63ea Mon Sep 17 00:00:00 2001 From: Alain Schlesser Date: Tue, 3 Nov 2026 13:58:18 +0000 Subject: [PATCH] test(core): isolate media and module-settings fixtures from ambient signing The hygiene-media, media-inventory, module-settings and module-jobs settings fixtures committed into temporary repositories with the host's signing configuration, so an ambient commit.gpgsign=true with an unavailable signer failed 31 cases at setup. The media helpers now pass command-scoped commit.gpgsign=false. The settings fixtures also commit through the CLI, so their Git and CLI children share a new withoutSigning(env) helper that appends command-scoped signing overrides to GIT_CONFIG_COUNT. Refs #3060 Co-Authored-By: Claude Opus 5.5 --- packages/core/tests/git-fixture.ts | 16 ++++++++++++++++ packages/core/tests/hygiene-media.test.ts | 2 +- packages/core/tests/media-inventory.test.ts | 2 +- packages/core/tests/module-settings.test.ts | 9 ++++++++- packages/module-jobs/tests/settings.test.ts | 9 ++++++++- 5 files changed, 34 insertions(+), 4 deletions(-) diff --git a/packages/core/tests/git-fixture.ts b/packages/core/tests/git-fixture.ts index 614abe3eca..4986eaa3e2 100644 --- a/packages/core/tests/git-fixture.ts +++ b/packages/core/tests/git-fixture.ts @@ -71,3 +71,19 @@ export function expectBlobsIntact(root: string, blobs: { oid: string; content: s export function reflogs(root: string): string[] { return git(root, "reflog", "show", "--all", "--format=%gd %H %gs").split("\n").filter(Boolean).sort(); } + +/** + * `env` with commit and tag signing disabled at command scope, for a fixture + * whose product commands commit too. The entries go after any inherited + * `GIT_CONFIG_COUNT` ones, so they outrank global, repository and earlier + * environment configuration without touching the host's settings. + */ +export function withoutSigning(env: Record): Record { + const count = Number(env.GIT_CONFIG_COUNT ?? 0); + return { + ...env, + GIT_CONFIG_COUNT: String(count + 2), + [`GIT_CONFIG_KEY_${count}`]: "commit.gpgSign", [`GIT_CONFIG_VALUE_${count}`]: "false", + [`GIT_CONFIG_KEY_${count + 1}`]: "tag.gpgSign", [`GIT_CONFIG_VALUE_${count + 1}`]: "false", + }; +} diff --git a/packages/core/tests/hygiene-media.test.ts b/packages/core/tests/hygiene-media.test.ts index 70418dd8f8..408747a9f1 100644 --- a/packages/core/tests/hygiene-media.test.ts +++ b/packages/core/tests/hygiene-media.test.ts @@ -25,7 +25,7 @@ afterEach(() => { }); function git(cwd: string, ...args: string[]): void { - const r = Bun.spawnSync(["git", "-C", cwd, ...args]); + const r = Bun.spawnSync(["git", "-c", "commit.gpgsign=false", "-C", cwd, ...args]); if (r.exitCode !== 0) throw new Error(r.stderr.toString()); } function put(root: string, path: string, text: string): void { diff --git a/packages/core/tests/media-inventory.test.ts b/packages/core/tests/media-inventory.test.ts index 7acb5c3fdc..d93d23c4b6 100644 --- a/packages/core/tests/media-inventory.test.ts +++ b/packages/core/tests/media-inventory.test.ts @@ -32,7 +32,7 @@ const VOYAGE = ["pi", "voyage-home"]; const key = (backend: string, session: string) => JSON.stringify([backend, session]); function git(cwd: string, ...args: string[]): void { - const r = Bun.spawnSync(["git", "-C", cwd, ...args]); + const r = Bun.spawnSync(["git", "-c", "commit.gpgsign=false", "-C", cwd, ...args]); if (r.exitCode !== 0) throw new Error(r.stderr.toString()); } diff --git a/packages/core/tests/module-settings.test.ts b/packages/core/tests/module-settings.test.ts index 7fbcecb7b0..cf8953c663 100644 --- a/packages/core/tests/module-settings.test.ts +++ b/packages/core/tests/module-settings.test.ts @@ -1,7 +1,14 @@ import { afterEach, expect, test } from "bun:test"; import { chmodSync, existsSync, mkdirSync, readFileSync, rmSync, symlinkSync, writeFileSync } from "fs"; import { join } from "path"; -import { BRAIN_BIN, cleanup, keylessEnv, makeTempBrain, runCli } from "./cli-harness"; +import { BRAIN_BIN, cleanup, keylessEnv as harnessEnv, makeTempBrain, runCli as harnessCli } from "./cli-harness"; +import { withoutSigning } from "./git-fixture"; + +// Settings saves commit through the CLI. Every Git child, fixture and product +// alike, gets signing disabled at command scope, so no ambient signing +// configuration reaches these temporary repositories. +const keylessEnv = (root: string) => withoutSigning(harnessEnv(root)); +const runCli = (root: string, args: string[]) => harnessCli(root, args, keylessEnv(root)); const roots: string[] = []; afterEach(() => { for (const root of roots.splice(0)) cleanup(root); }); diff --git a/packages/module-jobs/tests/settings.test.ts b/packages/module-jobs/tests/settings.test.ts index d83301c4d8..083bbc3b43 100644 --- a/packages/module-jobs/tests/settings.test.ts +++ b/packages/module-jobs/tests/settings.test.ts @@ -2,13 +2,20 @@ import { frontmatterEngineSentinel } from "../../../tests/helpers/frontmatter-en import { afterEach, expect, test } from "bun:test"; import { chmodSync, mkdirSync, readFileSync, writeFileSync } from "fs"; import { join } from "path"; -import { cleanup, keylessEnv, makeTempBrain, runCli } from "../../core/tests/cli-harness"; +import { cleanup, keylessEnv as harnessEnv, makeTempBrain, runCli as harnessCli } from "../../core/tests/cli-harness"; +import { withoutSigning } from "../../core/tests/git-fixture"; import { parseFrontmatter } from "@schlessera/brain-common/internal/frontmatter"; import { configSchema } from "../src/module"; import { jobsSettings, planScoringMigration } from "../src/settings"; import { loadScoringConfig, parseScoringConfig, scoreJob } from "../src/score"; import { ADAPTERS, getAdapterOptions } from "../src/scrape"; +// Settings saves commit through the CLI. Every Git child, fixture and product +// alike, gets signing disabled at command scope, so no ambient signing +// configuration reaches these temporary repositories. +const keylessEnv = (root: string) => withoutSigning(harnessEnv(root)); +const runCli = (root: string, args: string[]) => harnessCli(root, args, keylessEnv(root)); + const roots: string[] = []; afterEach(() => { for (const root of roots.splice(0)) cleanup(root); }); const source = readFileSync(join(import.meta.dir, "fixtures/criteria.md"), "utf8");