Skip to content

OpenAI's Codex Security CLI and TypeScript SDK for finding, validating, and fixing security vulnerabilities. npm: https://www.npmjs.com/package/@openai/codex-security

test: fix Windows runner cleanup and subprocess failures (#727)

mldangelo-oai196eb5764ae3
diff --git a/sdk/typescript/tests-ts/release-automation.test.ts b/sdk/typescript/tests-ts/release-automation.test.ts
index c1a6599c0..d1900db39 100644
--- a/sdk/typescript/tests-ts/release-automation.test.ts
+++ b/sdk/typescript/tests-ts/release-automation.test.ts
@@ -1,4 +1,4 @@
-import { spawnSync } from "node:child_process";
+import { execFile, spawnSync } from "node:child_process";
import { createHash } from "node:crypto";
import {
mkdirSync,
@@ -159,6 +159,35 @@ const releaseRepository = "openai/codex-security";
const releaseTagTimeout = process.platform === "win32" ? 20_000 : 10_000;
const bash = bashCommand();
+
+function runCommand(
+ command: string,
+ args: string[],
+ {
+ input,
+ ...options
+ }: {
+ cwd?: string;
+ env?: NodeJS.ProcessEnv;
+ input?: string;
+ timeout: number;
+ },
+): Promise<{ status: number | null; stdout: string; stderr: string }> {
+ // Avoid Bun's premature synchronous timeouts while keeping pipe reads bounded.
+ return new Promise((resolve, reject) => {
+ const child = execFile(
+ command,
+ args,
+ { ...options, encoding: "utf8" },
+ (_error, stdout, stderr) => {
+ resolve({ status: child.exitCode, stdout, stderr });
+ },
+ );
+ child.stdin?.on("error", reject);
+ child.stdin?.end(input);
+ });
+}
+
const jqMock = [
"jq() {",
' node -e \'const fs=require("node:fs");const filter=process.argv.at(-1);const value=JSON.parse(fs.readFileSync(0,"utf8"));if(filter==="[.object.type, .object.sha] | @tsv"){const fields=[value.object?.type,value.object?.sha];if(fields.some((field)=>typeof field!=="string"))process.exit(1);process.stdout.write(fields.join("\\t")+"\\n");}else if(filter===".status // empty"){if(value.status!=null)process.stdout.write(String(value.status)+"\\n");}else process.exit(64);\' -- "$@"',
@@ -495,7 +524,7 @@ describe("reviewed release note helpers", () => {
);
});
- test("rejects NUL bytes before shell composition", () => {
+ test("rejects NUL bytes before shell composition", async () => {
const workspace = mkdtempSync(join(tmpdir(), "release-notes-nul-"));
try {
const taggedNotes = join(workspace, "tagged-notes.md");
@@ -503,7 +532,7 @@ describe("reviewed release note helpers", () => {
writeFileSync(taggedNotes, "<!-- release-version: 1.2.3 -->\n\0\n");
writeFileSync(generatedNotes, "Generated release notes\n");
- const result = spawnSync(
+ const result = await runCommand(
bash,
[
"-c",
@@ -514,7 +543,6 @@ describe("reviewed release note helpers", () => {
].join("\n"),
],
{
- encoding: "utf8",
env: {
...process.env,
AUTOMATION_SCRIPT: fileURLToPath(automationScript),
@@ -1664,6 +1692,20 @@ describe("GitHub release workflow safeguards", () => {
);
const checkedOutTag = `npm-v${checkedOutVersion}`;
+ test("stops reading inherited pipes when a command times out", async () => {
+ const result = await runCommand(
+ bash,
+ [
+ "-c",
+ "(sleep 1; printf 'late stdout'; printf 'late stderr' >&2) & wait",
+ ],
+ { timeout: 100 },
+ );
+ expect(result.status).toBeNull();
+ expect(result.stdout).not.toContain("late stdout");
+ expect(result.stderr).not.toContain("late stderr");
+ });
+
test("rejects unsupported jq mock filters", () => {
const result = spawnSync(
bash,
@@ -1743,7 +1785,7 @@ describe("GitHub release workflow safeguards", () => {
},
])(
"validates $scenario before protected npm publication",
- ({ summary, status, message }) => {
+ async ({ summary, status, message }) => {
const script = workflowStepShell(
protectedReleaseWorkflow,
"Validate reviewed release notes",
@@ -1754,9 +1796,8 @@ describe("GitHub release workflow safeguards", () => {
" printf '%s\\n' \"$MOCK_RELEASE_SUMMARY\"",
"}",
].join("\n");
- const result = spawnSync(bash, ["-c", `${mock}\n${script}`], {
+ const result = await runCommand(bash, ["-c", `${mock}\n${script}`], {
cwd: fileURLToPath(new URL("../../../", import.meta.url)),
- encoding: "utf8",
env: {
...process.env,
GITHUB_SHA: releaseCommit,
@@ -1851,7 +1892,7 @@ describe("GitHub release workflow safeguards", () => {
).toBe(scenario.expected);
});
- test("executes the manual release cut against all published versions", () => {
+ test("executes the manual release cut against all published versions", async () => {
const script = workflowStepShell(
releaseCutWorkflow,
"Resolve the stable package version",
@@ -1865,9 +1906,8 @@ describe("GitHub release workflow safeguards", () => {
"}",
"npm() { printf '%s\\n' '[\"0.1.1\",\"999999999999999999999999.0.0\"]'; }",
].join("\n");
- const result = spawnSync(bash, ["-c", `${mocks}\n${script}`], {
+ const result = await runCommand(bash, ["-c", `${mocks}\n${script}`], {
cwd: fileURLToPath(new URL("../../../", import.meta.url)),
- encoding: "utf8",
env: {
...process.env,
BEFORE_SHA: "",
@@ -1920,7 +1960,7 @@ describe("GitHub release workflow safeguards", () => {
},
])(
"resolves $scenario against its published npm history",
- ({
+ async ({
event,
previousVersion,
currentVersion,
@@ -1961,9 +2001,8 @@ describe("GitHub release workflow safeguards", () => {
try {
const outputPath = join(workspace, "outputs");
- const result = spawnSync(bash, ["-c", `${mocks}\n${script}`], {
+ const result = await runCommand(bash, ["-c", `${mocks}\n${script}`], {
cwd: fileURLToPath(new URL("../../../", import.meta.url)),
- encoding: "utf8",
env: {
...process.env,
GITHUB_EVENT_NAME: event,
@@ -2010,7 +2049,7 @@ describe("GitHub release workflow safeguards", () => {
summary: "<!-- release-version: 0.1.6 -->\n ",
message: "Release notes must start with <!-- release-version: 0.1.6 -->",
},
- ])("rejects $scenario before cutting a tag", ({ summary, message }) => {
+ ])("rejects $scenario before cutting a tag", async ({ summary, message }) => {
const script = workflowStepShell(
releaseCutWorkflow,
"Resolve the stable package version",
@@ -2032,9 +2071,8 @@ describe("GitHub release workflow safeguards", () => {
"}",
"npm() { printf '%s\\n' 'npm history must not be queried' >&2; return 70; }",
].join("\n");
- const result = spawnSync(bash, ["-c", `${mocks}\n${script}`], {
+ const result = await runCommand(bash, ["-c", `${mocks}\n${script}`], {
cwd: fileURLToPath(new URL("../../../", import.meta.url)),
- encoding: "utf8",
env: {
...process.env,
GITHUB_EVENT_NAME: "workflow_dispatch",
@@ -2091,7 +2129,7 @@ describe("GitHub release workflow safeguards", () => {
},
])(
"handles $errorCode during $workflow npm-history validation for $version",
- ({ workflow, version, errorCode, status }) => {
+ async ({ workflow, version, errorCode, status }) => {
const cutting = workflow === "release cut";
const script = workflowStepShell(
cutting ? releaseCutWorkflow : protectedReleaseWorkflow,
@@ -2120,9 +2158,8 @@ describe("GitHub release workflow safeguards", () => {
" return 1",
"}",
].join("\n");
- const result = spawnSync(bash, ["-c", `${mocks}\n${script}`], {
+ const result = await runCommand(bash, ["-c", `${mocks}\n${script}`], {
cwd: fileURLToPath(new URL("../../../", import.meta.url)),
- encoding: "utf8",
env: {
...process.env,
BEFORE_SHA: "",
@@ -2149,7 +2186,7 @@ describe("GitHub release workflow safeguards", () => {
},
);
- test("creates the release tag at the successful CI commit", () => {
+ test("creates the release tag at the successful CI commit", async () => {
const script = workflowStepShell(
releaseCutWorkflow,
"Create the exact merged release tag",
@@ -2172,8 +2209,7 @@ describe("GitHub release workflow safeguards", () => {
" printf 'created tag at %s\\n' \"$RELEASE_SHA\"",
"}",
].join("\n");
- const result = spawnSync(bash, ["-c", `${mock}\n${script}`], {
- encoding: "utf8",
+ const result = await runCommand(bash, ["-c", `${mock}\n${script}`], {
env: {
...process.env,
GITHUB_REPOSITORY: "test/codex-security",
@@ -2215,7 +2251,7 @@ describe("GitHub release workflow safeguards", () => {
},
])(
"handles $kind safely before cutting a release",
- ({ lookupResponse, lookupHttpStatus, status }) => {
+ async ({ lookupResponse, lookupHttpStatus, status }) => {
const script = workflowStepShell(
releaseCutWorkflow,
"Create the exact merged release tag",
@@ -2241,8 +2277,7 @@ describe("GitHub release workflow safeguards", () => {
" printf 'created exact release tag\\n'",
"}",
].join("\n");
- const result = spawnSync(bash, ["-c", `${mock}\n${script}`], {
- encoding: "utf8",
+ const result = await runCommand(bash, ["-c", `${mock}\n${script}`], {
env: {
...process.env,
GITHUB_REPOSITORY: "test/codex-security",
@@ -2290,7 +2325,7 @@ describe("GitHub release workflow safeguards", () => {
},
])(
"resolves an $kind to its exact commit before cutting a release",
- ({ tagType, tagObject, peeledCommit, status }) => {
+ async ({ tagType, tagObject, peeledCommit, status }) => {
const script = workflowStepShell(
releaseCutWorkflow,
"Create the exact merged release tag",
@@ -2318,8 +2353,7 @@ describe("GitHub release workflow safeguards", () => {
" esac",
"}",
].join("\n");
- const result = spawnSync(bash, ["-c", `${mock}\n${script}`], {
- encoding: "utf8",
+ const result = await runCommand(bash, ["-c", `${mock}\n${script}`], {
env: {
...process.env,
GITHUB_REPOSITORY: "test/codex-security",
@@ -2390,7 +2424,7 @@ describe("GitHub release workflow safeguards", () => {
},
])(
"revalidates the authoritative $kind immediately before npm publication",
- ({ tagType, tagObject, peeledCommit, status }) => {
+ async ({ tagType, tagObject, peeledCommit, status }) => {
const script = workflowStepShell(
protectedReleaseWorkflow,
"Revalidate protected release tag",
@@ -2411,8 +2445,7 @@ describe("GitHub release workflow safeguards", () => {
" esac",
"}",
].join("\n");
- const result = spawnSync(bash, ["-c", `${mock}\n${script}`], {
- encoding: "utf8",
+ const result = await runCommand(bash, ["-c", `${mock}\n${script}`], {
env: {
...process.env,
GITHUB_REF: `refs/tags/${checkedOutTag}`,
@@ -2440,7 +2473,7 @@ describe("GitHub release workflow safeguards", () => {
},
);
- test("rejects manually publishing a tag older than npm latest", () => {
+ test("rejects manually publishing a tag older than npm latest", async () => {
const script = workflowStepShell(
protectedReleaseWorkflow,
"Validate release tag",
@@ -2449,9 +2482,8 @@ describe("GitHub release workflow safeguards", () => {
"git() { return 0; }",
"sfw() { printf '%s\\n' '[\"0.1.1\",\"999999999999999999999999.0.0\"]'; }",
].join("\n");
- const result = spawnSync(bash, ["-c", `${mocks}\n${script}`], {
+ const result = await runCommand(bash, ["-c", `${mocks}\n${script}`], {
cwd: fileURLToPath(new URL("../../../", import.meta.url)),
- encoding: "utf8",
env: {
...process.env,
GITHUB_OUTPUT: "/dev/null",
@@ -2469,7 +2501,7 @@ describe("GitHub release workflow safeguards", () => {
);
});
- test("allows the exact already-published release to enter verified recovery", () => {
+ test("allows the exact already-published release to enter verified recovery", async () => {
const script = workflowStepShell(
protectedReleaseWorkflow,
"Validate release tag",
@@ -2478,9 +2510,8 @@ describe("GitHub release workflow safeguards", () => {
"git() { return 0; }",
`sfw() { printf '%s\\n' '["0.1.0","${checkedOutVersion}"]'; }`,
].join("\n");
- const result = spawnSync(bash, ["-c", `${mocks}\n${script}`], {
+ const result = await runCommand(bash, ["-c", `${mocks}\n${script}`], {
cwd: fileURLToPath(new URL("../../../", import.meta.url)),
- encoding: "utf8",
env: {
...process.env,
GITHUB_OUTPUT: "/dev/null",
@@ -2541,14 +2572,13 @@ describe("GitHub release workflow safeguards", () => {
expect(githubReleaseWorkflow).not.toContain("TRIGGER_RUN_ID");
});
- test("dispatches the exact protected run and release tag from trusted main", () => {
+ test("dispatches the exact protected run and release tag from trusted main", async () => {
const script = workflowStepShell(
protectedReleaseWorkflow,
"Dispatch the verified GitHub release",
);
const mock = "gh() { printf '%s\\n' \"$@\"; }";
- const result = spawnSync(bash, ["-c", `${mock}\n${script}`], {
- encoding: "utf8",
+ const result = await runCommand(bash, ["-c", `${mock}\n${script}`], {
env: {
...process.env,
GITHUB_REPOSITORY: releaseRepository,
@@ -2599,7 +2629,7 @@ describe("GitHub release workflow safeguards", () => {
test.each(["queued", "in_progress"])(
"waits for a %s protected npm release to finish before publishing notes",
- (pendingStatus) => {
+ async (pendingStatus) => {
const script = workflowStepShell(
githubReleaseWorkflow,
"Resolve the successful protected release",
@@ -2630,8 +2660,7 @@ describe("GitHub release workflow safeguards", () => {
].join("\n");
try {
- const result = spawnSync(bash, ["-c", `${mocks}\n${script}`], {
- encoding: "utf8",
+ const result = await runCommand(bash, ["-c", `${mocks}\n${script}`], {
env: {
...process.env,
GITHUB_OUTPUT: "/dev/null",
@@ -2651,7 +2680,7 @@ describe("GitHub release workflow safeguards", () => {
},
);
- test("rejects a pending npm release for a different tagged commit", () => {
+ test("rejects a pending npm release for a different tagged commit", async () => {
const script = workflowStepShell(
githubReleaseWorkflow,
"Resolve the successful protected release",
@@ -2673,8 +2702,7 @@ describe("GitHub release workflow safeguards", () => {
"}",
"sleep() { return 99; }",
].join("\n");
- const result = spawnSync(bash, ["-c", `${mocks}\n${script}`], {
- encoding: "utf8",
+ const result = await runCommand(bash, ["-c", `${mocks}\n${script}`], {
env: {
...process.env,
GITHUB_OUTPUT: "/dev/null",
@@ -2691,7 +2719,7 @@ describe("GitHub release workflow safeguards", () => {
);
});
- test("times out safely if a protected npm release never completes", () => {
+ test("times out safely if a protected npm release never completes", async () => {
const script = workflowStepShell(
githubReleaseWorkflow,
"Resolve the successful protected release",
@@ -2712,8 +2740,7 @@ describe("GitHub release workflow safeguards", () => {
"}",
"sleep() { :; }",
].join("\n");
- const result = spawnSync(bash, ["-c", `${mocks}\n${script}`], {
- encoding: "utf8",
+ const result = await runCommand(bash, ["-c", `${mocks}\n${script}`], {
env: {
...process.env,
GITHUB_OUTPUT: "/dev/null",
@@ -2730,7 +2757,7 @@ describe("GitHub release workflow safeguards", () => {
);
});
- test("rejects a release-shaped branch before resolving its commit", () => {
+ test("rejects a release-shaped branch before resolving its commit", async () => {
const script = workflowStepShell(
githubReleaseWorkflow,
"Resolve the successful protected release",
@@ -2753,8 +2780,7 @@ describe("GitHub release workflow safeguards", () => {
" esac",
"}",
].join("\n");
- const result = spawnSync(bash, ["-c", `${mock}\n${script}`], {
- encoding: "utf8",
+ const result = await runCommand(bash, ["-c", `${mock}\n${script}`], {
env: {
...process.env,
GITHUB_OUTPUT: "/dev/null",
@@ -2780,7 +2806,7 @@ describe("GitHub release workflow safeguards", () => {
},
])(
"resolves the exact $kind tag when a same-named branch exists",
- ({ tagType, objectSha }) => {
+ async ({ tagType, objectSha }) => {
const script = workflowStepShell(
githubReleaseWorkflow,
"Resolve the successful protected release",
@@ -2816,8 +2842,7 @@ describe("GitHub release workflow safeguards", () => {
" esac",
"}",
].join("\n");
- const result = spawnSync(bash, ["-c", `${mocks}\n${script}`], {
- encoding: "utf8",
+ const result = await runCommand(bash, ["-c", `${mocks}\n${script}`], {
env: {
...process.env,
GITHUB_OUTPUT: "/dev/null",
@@ -2838,7 +2863,7 @@ describe("GitHub release workflow safeguards", () => {
test.each(["0", "01", "000123"])(
"rejects the noncanonical protected GitHub release run ID %j",
- (runId) => {
+ async (runId) => {
const script = workflowStepShell(
githubReleaseWorkflow,
"Resolve the successful protected release",
@@ -2858,8 +2883,7 @@ describe("GitHub release workflow safeguards", () => {
" esac",
"}",
].join("\n");
- const result = spawnSync(bash, ["-c", `${mocks}\n${script}`], {
- encoding: "utf8",
+ const result = await runCommand(bash, ["-c", `${mocks}\n${script}`], {
env: {
...process.env,
GITHUB_OUTPUT: "/dev/null",
@@ -2952,7 +2976,7 @@ describe("GitHub release workflow safeguards", () => {
},
])(
"revalidates the $description immediately before creating its GitHub release",
- ({ existingLookup, tagType, tagObject, peeledCommit, status }) => {
+ async ({ existingLookup, tagType, tagObject, peeledCommit, status }) => {
const script = workflowStepShell(
githubReleaseWorkflow,
"Publish GitHub Release and generated notes",
@@ -3001,10 +3025,9 @@ describe("GitHub release workflow safeguards", () => {
" fi",
"}",
].join("\n");
- const result = spawnSync(bash, [], {
+ const result = await runCommand(bash, [], {
input: `${mocks}\n${script}`,
cwd: fileURLToPath(new URL("../../../", import.meta.url)),
- encoding: "utf8",
env: {
...process.env,
GITHUB_REPOSITORY: "test/codex-security",
@@ -3114,7 +3137,7 @@ describe("GitHub release workflow safeguards", () => {
},
])(
"binds GitHub release provenance to $description",
- ({ exact, recoveryConclusion, originalCommit, status, message }) => {
+ async ({ exact, recoveryConclusion, originalCommit, status, message }) => {
const script = workflowStepShell(
githubReleaseWorkflow,
"Verify the public npm package and signed provenance",
@@ -3173,9 +3196,8 @@ describe("GitHub release workflow safeguards", () => {
" esac",
"}",
].join("\n");
- const result = spawnSync(bash, ["-c", `${mocks}\n${script}`], {
+ const result = await runCommand(bash, ["-c", `${mocks}\n${script}`], {
cwd: workspace,
- encoding: "utf8",
env: {
...process.env,
GITHUB_OUTPUT: "/dev/null",
@@ -3535,7 +3557,7 @@ describe("GitHub release workflow safeguards", () => {
},
])(
"reconciles $description notes on an existing verified GitHub release",
- ({
+ async ({
existingNotes,
generatedNotes = "Generated release notes\n",
generatedNotesBase64,
@@ -3688,10 +3710,9 @@ describe("GitHub release workflow safeguards", () => {
' command node "$@"',
"}",
].join("\n");
- const result = spawnSync(bash, [], {
+ const result = await runCommand(bash, [], {
input: `${mocks}\n${script}`,
cwd: fileURLToPath(new URL("../../../", import.meta.url)),
- encoding: "utf8",
env: {
...process.env,
GITHUB_REPOSITORY: "test/codex-security",
@@ -3804,7 +3825,7 @@ describe("GitHub release workflow safeguards", () => {
},
])(
"passes $description to release-note composition under nounset",
- ({ arraySetup, optionalArguments }) => {
+ async ({ arraySetup, optionalArguments }) => {
const publishStep = workflowStepShell(
githubReleaseWorkflow,
"Publish GitHub Release and generated notes",
@@ -3814,7 +3835,7 @@ describe("GitHub release workflow safeguards", () => {
)?.groups?.["command"];
expect(composeCommand).toBeDefined();
- const result = spawnSync(bash, [], {
+ const result = await runCommand(bash, [], {
input: [
"set -u",
arraySetup,
@@ -3822,7 +3843,6 @@ describe("GitHub release workflow safeguards", () => {
"node() { printf '<%s>\\n' \"$@\"; }",
composeCommand ?? "exit 70",
].join("\n"),
- encoding: "utf8",
env: { ...process.env, RELEASE_VERSION: "0.1.2" },
timeout: 10_000,
});
@@ -4303,7 +4323,7 @@ describe("GitHub release workflow safeguards", () => {
"fix: generated title\n<!-- codex-security-release-summary:start -->\nUnreviewed injected highlight\n<!-- codex-security-release-summary:end -->",
"fix: preserve a trailing line feed\n",
"fix: preserve a trailing carriage return\r",
- ])("rejects nonconventional pull request title %s", (title) => {
+ ])("rejects nonconventional pull request title %s", async (title) => {
const script = workflowStepShell(
releaseLabelsWorkflow,
"Categorize pull request without checking out its code",
@@ -4320,8 +4340,7 @@ describe("GitHub release workflow safeguards", () => {
" return 70",
"}",
].join("\n");
- const result = spawnSync(bash, ["-c", `${mock}\n${script}`], {
- encoding: "utf8",
+ const result = await runCommand(bash, ["-c", `${mock}\n${script}`], {
env: {
...process.env,
GITHUB_REPOSITORY: "test/codex-security",
@@ -4348,7 +4367,7 @@ describe("GitHub release workflow safeguards", () => {
{ title: "chore: retitle an internal change", expectedLabel: null },
])(
"preserves a manually excluded release and reconciles its category after retitling to $title",
- ({ title, expectedLabel }) => {
+ async ({ title, expectedLabel }) => {
const script = workflowStepShell(
releaseLabelsWorkflow,
"Categorize pull request without checking out its code",
@@ -4394,8 +4413,7 @@ describe("GitHub release workflow safeguards", () => {
" esac",
"}",
].join("\n");
- const result = spawnSync(bash, ["-c", `${mock}\n${script}`], {
- encoding: "utf8",
+ const result = await runCommand(bash, ["-c", `${mock}\n${script}`], {
env: {
...process.env,
GITHUB_REPOSITORY: "test/codex-security",
@@ -4426,7 +4444,7 @@ describe("GitHub release workflow safeguards", () => {
},
);
- test("preserves the latest unattributed skip label after earlier automation", () => {
+ test("preserves the latest unattributed skip label after earlier automation", async () => {
const script = workflowStepShell(
releaseLabelsWorkflow,
"Categorize pull request without checking out its code",
@@ -4467,8 +4485,7 @@ describe("GitHub release workflow safeguards", () => {
" esac",
"}",
].join("\n");
- const result = spawnSync(bash, ["-c", `${mock}\n${script}`], {
- encoding: "utf8",
+ const result = await runCommand(bash, ["-c", `${mock}\n${script}`], {
env: {
...process.env,
GITHUB_REPOSITORY: "test/codex-security",
@@ -4494,7 +4511,7 @@ describe("GitHub release workflow safeguards", () => {
{ title: "deps: upgrade a dependency", label: null },
])(
"reconciles an automatic skip label after retitling to $title",
- ({ title, label }) => {
+ async ({ title, label }) => {
const script = workflowStepShell(
releaseLabelsWorkflow,
"Categorize pull request without checking out its code",
@@ -4530,8 +4547,7 @@ describe("GitHub release workflow safeguards", () => {
" esac",
"}",
].join("\n");
- const result = spawnSync(bash, ["-c", `${mock}\n${script}`], {
- encoding: "utf8",
+ const result = await runCommand(bash, ["-c", `${mock}\n${script}`], {
env: {
...process.env,
GITHUB_REPOSITORY: "test/codex-security",
@@ -4572,7 +4588,7 @@ describe("GitHub release workflow safeguards", () => {
title: "security(api)!: breaking security change",
label: "breaking-change",
},
- ])("categorizes breaking-change title $title", ({ title, label }) => {
+ ])("categorizes breaking-change title $title", async ({ title, label }) => {
const script = workflowStepShell(
releaseLabelsWorkflow,
"Categorize pull request without checking out its code",
@@ -4605,8 +4621,7 @@ describe("GitHub release workflow safeguards", () => {
" esac",
"}",
].join("\n");
- const result = spawnSync(bash, ["-c", `${mock}\n${script}`], {
- encoding: "utf8",
+ const result = await runCommand(bash, ["-c", `${mock}\n${script}`], {
env: {
...process.env,
GITHUB_REPOSITORY: "test/codex-security",
@@ -4620,7 +4635,7 @@ describe("GitHub release workflow safeguards", () => {
expect(result.stdout).toContain(`labels[]=${label}`);
});
- test("executes and recovers from concurrent skip-label creation", () => {
+ test("executes and recovers from concurrent skip-label creation", async () => {
const script = workflowStepShell(
releaseLabelsWorkflow,
"Categorize pull request without checking out its code",
@@ -4658,8 +4673,7 @@ describe("GitHub release workflow safeguards", () => {
" esac",
"}",
].join("\n");
- const result = spawnSync(bash, ["-c", `${mock}\n${script}`], {
- encoding: "utf8",
+ const result = await runCommand(bash, ["-c", `${mock}\n${script}`], {
env: {
...process.env,
GITHUB_REPOSITORY: "test/codex-security",
@@ -4672,11 +4686,11 @@ describe("GitHub release workflow safeguards", () => {
expect(result.stdout).toContain("applied skip-release-notes");
});
- test("documents JSON stdin for every verification command", () => {
- const result = spawnSync(
+ test("documents JSON stdin for every verification command", async () => {
+ const result = await runCommand(
"node",
[fileURLToPath(automationScript), "unknown"],
- { encoding: "utf8", timeout: 10_000 },
+ { timeout: 10_000 },
);
expect(result.status).toBe(1);
expect(result.stderr).toContain("published npm versions JSON from stdin");
diff --git a/sdk/typescript/tests-ts/scan-comparison.test.ts b/sdk/typescript/tests-ts/scan-comparison.test.ts
index 0ffb8e116..077b1177c 100644
--- a/sdk/typescript/tests-ts/scan-comparison.test.ts
+++ b/sdk/typescript/tests-ts/scan-comparison.test.ts
@@ -31,9 +31,22 @@ const temporaryDirectories: string[] = [];
afterEach(async () => {
await Promise.all(
- temporaryDirectories
- .splice(0)
- .map((path) => rm(path, { recursive: true, force: true })),
+ temporaryDirectories.splice(0).map(async (path) => {
+ // Bun 1.3.13 ignores fs.rm's retry options.
+ for (let attempt = 0; ; attempt++) {
+ try {
+ await rm(path, { recursive: true, force: true });
+ return;
+ } catch (error) {
+ if (
+ (error as NodeJS.ErrnoException).code !== "EBUSY" ||
+ attempt === 10
+ )
+ throw error;
+ await Bun.sleep(100 * (attempt + 1));
+ }
+ }
+ }),
);
});