From be66700430f3269a8a21668399fa1c7afb0db711 Mon Sep 17 00:00:00 2001 From: Alain Schlesser Date: Sun, 15 Nov 2026 22:20:06 +0000 Subject: [PATCH] test(ci): isolate environment-scoped signing in Git fixtures --- packages/core/tests/cache-location.test.ts | 3 +++ packages/core/tests/git-fixture.ts | 23 ++++++++++++++++++- .../core/tests/media-review-contract.test.ts | 3 +++ packages/core/tests/sync-cache-commit.test.ts | 3 +++ packages/core/tests/sync-commit.test.ts | 3 +++ packages/core/tests/sync-pull-rebase.test.ts | 3 +++ packages/core/tests/sync-run.test.ts | 3 +++ packages/core/tests/sync-runtime.test.ts | 3 +++ packages/core/tests/sync-scenarios.test.ts | 3 +++ .../core/tests/sync-stats-history.test.ts | 3 +++ packages/core/tests/sync-verbs.test.ts | 3 +++ .../tests/jobs-board-selection-http.test.ts | 3 +++ .../tests/module-settings-http.test.ts | 3 +++ .../tests/storage-maintenance-owners.test.ts | 2 +- 14 files changed, 59 insertions(+), 2 deletions(-) diff --git a/packages/core/tests/cache-location.test.ts b/packages/core/tests/cache-location.test.ts index 042c33b113..405326e1d1 100644 --- a/packages/core/tests/cache-location.test.ts +++ b/packages/core/tests/cache-location.test.ts @@ -5,6 +5,7 @@ * lines into the new file. The move is idempotent, keeps union-merged lines, * and survives a merge with a clone that still writes the old names. */ +import { withoutSigningForEach } from "./git-fixture"; import { afterEach, expect, test } from "bun:test"; import { Database } from "bun:sqlite"; import { chmodSync, existsSync, mkdirSync, mkdtempSync, readFileSync, renameSync, rmSync, symlinkSync, writeFileSync } from "fs"; @@ -23,6 +24,8 @@ import { vecAvailable } from "./vec-fixture"; import { makeTempBrain, runCli } from "./cli-harness"; import { brainWithRemote, cleanupFixtures, git, write } from "./sync-fixture"; +withoutSigningForEach(); + const DIM = 16; const taxonomy = buildTaxonomy({ user: null }); const OLD_CONTEXTS = ".context-cache.jsonl"; diff --git a/packages/core/tests/git-fixture.ts b/packages/core/tests/git-fixture.ts index 4986eaa3e2..3de1e3fa82 100644 --- a/packages/core/tests/git-fixture.ts +++ b/packages/core/tests/git-fixture.ts @@ -4,7 +4,7 @@ * config is needed. */ -import { expect } from "bun:test"; +import { afterEach, beforeEach, expect } from "bun:test"; export function git(root: string, ...args: string[]): string { const proc = Bun.spawnSync( @@ -87,3 +87,24 @@ export function withoutSigning(env: Record): Record = {}; + beforeEach(() => { + before = Object.fromEntries(Object.entries(process.env).filter( + (entry): entry is [string, string] => entry[0].startsWith("GIT_CONFIG_") && entry[1] !== undefined, + )); + Object.assign(process.env, withoutSigning(before)); + }); + afterEach(() => { + for (const key of Object.keys(process.env)) { + if (key.startsWith("GIT_CONFIG_") && !(key in before)) delete process.env[key]; + } + Object.assign(process.env, before); + }); +} diff --git a/packages/core/tests/media-review-contract.test.ts b/packages/core/tests/media-review-contract.test.ts index 6b083753d6..b10e3c08ef 100644 --- a/packages/core/tests/media-review-contract.test.ts +++ b/packages/core/tests/media-review-contract.test.ts @@ -5,6 +5,7 @@ * `brain sync` and review's `brain hygiene next` for the same tree. */ +import { withoutSigningForEach } from "./git-fixture"; import { afterEach, describe, expect, test } from "bun:test"; import { existsSync, readdirSync, readFileSync, writeFileSync } from "node:fs"; import { join } from "node:path"; @@ -15,6 +16,8 @@ import type { RunEnvelope } from "../src/lib/sync/run"; import { runCli } from "./cli-harness"; import { brainWithRemote, cleanupFixtures, git, syncJson, write } from "./sync-fixture"; +withoutSigningForEach(); + afterEach(cleanupFixtures); const LOG = "context/hygiene"; diff --git a/packages/core/tests/sync-cache-commit.test.ts b/packages/core/tests/sync-cache-commit.test.ts index 6e42b1785b..2cab4ffb33 100644 --- a/packages/core/tests/sync-cache-commit.test.ts +++ b/packages/core/tests/sync-cache-commit.test.ts @@ -8,6 +8,7 @@ * A pull that cannot merge says whether git refused or stopped on conflicts. */ +import { withoutSigningForEach } from "./git-fixture"; import { afterEach, describe, expect, test } from "bun:test"; import { Database } from "bun:sqlite"; import { chmodSync, mkdirSync, mkdtempSync, readFileSync, rmSync, symlinkSync, writeFileSync } from "node:fs"; @@ -18,6 +19,8 @@ import { chunkContextKey } from "../src/lib/indexer.js"; import { saveContextCache } from "../src/lib/indexer/caches.js"; import { makeTempBrain, runCli } from "./cli-harness"; +withoutSigningForEach(); + const CACHE = ".brain-cache/contexts.jsonl"; const dirs: string[] = []; diff --git a/packages/core/tests/sync-commit.test.ts b/packages/core/tests/sync-commit.test.ts index 114807a07b..ab6f79081b 100644 --- a/packages/core/tests/sync-commit.test.ts +++ b/packages/core/tests/sync-commit.test.ts @@ -5,6 +5,7 @@ * and leaves anything else staged where it was. */ +import { withoutSigningForEach } from "./git-fixture"; import { afterEach, describe, expect, test } from "bun:test"; import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs"; import { tmpdir } from "node:os"; @@ -21,6 +22,8 @@ import { type GroupedFile, } from "../src/lib/sync/commit.js"; +withoutSigningForEach(); + const TODAY = "2026-09-28"; const dirs: string[] = []; diff --git a/packages/core/tests/sync-pull-rebase.test.ts b/packages/core/tests/sync-pull-rebase.test.ts index 3e420c1387..32e4e3b454 100644 --- a/packages/core/tests/sync-pull-rebase.test.ts +++ b/packages/core/tests/sync-pull-rebase.test.ts @@ -1,4 +1,5 @@ /** Rebase-first pulls against real clones; conflicts must return to merge semantics. */ +import { withoutSigningForEach } from "./git-fixture"; import { afterEach, describe, expect, test } from "bun:test"; import { chmodSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs"; import { join } from "node:path"; @@ -6,6 +7,8 @@ import { brainConfigSchema } from "../src/lib/config"; import { runCli } from "./cli-harness"; import { brainWithRemote, cleanupFixtures, commitAndPush, git, gitMayFail, otherClone, write, type Brain } from "./sync-fixture"; +withoutSigningForEach(); + afterEach(cleanupFixtures); const CACHE = ".brain-cache/contexts.jsonl"; const head = (root: string) => git(root, "rev-parse", "HEAD"); diff --git a/packages/core/tests/sync-run.test.ts b/packages/core/tests/sync-run.test.ts index 1810034fa2..e55758bf74 100644 --- a/packages/core/tests/sync-run.test.ts +++ b/packages/core/tests/sync-run.test.ts @@ -8,6 +8,7 @@ * rules left. */ +import { withoutSigningForEach } from "./git-fixture"; import { afterAll, afterEach, beforeAll, describe, expect, test } from "bun:test"; import { chmodSync, mkdirSync, readFileSync, renameSync, symlinkSync, writeFileSync } from "node:fs"; import { join } from "node:path"; @@ -38,6 +39,8 @@ import { write, } from "./sync-fixture"; +withoutSigningForEach(); + afterEach(cleanupFixtures); const { sameNote, codeConflict, pushRace } = SCENARIO_SETUPS; diff --git a/packages/core/tests/sync-runtime.test.ts b/packages/core/tests/sync-runtime.test.ts index 933469204b..5f68af81a9 100644 --- a/packages/core/tests/sync-runtime.test.ts +++ b/packages/core/tests/sync-runtime.test.ts @@ -4,6 +4,7 @@ * `init` reported arrives unchanged, a run the rules finish never launches * the CLI, and human mode keeps the report and the agent's text. */ +import { withoutSigningForEach } from "./git-fixture"; import { afterEach, describe, expect, test } from "bun:test"; import { chmodSync, existsSync, mkdtempSync, rmSync, writeFileSync } from "node:fs"; import { tmpdir } from "node:os"; @@ -12,6 +13,8 @@ import { join } from "node:path"; import { runCli } from "./cli-harness"; import { brainWithRemote, cleanupFixtures, SCENARIO_SETUPS } from "./sync-fixture"; +withoutSigningForEach(); + const scratch: string[] = []; afterEach(() => { cleanupFixtures(); diff --git a/packages/core/tests/sync-scenarios.test.ts b/packages/core/tests/sync-scenarios.test.ts index 959b06e5a7..6ba75069ca 100644 --- a/packages/core/tests/sync-scenarios.test.ts +++ b/packages/core/tests/sync-scenarios.test.ts @@ -6,6 +6,7 @@ * `scripts/measure-sync-run.ts` times the same states. */ +import { withoutSigningForEach } from "./git-fixture"; import { afterEach, describe, expect, test } from "bun:test"; import { brainWithRemote, @@ -21,6 +22,8 @@ import { type Brain, } from "./sync-fixture"; +withoutSigningForEach(); + afterEach(cleanupFixtures); interface Row { diff --git a/packages/core/tests/sync-stats-history.test.ts b/packages/core/tests/sync-stats-history.test.ts index 50a3eaf291..57c13ead71 100644 --- a/packages/core/tests/sync-stats-history.test.ts +++ b/packages/core/tests/sync-stats-history.test.ts @@ -5,12 +5,15 @@ * `brain doctor --fix`) git conflicts on it, and nothing but an agent could * resolve it. The fixture brain has no `.gitattributes`, which is that brain. */ +import { withoutSigningForEach } from "./git-fixture"; import { afterEach, describe, expect, test } from "bun:test"; import { existsSync, readFileSync } from "node:fs"; import { join } from "node:path"; import { brainWithRemote, cleanupFixtures, commitAndPush, git, otherClone, syncJson, write, type Brain } from "./sync-fixture"; +withoutSigningForEach(); + const HISTORY = ".stats-history.jsonl"; const day = (date: string, at: string, documents: number) => JSON.stringify({ date, at, documents }); diff --git a/packages/core/tests/sync-verbs.test.ts b/packages/core/tests/sync-verbs.test.ts index 607c369eba..52c836710a 100644 --- a/packages/core/tests/sync-verbs.test.ts +++ b/packages/core/tests/sync-verbs.test.ts @@ -4,6 +4,7 @@ * off; the judged paths run in-process with a fake Jev, never the network. */ +import { withoutSigningForEach } from "./git-fixture"; import { afterEach, describe, expect, test } from "bun:test"; import { existsSync, readFileSync, writeFileSync } from "node:fs"; import { join } from "node:path"; @@ -24,6 +25,8 @@ import { write, } from "./sync-fixture"; +withoutSigningForEach(); + afterEach(cleanupFixtures); const IGNORE_SUBJECT = "Ignore generated artifacts and secrets"; diff --git a/packages/ui-server/tests/jobs-board-selection-http.test.ts b/packages/ui-server/tests/jobs-board-selection-http.test.ts index 673a54d52f..3ac1168518 100644 --- a/packages/ui-server/tests/jobs-board-selection-http.test.ts +++ b/packages/ui-server/tests/jobs-board-selection-http.test.ts @@ -1,3 +1,4 @@ +import { withoutSigningForEach } from "../../core/tests/git-fixture"; import { expect, test } from "bun:test"; import { existsSync, mkdirSync, readFileSync, symlinkSync, writeFileSync } from "node:fs"; import { join, resolve } from "node:path"; @@ -5,6 +6,8 @@ import { BRAIN_BIN, keylessEnv, runCli } from "../../core/tests/cli-harness"; import { RETIRED_SOURCES } from "../../module-jobs/src/types"; import { httpContractApp } from "./helpers/http-contract-app"; +withoutSigningForEach(); + function git(root: string, args: string[]) { const result = Bun.spawnSync(["git", "-C", root, ...args]); expect(result.exitCode, new TextDecoder().decode(result.stderr)).toBe(0); diff --git a/packages/ui-server/tests/module-settings-http.test.ts b/packages/ui-server/tests/module-settings-http.test.ts index 6cb01ee657..7d8df4d770 100644 --- a/packages/ui-server/tests/module-settings-http.test.ts +++ b/packages/ui-server/tests/module-settings-http.test.ts @@ -1,3 +1,4 @@ +import { withoutSigningForEach } from "../../core/tests/git-fixture"; import { expect, test } from "bun:test"; import { createElement } from "react"; import { renderToStaticMarkup } from "react-dom/server"; @@ -11,6 +12,8 @@ import { BRAIN_BIN } from "../../core/tests/cli-harness"; import { createPrincipal } from "../src/db/principals"; import { httpContractApp } from "./helpers/http-contract-app"; +withoutSigningForEach(); + const SECRET = "module-settings-fixture-secret-0123456789"; function git(root: string, args: string[]): string { const p = Bun.spawnSync(["git", "-C", root, ...args]); diff --git a/packages/ui-server/tests/storage-maintenance-owners.test.ts b/packages/ui-server/tests/storage-maintenance-owners.test.ts index f9f268eb25..4eec2a2ad3 100644 --- a/packages/ui-server/tests/storage-maintenance-owners.test.ts +++ b/packages/ui-server/tests/storage-maintenance-owners.test.ts @@ -100,7 +100,7 @@ test("bounded maintenance kills and reaps an actual output-flooding worker", asy test("hosted packing publishes real Git packs while preserving refs and history", async () => { const f = fixture(); const git = (...args: string[]) => { - const p = Bun.spawnSync(["git", "-C", f.brain, ...args], { stdout: "pipe", stderr: "pipe", env: { ...process.env, GIT_CONFIG_GLOBAL: "/dev/null", GIT_CONFIG_NOSYSTEM: "1" } }); + const p = Bun.spawnSync(["git", "-c", "commit.gpgsign=false", "-C", f.brain, ...args], { stdout: "pipe", stderr: "pipe", env: { ...process.env, GIT_CONFIG_GLOBAL: "/dev/null", GIT_CONFIG_NOSYSTEM: "1" } }); expect(p.exitCode, p.stderr.toString()).toBe(0); return p.stdout.toString(); }; try {