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

fix(ci): tolerate transient setup failures and slow Windows runners (#953)

mldangelo-oai6cb0d51e9d20
diff --git a/.github/workflows/native-unix.yml b/.github/workflows/native-unix.yml
index 931eb8f92..9f5522703 100644
--- a/.github/workflows/native-unix.yml
+++ b/.github/workflows/native-unix.yml
@@ -60,7 +60,17 @@ jobs:
pnpm --dir sdk/typescript install --frozen-lockfile
pnpm --dir sdk/typescript run build:ci
- name: Set up Rust
- run: rustup toolchain install 1.97.1 --profile minimal --component rustfmt --component clippy
+ run: |
+ # Rustup 1.29 retries component downloads, but not manifest checksums.
+ for attempt in 1 2 3; do
+ if rustup toolchain install 1.97.1 --profile minimal --component rustfmt --component clippy; then
+ break
+ fi
+ if [ "$attempt" -eq 3 ]; then
+ exit 1
+ fi
+ sleep "$((attempt * 10))"
+ done
- name: Check Rust source and fetch locked dependencies
run: |
cargo fmt --check
diff --git a/.github/workflows/node-ci.yml b/.github/workflows/node-ci.yml
index 532a8a56c..f35c37671 100644
--- a/.github/workflows/node-ci.yml
+++ b/.github/workflows/node-ci.yml
@@ -573,14 +573,14 @@ jobs:
retention-days: 14
- name: Test machine-wide PowerShell policy
if: matrix.shard == 3 && runner.environment == 'github-hosted'
- timeout-minutes: 5
+ timeout-minutes: 7
working-directory: sdk/typescript
env:
TEMP: ${{ steps.windows-temp.outputs.path }}
TMP: ${{ steps.windows-temp.outputs.path }}
TMPDIR: ${{ steps.windows-temp.outputs.path }}
CODEX_SECURITY_ALLOW_MACHINE_POLICY_TEST: "true"
- run: bun test --timeout 120000 ./tests-ts/windows-machine-policy.test.ts
+ run: bun test --timeout 360000 ./tests-ts/windows-machine-policy.test.ts
windows-verify:
name: windows-latest / node-${{ matrix.node == '22.13.0' && '22' || matrix.node }} / verify
diff --git a/sdk/typescript/scripts/package-smoke-timeouts.mjs b/sdk/typescript/scripts/package-smoke-timeouts.mjs
index 019d582a1..35d16d74d 100644
--- a/sdk/typescript/scripts/package-smoke-timeouts.mjs
+++ b/sdk/typescript/scripts/package-smoke-timeouts.mjs
@@ -1,9 +1,11 @@
export function packageSmokeTimeouts(platform = process.platform) {
const commandTimeoutMs = platform === "win32" ? 180_000 : 120_000;
+ const installTimeoutMs = platform === "win32" ? 300_000 : commandTimeoutMs;
return {
commandTimeoutMs,
+ installTimeoutMs,
// Installation and verification run sequentially; allow both plus cleanup.
- processTimeoutMs: commandTimeoutMs * 2 + 30_000,
+ processTimeoutMs: installTimeoutMs + commandTimeoutMs + 30_000,
};
}
diff --git a/sdk/typescript/scripts/smoke-package.mjs b/sdk/typescript/scripts/smoke-package.mjs
index 599b5cf1b..e384081fa 100644
--- a/sdk/typescript/scripts/smoke-package.mjs
+++ b/sdk/typescript/scripts/smoke-package.mjs
@@ -25,7 +25,10 @@ import {
import { fileURLToPath, pathToFileURL } from "node:url";
import { packageSmokeTimeouts } from "./package-smoke-timeouts.mjs";
-const PACKAGE_SMOKE_TIMEOUT_MS = packageSmokeTimeouts().commandTimeoutMs;
+const {
+ commandTimeoutMs: PACKAGE_SMOKE_TIMEOUT_MS,
+ installTimeoutMs: PACKAGE_SMOKE_INSTALL_TIMEOUT_MS,
+} = packageSmokeTimeouts();
const packageRoot = fileURLToPath(new URL("../", import.meta.url));
const packageManifest = JSON.parse(
await readFile(new URL("../package.json", import.meta.url), "utf8"),
@@ -77,14 +80,20 @@ async function resolveArchive() {
function run(
command,
args,
- { cwd, env, capture = false, windowsVerbatimArguments = false } = {},
+ {
+ cwd,
+ env,
+ capture = false,
+ windowsVerbatimArguments = false,
+ timeout = PACKAGE_SMOKE_TIMEOUT_MS,
+ } = {},
) {
const result = spawnSync(command, args, {
cwd,
env,
encoding: "utf8",
stdio: capture ? "pipe" : "inherit",
- timeout: PACKAGE_SMOKE_TIMEOUT_MS,
+ timeout,
killSignal: "SIGKILL",
windowsVerbatimArguments,
windowsHide: true,
@@ -92,7 +101,7 @@ function run(
if (result.error?.code === "ETIMEDOUT") {
throw new Error(
- `Package smoke command timed out after ${PACKAGE_SMOKE_TIMEOUT_MS} ms: ${command}.`,
+ `Package smoke command timed out after ${timeout} ms: ${command}.`,
{ cause: result.error },
);
}
@@ -375,7 +384,7 @@ try {
`typescript@${packageManifest.devDependencies.typescript}`,
`@types/node@${packageManifest.devDependencies["@types/node"]}`,
],
- { cwd: consumer },
+ { cwd: consumer, timeout: PACKAGE_SMOKE_INSTALL_TIMEOUT_MS },
);
const installedRoot = join(
diff --git a/sdk/typescript/tests-ts/cli-patch-results.test.ts b/sdk/typescript/tests-ts/cli-patch-results.test.ts
index 8f3620a3e..2c5f16a17 100644
--- a/sdk/typescript/tests-ts/cli-patch-results.test.ts
+++ b/sdk/typescript/tests-ts/cli-patch-results.test.ts
@@ -119,7 +119,7 @@ lines.on("line", (line) => {
});
test.each([false, true])(
- "fails a no-op with full output %s and preserves local changes",
+ "fails a no-op with full output %j and preserves local changes",
async (fullOutput) => {
const fixture = await repositoryFixture();
await writeFile(join(fixture.directory, "app.ts"), "staged change\n");
@@ -180,7 +180,7 @@ lines.on("line", (line) => {
});
test.each([false, true])(
- "checks patch changes outside a Git repository: %s",
+ "checks patch changes outside a Git repository: %j",
async (apply) => {
const fixture = await repositoryFixture({ initializeGit: false });
const outcome = await fixture.patch(["Synthetic issue"], {
diff --git a/sdk/typescript/tests-ts/package-smoke-timeouts.test.ts b/sdk/typescript/tests-ts/package-smoke-timeouts.test.ts
index 67bdd9df4..f6262ec40 100644
--- a/sdk/typescript/tests-ts/package-smoke-timeouts.test.ts
+++ b/sdk/typescript/tests-ts/package-smoke-timeouts.test.ts
@@ -3,6 +3,7 @@ import { describe, expect, test } from "bun:test";
type PackageSmokeTimeouts = {
packageSmokeTimeouts: (platform?: NodeJS.Platform) => {
commandTimeoutMs: number;
+ installTimeoutMs: number;
processTimeoutMs: number;
};
};
@@ -18,17 +19,20 @@ describe("npm package smoke timeouts", () => {
}
});
- test("allows the Windows npm install to complete", () => {
- expect(packageSmokeTimeouts("win32").commandTimeoutMs).toBe(180_000);
+ test("extends the Windows install budget without slowing other command failures", () => {
+ const { installTimeoutMs, commandTimeoutMs } =
+ packageSmokeTimeouts("win32");
+ expect(installTimeoutMs).toBe(300_000);
+ expect(commandTimeoutMs).toBe(180_000);
});
test.each(["linux", "darwin", "win32"] as const)(
- "allows installation and verification to each use a command budget on %s",
+ "allows installation and verification to each use their budget on %s",
(platform) => {
- const { commandTimeoutMs, processTimeoutMs } =
+ const { commandTimeoutMs, installTimeoutMs, processTimeoutMs } =
packageSmokeTimeouts(platform);
- const remainingAfterInstallation = processTimeoutMs - commandTimeoutMs;
+ const remainingAfterInstallation = processTimeoutMs - installTimeoutMs;
expect(remainingAfterInstallation).toBeGreaterThan(commandTimeoutMs);
},
);
diff --git a/sdk/typescript/tests-ts/skeleton.test.ts b/sdk/typescript/tests-ts/skeleton.test.ts
index b89c50d3d..58d4791ae 100644
--- a/sdk/typescript/tests-ts/skeleton.test.ts
+++ b/sdk/typescript/tests-ts/skeleton.test.ts
@@ -320,7 +320,8 @@ describe("TypeScript package skeleton", () => {
).toMatchObject({
if: "matrix.shard == 3 && runner.environment == 'github-hosted'",
env: { CODEX_SECURITY_ALLOW_MACHINE_POLICY_TEST: "true" },
- run: "bun test --timeout 120000 ./tests-ts/windows-machine-policy.test.ts",
+ "timeout-minutes": 7,
+ run: "bun test --timeout 360000 ./tests-ts/windows-machine-policy.test.ts",
});
const quality = await workflow("test-quality.yml");
expect(Object.keys(quality.on).sort()).toEqual([
diff --git a/sdk/typescript/tests-ts/windows-machine-policy.test.ts b/sdk/typescript/tests-ts/windows-machine-policy.test.ts
index 13983049a..6b75b6a94 100644
--- a/sdk/typescript/tests-ts/windows-machine-policy.test.ts
+++ b/sdk/typescript/tests-ts/windows-machine-policy.test.ts
@@ -80,10 +80,11 @@ describe("runtime directories and plugin Python boundary", () => {
{
encoding: "utf8",
env: constrainedEnvironment,
- timeout: 15_000,
+ timeout: 60_000,
windowsHide: true,
},
);
+ expect(mode.error).toBeUndefined();
expect(mode.status).toBe(0);
expect(mode.stdout.trim()).toBe("ConstrainedLanguage");
@@ -99,10 +100,11 @@ describe("runtime directories and plugin Python boundary", () => {
{
encoding: "utf8",
env: constrainedEnvironment,
- timeout: 15_000,
+ timeout: 60_000,
windowsHide: true,
},
);
+ expect(oldImplementation.error).toBeUndefined();
expect(oldImplementation.status).not.toBe(0);
const trustedPowerShellEnvironment = {
@@ -130,10 +132,11 @@ describe("runtime directories and plugin Python boundary", () => {
{
encoding: "utf8",
env: trustedPowerShellEnvironment,
- timeout: 15_000,
+ timeout: 60_000,
windowsHide: true,
},
);
+ expect(guest.error).toBeUndefined();
expect(guest.status).toBe(0);
expect(guest.stdout.trim()).toMatch(/^S-1-(?:\d+-)*501$/u);
const home = join(root, "state", "codex-home");