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

refactor(ci): consolidate build and tool setup (#1204)

mldangelo-oaib45378072255
diff --git a/.github/actions/setup-tools/action.yml b/.github/actions/setup-tools/action.yml
new file mode 100644
index 000000000..90d5af39a
--- /dev/null
+++ b/.github/actions/setup-tools/action.yml
@@ -0,0 +1,36 @@
+name: Set up TypeScript tools
+description: Install the pinned package manager and Node.js runtime for repository tools.
+inputs:
+ setup-node:
+ description: Install the pinned Node.js runtime; false keeps an earlier setup step.
+ default: "true"
+ cache-dependency-path:
+ description: Lockfiles used for the pnpm store cache.
+ default: "sdk/typescript/pnpm-lock.yaml"
+ architecture:
+ description: Node.js architecture; empty selects the runner architecture.
+ compile:
+ description: Compile TypeScript tools after setup.
+runs:
+ using: composite
+ steps:
+ - name: Set up pnpm
+ uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0
+ with:
+ package_json_file: package.json
+ cache: true
+ cache_dependency_path: ${{ inputs.cache-dependency-path }}
+ - name: Set up Node.js
+ if: inputs.setup-node == 'true'
+ uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
+ with:
+ node-version: "22.13.0"
+ architecture: ${{ inputs.architecture }}
+ - name: Compile TypeScript tools
+ if: inputs.compile == 'true'
+ shell: ${{ runner.os == 'Windows' && 'pwsh' || 'bash' }}
+ working-directory: .
+ run: |
+ pnpm --dir sdk/typescript install --frozen-lockfile
+ ${{ runner.os == 'Windows' && 'if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }' || '' }}
+ pnpm --dir sdk/typescript run build:ci
diff --git a/.github/scripts/invoice-desk-target.mjs b/.github/scripts/invoice-desk-target.mjs
index 03d5e7683..c84f1f1e5 100644
--- a/.github/scripts/invoice-desk-target.mjs
+++ b/.github/scripts/invoice-desk-target.mjs
@@ -40,14 +40,11 @@ export async function resolveScanTargets(
);
if (candidates.length === 0) return [];
const dispatched = new Set(await dispatchedScanTitles(sha));
- return candidates
- .filter(
- (pr) =>
- !dispatched.has(
- `Invoice Desk scan — PR #${pr.number} @ ${pr.head.sha}`,
- ),
- )
- .map((pr) => ({ pr: pr.number, sha: pr.head.sha }));
+ return candidates.flatMap((pr) =>
+ !dispatched.has(`Invoice Desk scan — PR #${pr.number} @ ${pr.head.sha}`)
+ ? { pr: pr.number, sha: pr.head.sha }
+ : [],
+ );
}
if (eventName !== "workflow_dispatch") return [];
const { pr_number: number = "", source_sha: sourceSha = "" } =
diff --git a/.github/workflows/native-musl.yml b/.github/workflows/native-musl.yml
index 61c1ffe51..5abe43bdd 100644
--- a/.github/workflows/native-musl.yml
+++ b/.github/workflows/native-musl.yml
@@ -38,21 +38,10 @@ jobs:
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- - name: Set up pnpm
- uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0
+ - name: Set up TypeScript tools
+ uses: ./.github/actions/setup-tools
with:
- package_json_file: package.json
- cache: true
- cache_dependency_path: sdk/typescript/pnpm-lock.yaml
- - name: Set up Node.js for TypeScript tools
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
- with:
- node-version: "22.13.0"
- - name: Compile TypeScript tools
- working-directory: .
- run: |
- pnpm --dir sdk/typescript install --frozen-lockfile
- pnpm --dir sdk/typescript run build:ci
+ compile: true
- name: Fetch locked Rust dependencies
run: |
rustup toolchain install 1.97.1 --profile minimal
diff --git a/.github/workflows/native-unix.yml b/.github/workflows/native-unix.yml
index 6ea5ebe70..e7bc770ae 100644
--- a/.github/workflows/native-unix.yml
+++ b/.github/workflows/native-unix.yml
@@ -44,21 +44,10 @@ jobs:
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- - name: Set up pnpm
- uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0
+ - name: Set up TypeScript tools
+ uses: ./.github/actions/setup-tools
with:
- package_json_file: package.json
- cache: true
- cache_dependency_path: sdk/typescript/pnpm-lock.yaml
- - name: Set up Node.js 22
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
- with:
- node-version: "22.13.0"
- - name: Compile TypeScript tools
- working-directory: .
- run: |
- pnpm --dir sdk/typescript install --frozen-lockfile
- pnpm --dir sdk/typescript run build:ci
+ compile: true
- name: Set up Rust
run: |
# Rustup 1.29 retries component downloads, but not manifest checksums.
diff --git a/.github/workflows/native-windows.yml b/.github/workflows/native-windows.yml
index 2a62e4fdb..e3c7d18df 100644
--- a/.github/workflows/native-windows.yml
+++ b/.github/workflows/native-windows.yml
@@ -32,23 +32,11 @@ jobs:
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- - name: Set up pnpm
- uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0
+ - name: Set up TypeScript tools
+ uses: ./.github/actions/setup-tools
with:
- package_json_file: package.json
- cache: true
- cache_dependency_path: sdk/typescript/pnpm-lock.yaml
- - name: Set up Node.js 22
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
- with:
- node-version: "22.13.0"
architecture: ${{ matrix.arch }}
- - name: Compile TypeScript tools
- working-directory: .
- run: |
- pnpm --dir sdk/typescript install --frozen-lockfile
- if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
- pnpm --dir sdk/typescript run build:ci
+ compile: true
- name: Set up Rust
run: rustup toolchain install 1.97.1 --profile minimal --component rustfmt --component clippy --target ${{ matrix.target }}
- name: Check Rust source
diff --git a/.github/workflows/node-ci.yml b/.github/workflows/node-ci.yml
index 739455dd7..c67455b39 100644
--- a/.github/workflows/node-ci.yml
+++ b/.github/workflows/node-ci.yml
@@ -90,7 +90,7 @@ jobs:
.github/workflows/container-validate.yml)
container_validate=true
;;
- .github/workflows/node-ci.yml)
+ .github/workflows/node-ci.yml | .github/actions/setup-tools/*)
container_validate=true
test_quality=true
;;
@@ -185,18 +185,12 @@ jobs:
with:
fetch-depth: 2
persist-credentials: false
- - name: Set up pnpm
- uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0
+ - name: Set up TypeScript tools
+ uses: ./.github/actions/setup-tools
with:
- package_json_file: package.json
- cache: true
- cache_dependency_path: |
+ cache-dependency-path: |
sdk/typescript/pnpm-lock.yaml
plugins/codex-security/mcp-app/pnpm-lock.yaml
- - name: Set up Node.js
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
- with:
- node-version: "22.13.0"
- name: Install dependencies
run: |
pnpm --dir sdk/typescript install --frozen-lockfile
@@ -240,18 +234,12 @@ jobs:
run: node sdk/typescript/scripts/check-plugin-source.mjs
- name: Prepare native runtime
uses: ./.github/actions/download-native
- - name: Set up pnpm
- uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0
+ - name: Set up TypeScript tools
+ uses: ./.github/actions/setup-tools
with:
- package_json_file: package.json
- cache: true
- cache_dependency_path: |
+ cache-dependency-path: |
sdk/typescript/pnpm-lock.yaml
plugins/codex-security/mcp-app/pnpm-lock.yaml
- - name: Set up Node.js
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
- with:
- node-version: "22.13.0"
- name: Install dependencies
run: |
pnpm --dir sdk/typescript install --frozen-lockfile
@@ -291,18 +279,12 @@ jobs:
persist-credentials: false
- name: Prepare native runtime
uses: ./.github/actions/download-native
- - name: Set up pnpm
- uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0
+ - name: Set up TypeScript tools
+ uses: ./.github/actions/setup-tools
with:
- package_json_file: package.json
- cache: true
- cache_dependency_path: |
+ cache-dependency-path: |
sdk/typescript/pnpm-lock.yaml
plugins/codex-security/mcp-app/pnpm-lock.yaml
- - name: Set up Node.js
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
- with:
- node-version: "22.13.0"
- name: Set up Bun
uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
with:
@@ -390,16 +372,10 @@ jobs:
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- - name: Set up pnpm
- uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0
- with:
- package_json_file: package.json
- cache: true
- cache_dependency_path: plugins/codex-security/mcp-app/pnpm-lock.yaml
- - name: Set up Node.js
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
+ - name: Set up TypeScript tools
+ uses: ./.github/actions/setup-tools
with:
- node-version: "22.13.0"
+ cache-dependency-path: plugins/codex-security/mcp-app/pnpm-lock.yaml
- name: Install dependencies
run: pnpm --dir plugins/codex-security/mcp-app install --frozen-lockfile
- name: Install ripgrep
@@ -441,17 +417,13 @@ jobs:
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- sparse-checkout: plugins/codex-security
- - name: Set up pnpm
- uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0
- with:
- package_json_file: package.json
- cache: true
- cache_dependency_path: plugins/codex-security/mcp-app/pnpm-lock.yaml
- - name: Set up Node.js
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
+ sparse-checkout: |
+ plugins/codex-security
+ .github/actions/setup-tools
+ - name: Set up TypeScript tools
+ uses: ./.github/actions/setup-tools
with:
- node-version: "22.13.0"
+ cache-dependency-path: plugins/codex-security/mcp-app/pnpm-lock.yaml
- name: Install plugin dependencies
run: pnpm --dir plugins/codex-security/mcp-app install --frozen-lockfile
- name: Build and test the standalone host runtime
@@ -473,15 +445,10 @@ jobs:
with:
node-version: "22.13.0"
- name: Set up pnpm
- uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0
+ uses: ./.github/actions/setup-tools
with:
- package_json_file: package.json
- cache: true
- cache_dependency_path: sdk/typescript/pnpm-lock.yaml
- - name: Install dependencies
- run: pnpm --dir sdk/typescript install --frozen-lockfile
- - name: Compile CI scripts
- run: pnpm --dir sdk/typescript run build:ci
+ setup-node: false
+ compile: true
- name: Set up Python
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
diff --git a/.github/workflows/test-quality.yml b/.github/workflows/test-quality.yml
index 2981492b7..c0c383fce 100644
--- a/.github/workflows/test-quality.yml
+++ b/.github/workflows/test-quality.yml
@@ -107,11 +107,10 @@ jobs:
with:
node-version: "22.13.0"
- name: Set up pnpm
- uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0
+ uses: ./.github/actions/setup-tools
with:
- package_json_file: package.json
- cache: true
- cache_dependency_path: |
+ setup-node: false
+ cache-dependency-path: |
sdk/typescript/pnpm-lock.yaml
plugins/codex-security/mcp-app/pnpm-lock.yaml
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
@@ -157,15 +156,10 @@ jobs:
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: "22.13.0"
- - uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0
+ - uses: ./.github/actions/setup-tools
with:
- package_json_file: package.json
- cache: true
- cache_dependency_path: sdk/typescript/pnpm-lock.yaml
- - name: Install comparison dependencies
- run: pnpm --dir sdk/typescript install --frozen-lockfile
- - name: Compile CI scripts
- run: pnpm --dir sdk/typescript run build:ci
+ setup-node: false
+ compile: true
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
pattern: runner-*
@@ -195,11 +189,9 @@ jobs:
with:
# Stryker 10's Babel 8 requires Node 22.18+ or 24.11+.
node-version: "24.15.0"
- - uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0
+ - uses: ./.github/actions/setup-tools
with:
- package_json_file: package.json
- cache: true
- cache_dependency_path: sdk/typescript/pnpm-lock.yaml
+ setup-node: false
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
with:
bun-version: "1.3.14"
diff --git a/plugins/codex-security/mcp-app/tsconfig.json b/plugins/codex-security/mcp-app/tsconfig.json
index ef0922f6b..47eaa1ac3 100644
--- a/plugins/codex-security/mcp-app/tsconfig.json
+++ b/plugins/codex-security/mcp-app/tsconfig.json
@@ -1,7 +1,5 @@
{
"compilerOptions": {
- "esModuleInterop": true,
- "forceConsistentCasingInFileNames": true,
"module": "ESNext",
"moduleResolution": "Bundler",
"noEmit": true,
@@ -11,5 +9,11 @@
"target": "ES2022",
"types": ["node"]
},
- "include": ["main.ts", "artifact-writer-main.ts", "helpers-main.ts", "server.ts", "src"]
+ "include": [
+ "main.ts",
+ "artifact-writer-main.ts",
+ "helpers-main.ts",
+ "server.ts",
+ "src"
+ ]
}
diff --git a/sdk/typescript/scripts/build-plugin.mjs b/sdk/typescript/scripts/build-plugin.mjs
index 455c9147a..b80b99bbf 100644
--- a/sdk/typescript/scripts/build-plugin.mjs
+++ b/sdk/typescript/scripts/build-plugin.mjs
@@ -9,19 +9,17 @@ import {
rm,
} from "node:fs/promises";
import { dirname, join, posix, resolve } from "node:path";
-import { fileURLToPath, pathToFileURL } from "node:url";
+import { pathToFileURL } from "node:url";
import { promisify } from "node:util";
import { pluginContractFiles } from "./plugin-contract.mjs";
-const scriptDirectory = dirname(fileURLToPath(import.meta.url));
-const packageRoot = resolve(scriptDirectory, "..");
+const packageRoot = resolve(import.meta.dirname, "..");
const repositoryRoot = resolve(packageRoot, "../..");
const execFileAsync = promisify(execFile);
function validatePath(path) {
const parts = path.split("/");
if (
- path === "" ||
path.includes("\\") ||
posix.isAbsolute(path) ||
parts.some((part) => part === "" || part === "." || part === "..")
diff --git a/sdk/typescript/scripts/check-package.mjs b/sdk/typescript/scripts/check-package.mjs
index 8f3baae1e..f515784af 100644
--- a/sdk/typescript/scripts/check-package.mjs
+++ b/sdk/typescript/scripts/check-package.mjs
@@ -131,37 +131,17 @@ for (const file of required) {
const contract = JSON.parse(readFileSync(contractPath, "utf8"));
const pluginPaths = pluginContractFiles(contract);
-const pluginFiles = new Set(pluginPaths);
-if (pluginFiles.size !== pluginPaths.length) {
+if (new Set(pluginPaths).size !== pluginPaths.length) {
throw new Error("Plugin projection contract contains duplicate paths.");
}
-const pluginEntries = new Set();
-const pluginDirectories = new Set(["package/_bundled_plugin"]);
-for (const file of pluginFiles) {
- const archivePath = `package/_bundled_plugin/${file}`;
- pluginEntries.add(archivePath);
- if (!files.has(archivePath)) {
- throw new Error(`npm tarball is missing ${archivePath}.`);
- }
- const parts = file.split("/");
- for (let index = 1; index < parts.length; index++) {
- pluginDirectories.add(
- `package/_bundled_plugin/${parts.slice(0, index).join("/")}`,
- );
- }
-}
-
-const allowedRoot = new Set([
- "package/package.json",
- "package/README.md",
- "package/docs/dedupe-records.md",
- "package/LICENSE",
- "package/bin/codex-security.mjs",
- "package/schemas/project-config.schema.json",
-]);
-const distFiles = new Set(
- [
+const allowedFiles = new Set([
+ ...required,
+ "package/dist/server/dashboard/index.html",
+ "package/dist/server/dashboard/app.js",
+ "package/dist/server/dashboard/app.css",
+ "package/dist/server/dashboard/THIRD_PARTY_NOTICES.txt",
+ ...[
"api",
"artifact-export",
"auth",
@@ -264,37 +244,25 @@ const distFiles = new Set(
(extension) => `package/dist/${module}.${extension}`,
),
),
-);
-const dashboardFiles = new Set([
- "package/dist/server/dashboard/index.html",
- "package/dist/server/dashboard/app.js",
- "package/dist/server/dashboard/app.css",
- "package/dist/server/dashboard/THIRD_PARTY_NOTICES.txt",
]);
-for (const file of dashboardFiles) {
- if (!files.has(file)) throw new Error(`npm tarball is missing ${file}.`);
+for (const file of pluginPaths) {
+ const archivePath = `package/_bundled_plugin/${file}`;
+ allowedFiles.add(archivePath);
+ if (!files.has(archivePath)) {
+ throw new Error(`npm tarball is missing ${archivePath}.`);
+ }
}
-for (const file of distFiles) {
+
+for (const file of [...allowedFiles]) {
if (!files.has(file)) throw new Error(`npm tarball is missing ${file}.`);
+ const parts = file.split("/");
+ for (let index = 1; index < parts.length; index++) {
+ allowedFiles.add(`${parts.slice(0, index).join("/")}/`);
+ }
}
const unsafePath = /(?:^|\/)\.{1,2}(?:\/|$)/u;
for (const file of files) {
- const normalized = file.endsWith("/") ? file.slice(0, -1) : file;
- const allowed = file.endsWith("/")
- ? normalized === "package" ||
- normalized === "package/bin" ||
- normalized === "package/schemas" ||
- normalized === "package/docs" ||
- normalized === "package/dist" ||
- normalized === "package/dist/server" ||
- normalized === "package/dist/server/dashboard" ||
- normalized === "package/dist/deduplication" ||
- pluginDirectories.has(normalized)
- : allowedRoot.has(normalized) ||
- distFiles.has(normalized) ||
- dashboardFiles.has(normalized) ||
- pluginEntries.has(normalized);
- if (!allowed || unsafePath.test(file) || file.includes("\\")) {
+ if (!allowedFiles.has(file) || unsafePath.test(file) || file.includes("\\")) {
throw new Error(`npm tarball contains an unexpected file: ${file}.`);
}
}
diff --git a/sdk/typescript/scripts/check-plugin-source.mjs b/sdk/typescript/scripts/check-plugin-source.mjs
index c4e5a9751..568e4111b 100644
--- a/sdk/typescript/scripts/check-plugin-source.mjs
+++ b/sdk/typescript/scripts/check-plugin-source.mjs
@@ -1,11 +1,10 @@
import { execFile } from "node:child_process";
-import { dirname, resolve } from "node:path";
-import { fileURLToPath, pathToFileURL } from "node:url";
+import { resolve } from "node:path";
+import { pathToFileURL } from "node:url";
import { promisify } from "node:util";
const execFileAsync = promisify(execFile);
-const scriptDirectory = dirname(fileURLToPath(import.meta.url));
-const defaultPackageRoot = resolve(scriptDirectory, "..");
+const defaultPackageRoot = resolve(import.meta.dirname, "..");
export async function assertGeneratedPluginUntracked({
packageRoot = defaultPackageRoot,
diff --git a/sdk/typescript/scripts/compare-test-reports.mts b/sdk/typescript/scripts/compare-test-reports.mts
index e78b6103c..eda1be406 100644
--- a/sdk/typescript/scripts/compare-test-reports.mts
+++ b/sdk/typescript/scripts/compare-test-reports.mts
@@ -33,44 +33,43 @@ function matchingReports(pattern: string): string[] {
}
const parent = dirname(pattern);
const namePattern = basename(pattern);
- const directories = /[*?[]/u.test(parent)
- ? matchingReports(parent)
- : [parent];
- return directories.flatMap((directory) => {
- let names: string[];
- try {
- names = readdirSync(directory);
- } catch {
- return [];
- }
- return names
- .filter(
- (name) =>
- (!name.startsWith(".") || namePattern.startsWith(".")) &&
- minimatch(
- name,
- namePattern.replaceAll("\\", "\\\\").replaceAll("[^", "[\\^"),
- {
- dot: true,
- nobrace: true,
- noext: true,
- noglobstar: true,
- nonegate: true,
- nocomment: true,
- nocase: process.platform === "win32",
- },
- ),
- )
- .map((name) => join(directory, name))
- .filter((path) => {
- if (!directoriesOnly) return true;
- try {
- return statSync(path).isDirectory();
- } catch {
- return false;
- }
- });
- });
+ return (/[*?[]/u.test(parent) ? matchingReports(parent) : [parent]).flatMap(
+ (directory) => {
+ let names: string[];
+ try {
+ names = readdirSync(directory);
+ } catch {
+ return [];
+ }
+ return names
+ .filter(
+ (name) =>
+ (!name.startsWith(".") || namePattern.startsWith(".")) &&
+ minimatch(
+ name,
+ namePattern.replaceAll("\\", "\\\\").replaceAll("[^", "[\\^"),
+ {
+ dot: true,
+ nobrace: true,
+ noext: true,
+ noglobstar: true,
+ nonegate: true,
+ nocomment: true,
+ nocase: process.platform === "win32",
+ },
+ ),
+ )
+ .map((name) => join(directory, name))
+ .filter((path) => {
+ if (!directoriesOnly) return true;
+ try {
+ return statSync(path).isDirectory();
+ } catch {
+ return false;
+ }
+ });
+ },
+ );
}
function integer(value: string): bigint {
diff --git a/sdk/typescript/tests-ts/build-plugin.test.ts b/sdk/typescript/tests-ts/build-plugin.test.ts
index 3850aa43d..6bd3fb371 100644
--- a/sdk/typescript/tests-ts/build-plugin.test.ts
+++ b/sdk/typescript/tests-ts/build-plugin.test.ts
@@ -2,14 +2,11 @@ import { execFile } from "node:child_process";
import {
chmod,
mkdir,
- mkdtemp,
readFile,
readdir,
- rm,
stat,
writeFile,
} from "node:fs/promises";
-import { tmpdir } from "node:os";
import { delimiter, join } from "node:path";
import { fileURLToPath } from "node:url";
import { promisify } from "node:util";
@@ -17,14 +14,13 @@ import { afterEach, describe, expect, test } from "bun:test";
import { buildBundledPlugin } from "../scripts/build-plugin.mjs";
import { assertGeneratedPluginUntracked } from "../scripts/check-plugin-source.mjs";
-const temporaryDirectories: string[] = [];
+import { createTemporaryDirectories } from "./support/temporary-directories.js";
+
+const temporaryDirectories = createTemporaryDirectories({ canonical: false });
const execFileAsync = promisify(execFile);
-async function temporaryDirectory(): Promise<string> {
- const directory = await mkdtemp(join(tmpdir(), "codex-security-plugin-"));
- temporaryDirectories.push(directory);
- return directory;
-}
+const temporaryDirectory = () =>
+ temporaryDirectories.create("codex-security-plugin-");
async function writeFixture(
root: string,
@@ -60,13 +56,7 @@ async function snapshot(root: string) {
);
}
-afterEach(async () => {
- await Promise.all(
- temporaryDirectories
- .splice(0)
- .map((directory) => rm(directory, { force: true, recursive: true })),
- );
-});
+afterEach(temporaryDirectories.cleanup);
describe("bundled plugin build", () => {
test("builds the MCP runtime without invoking an npm launcher", async () => {
diff --git a/sdk/typescript/tests-ts/container-ci-workflow.test.ts b/sdk/typescript/tests-ts/container-ci-workflow.test.ts
index 6d286a050..17cabb01a 100644
--- a/sdk/typescript/tests-ts/container-ci-workflow.test.ts
+++ b/sdk/typescript/tests-ts/container-ci-workflow.test.ts
@@ -90,6 +90,7 @@ test.each([
["pull_request", false, ".github/workflows/container-release.yml", true],
["pull_request", false, ".github/workflows/native-windows.yml", true],
["pull_request", false, ".github/workflows/node-ci.yml", true],
+ ["pull_request", false, ".github/actions/setup-tools/action.yml", true],
["pull_request", false, "sdk/typescript/src/index.ts", true],
[
"pull_request",
@@ -127,6 +128,9 @@ test.each([
.map((line) => line.split("=")),
);
expect(outputs["container-validate"]).toBe(String(selected));
+ if (path === ".github/actions/setup-tools/action.yml") {
+ expect(outputs["test-quality"]).toBe("true");
+ }
} finally {
rmSync(directory, { recursive: true, force: true });
}
diff --git a/sdk/typescript/tests-ts/test-reports.test.ts b/sdk/typescript/tests-ts/test-reports.test.ts
index c2026b2d5..dccf8d5e0 100644
--- a/sdk/typescript/tests-ts/test-reports.test.ts
+++ b/sdk/typescript/tests-ts/test-reports.test.ts
@@ -18,6 +18,7 @@ import {
test,
} from "bun:test";
import { bashCommand, runCommand } from "./support/shell.js";
+import { createTemporaryDirectories } from "./support/temporary-directories.js";
const bash = bashCommand();
const packageRoot = fileURLToPath(new URL("..", import.meta.url));
@@ -45,18 +46,11 @@ beforeAll(async () => {
afterAll(async () => {
if (buildRoot) await rm(buildRoot, { recursive: true, force: true });
});
-const directories: string[] = [];
-afterEach(async () => {
- await Promise.all(
- directories
- .splice(0)
- .map((path) => rm(path, { recursive: true, force: true })),
- );
-});
+const directories = createTemporaryDirectories({ canonical: false });
+afterEach(directories.cleanup);
async function fixtures() {
- const root = await mkdtemp(join(tmpdir(), "codex-security-test-reports-"));
- directories.push(root);
+ const root = await directories.create("codex-security-test-reports-");
return {
root,
async report(
diff --git a/sdk/typescript/tsconfig.build.json b/sdk/typescript/tsconfig.build.json
index 3bf44f6f0..e36d09dd8 100644
--- a/sdk/typescript/tsconfig.build.json
+++ b/sdk/typescript/tsconfig.build.json
@@ -1,7 +1,6 @@
{
"extends": "./tsconfig.json",
"include": ["src/**/*.ts", "src/**/*.tsx"],
- "exclude": ["dist", "node_modules", "tests-ts"],
"compilerOptions": {
"rootDir": "src",
"outDir": "dist",
diff --git a/sdk/typescript/tsconfig.json b/sdk/typescript/tsconfig.json
index 4cb3fcf3b..b30beb90c 100644
--- a/sdk/typescript/tsconfig.json
+++ b/sdk/typescript/tsconfig.json
@@ -13,12 +13,9 @@
"scripts/fixtures/findings-service-sqlite.ts",
"scripts/fixtures/prepare-runner-scan.ts"
],
- "exclude": ["dist", "node_modules", "tests-ts/package.test.ts"],
"compilerOptions": {
"allowJs": false,
"checkJs": false,
- "esModuleInterop": true,
- "forceConsistentCasingInFileNames": true,
"incremental": true,
"isolatedModules": true,
"jsx": "react-jsx",