File size: 1,795 Bytes
d197cf3 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | // Codex CI config script tests cover generated CI configuration files.
import fs from "node:fs/promises";
import path from "node:path";
import { describe, expect, it } from "vitest";
import {
buildCiSafeCodexConfig,
writeCiSafeCodexConfig,
} from "../../scripts/prepare-codex-ci-config.ts";
import { withTempDir } from "../test-utils/temp-dir.js";
describe("prepare-codex-ci-config", () => {
it("renders a minimal trusted non-interactive Codex config for the target repo", () => {
expect(
buildCiSafeCodexConfig({
projectPath: "/tmp/openclaw-pr-sync.xph5uu",
}),
).toBe(
[
"# Generated for Codex CI runs.",
"# Keep the checked-out repo trusted while avoiding maintainer-local",
"# provider/profile overrides that do not exist on CI runners.",
'approval_policy = "never"',
'sandbox_mode = "workspace-write"',
'model_reasoning_effort = "low"',
"",
'[projects."/tmp/openclaw-pr-sync.xph5uu"]',
'trust_level = "trusted"',
"",
].join("\n"),
);
});
it("writes the generated config to disk", async () => {
await withTempDir("codex-ci-config-", async (tempDir) => {
const outputPath = path.join(tempDir, ".codex", "config.toml");
const projectPath = path.join(tempDir, "repo");
await writeCiSafeCodexConfig({
outputPath,
projectPath,
});
await expect(fs.readFile(outputPath, "utf-8")).resolves.toContain(
`approval_policy = "never"`,
);
await expect(fs.readFile(outputPath, "utf-8")).resolves.toContain(
`model_reasoning_effort = "low"`,
);
await expect(fs.readFile(outputPath, "utf-8")).resolves.toContain(
`[projects."${projectPath}"]`,
);
});
});
});
|