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: share SDK progress schedules and workflow fixtures (#2338)

Michael D'Angelocde200d79f51
diff --git a/sdk/typescript/tests-ts/api.test.ts b/sdk/typescript/tests-ts/api.test.ts
index f375c48bd..7b4db7b59 100644
--- a/sdk/typescript/tests-ts/api.test.ts
+++ b/sdk/typescript/tests-ts/api.test.ts
@@ -9869,7 +9869,9 @@ if __name__ == "__main__":
| readonly ["boundary"]
| readonly ["resolve"]
| readonly ["begin"];
+ type ProgressPartition = "batch" | "staged" | "each";
type ProgressScenario = {
+ partitions?: readonly ProgressPartition[];
name: string;
expected: ScanProgress;
steps: readonly ProgressScenarioStep[];
@@ -9877,10 +9879,6 @@ if __name__ == "__main__":
};
type ScopedProgressScenario = ProgressScenario & {
initialScope: number | null;
- partitions?: readonly ("batch" | "each")[];
- };
- type SplitProgressScenario = ProgressScenario & {
- partitions?: readonly boolean[];
};
function lastAnchorOrSave(steps: readonly ProgressScenarioStep[]): number {
const anchor = steps.findLastIndex(
@@ -9955,16 +9953,14 @@ if __name__ == "__main__":
initialScope = 8,
workerFirst,
stopBeforeResolution,
- split,
- partition = split ? "each" : "batch",
+ partition = "batch",
}: {
steps: readonly ProgressScenarioStep[];
expected: ScanProgress;
initialScope?: number | null;
workerFirst: boolean;
stopBeforeResolution?: boolean;
- split?: boolean;
- partition?: "batch" | "staged" | "each";
+ partition?: ProgressPartition;
},
{
resolutionIndex = -1,
@@ -10151,6 +10147,37 @@ if __name__ == "__main__":
expect(updates).toEqual(settled);
}
+ const progressScheduleTitle =
+ "retains $name (workers first=$workerFirst, stop=$stopBeforeResolution, partition=$partition)";
+
+ function progressSchedules(
+ scenarios: readonly ProgressScenario[],
+ defaultPartitions: readonly ProgressPartition[] = ["batch", "each"],
+ ) {
+ return scenarios.flatMap((scenario) =>
+ [false, true].flatMap((workerFirst) =>
+ (scenario.partitions ?? defaultPartitions).flatMap((partition) =>
+ [false, true].map((stopBeforeResolution) => ({
+ ...scenario,
+ workerFirst,
+ partition,
+ stopBeforeResolution,
+ })),
+ ),
+ ),
+ );
+ }
+
+ function testProgressSchedules(
+ scenarios: readonly ProgressScenario[],
+ partitions?: readonly ProgressPartition[],
+ ) {
+ test.each(progressSchedules(scenarios, partitions))(
+ progressScheduleTitle,
+ (scenario) => runProgressScenario(scenario),
+ );
+ }
+
describe("displayed receipt eligibility after inventory recovery", () => {
const scenarios: ScopedProgressScenario[] = [];
for (const mode of [
@@ -10221,24 +10248,7 @@ if __name__ == "__main__":
],
});
}
- test.each(
- scenarios.flatMap((scenario) =>
- [false, true].flatMap((workerFirst) =>
- (scenario.partitions ?? (["batch", "each"] as const)).flatMap(
- (partition) =>
- [false, true].map((stopBeforeResolution) => ({
- ...scenario,
- workerFirst,
- partition,
- stopBeforeResolution,
- })),
- ),
- ),
- ),
- )(
- "retains $name (workers first=$workerFirst, stop=$stopBeforeResolution, partition=$partition)",
- (scenario) => runProgressScenario(scenario),
- );
+ testProgressSchedules(scenarios);
});
describe("recovered scope and phase authority", () => {
@@ -10378,24 +10388,7 @@ if __name__ == "__main__":
});
}
}
- test.each(
- scenarios.flatMap((scenario) =>
- [false, true].flatMap((workerFirst) =>
- (scenario.partitions ?? (["batch", "each"] as const)).flatMap(
- (partition) =>
- [false, true].map((stopBeforeResolution) => ({
- ...scenario,
- workerFirst,
- partition,
- stopBeforeResolution,
- })),
- ),
- ),
- ),
- )(
- "retains $name (workers first=$workerFirst, stop=$stopBeforeResolution, partition=$partition)",
- (scenario) => runProgressScenario(scenario),
- );
+ testProgressSchedules(scenarios);
});
describe("admitted inventory across truncated live copies", () => {
@@ -10509,24 +10502,7 @@ if __name__ == "__main__":
});
}
}
- test.each(
- scenarios.flatMap((scenario) =>
- [false, true].flatMap((workerFirst) =>
- (scenario.partitions ?? (["batch", "each"] as const)).flatMap(
- (partition) =>
- [false, true].map((stopBeforeResolution) => ({
- ...scenario,
- workerFirst,
- partition,
- stopBeforeResolution,
- })),
- ),
- ),
- ),
- )(
- "retains $name (workers first=$workerFirst, stop=$stopBeforeResolution, partition=$partition)",
- (scenario) => runProgressScenario(scenario),
- );
+ testProgressSchedules(scenarios);
});
describe("saved inventory receipts and live prefix proof", () => {
@@ -10672,23 +10648,7 @@ if __name__ == "__main__":
["live", "anchor", "done"],
],
});
- test.each(
- scenarios.flatMap((scenario) =>
- [false, true].flatMap((workerFirst) =>
- (["batch", "each"] as const).flatMap((partition) =>
- [false, true].map((stopBeforeResolution) => ({
- ...scenario,
- workerFirst,
- partition,
- stopBeforeResolution,
- })),
- ),
- ),
- ),
- )(
- "retains $name (workers first=$workerFirst, stop=$stopBeforeResolution, partition=$partition)",
- (scenario) => runProgressScenario(scenario),
- );
+ testProgressSchedules(scenarios);
});
describe("source eligibility and durable inventory proof", () => {
@@ -10806,31 +10766,15 @@ if __name__ == "__main__":
);
}
}
- test.each(
- scenarios.flatMap((scenario) =>
- [false, true].flatMap((workerFirst) =>
- (["batch", "staged", "each"] as const).flatMap((partition) =>
- [false, true].map((stopBeforeResolution) => ({
- ...scenario,
- workerFirst,
- partition,
- stopBeforeResolution,
- })),
- ),
- ),
- ),
- )(
- "retains $name (workers first=$workerFirst, stop=$stopBeforeResolution, partition=$partition)",
- (scenario) => runProgressScenario(scenario),
- );
+ testProgressSchedules(scenarios, ["batch", "staged", "each"]);
});
function progressWithWorkerFollowup(
name: string,
state: ScanProgress,
steps: readonly ProgressScenarioStep[],
- partitions?: readonly boolean[],
- ): SplitProgressScenario {
+ partitions?: readonly ProgressPartition[],
+ ): ProgressScenario {
const next =
state.filesCompleted < state.filesTotal
? progress("reporting", state.filesCompleted + 1, state.filesTotal)
@@ -10866,28 +10810,8 @@ if __name__ == "__main__":
};
}
- function testProgressSchedules(scenarios: readonly SplitProgressScenario[]) {
- test.each(
- scenarios.flatMap((scenario) =>
- [false, true].flatMap((workerFirst) =>
- (scenario.partitions ?? [false, true]).flatMap((split) =>
- [false, true].map((stopBeforeResolution) => ({
- ...scenario,
- workerFirst,
- split,
- stopBeforeResolution,
- })),
- ),
- ),
- ),
- )(
- "retains $name (workers first=$workerFirst, stop=$stopBeforeResolution, split=$split)",
- (scenario) => runProgressScenario(scenario),
- );
- }
-
describe("review eligibility and ordered projections", () => {
- const scenarios: SplitProgressScenario[] = [];
+ const scenarios: ProgressScenario[] = [];
for (const mode of ["exact", "changed", "after inventory"] as const) {
for (const eligible of [false, true]) {
const initialTotal = eligible ? 7 : 6;
@@ -10966,7 +10890,7 @@ if __name__ == "__main__":
});
describe("inventory authority before scope projection", () => {
- const scenarios: SplitProgressScenario[] = [];
+ const scenarios: ProgressScenario[] = [];
for (const persisted of ["late", "early", "absent"] as const) {
for (const phase of ["reporting", "attack_path"] as const) {
const scenario = progressWithWorkerFollowup(
@@ -11037,7 +10961,7 @@ if __name__ == "__main__":
});
describe("inventory proof across completion intervals", () => {
- const scenarios: SplitProgressScenario[] = [];
+ const scenarios: ProgressScenario[] = [];
for (const total of [9, 10]) {
for (const tail of ["same", "shrink", "none"] as const) {
for (const exact of [false, true]) {
@@ -11146,7 +11070,7 @@ if __name__ == "__main__":
});
describe("bounded inventory marker evidence", () => {
- const scenarios: SplitProgressScenario[] = [];
+ const scenarios: ProgressScenario[] = [];
for (const command of ["changed", "exact"] as const) {
const live = command === "changed" ? "live-changed" : "live";
const scenario = progressWithWorkerFollowup(
@@ -11287,7 +11211,7 @@ if __name__ == "__main__":
});
describe("inventory occurrence and cutoff revalidation", () => {
- const scenarios: SplitProgressScenario[] = [];
+ const scenarios: ProgressScenario[] = [];
for (const control of ["dropped", "delivered", "eligible"] as const) {
const review = progress("validation", 3, control === "eligible" ? 8 : 10);
const scenario = progressWithWorkerFollowup(
@@ -11340,7 +11264,7 @@ if __name__ == "__main__":
: []),
["live", "anchor", "done"],
],
- control === "single batch" ? [false] : undefined,
+ control === "single batch" ? ["batch"] : undefined,
);
scenarios.push(scenario);
}
@@ -11754,26 +11678,11 @@ if __name__ == "__main__":
],
},
);
- test.each(
- scenarios.flatMap((scenario) =>
- [false, true].flatMap((workerFirst) =>
- [false, true].flatMap((split) =>
- [false, true].map((stopBeforeResolution) => ({
- ...scenario,
- workerFirst,
- split,
- stopBeforeResolution,
- })),
- ),
- ),
- ),
- )(
- "retains $name (workers first=$workerFirst, stop=$stopBeforeResolution, split=$split)",
- (scenario) =>
- runProgressScenario(scenario, {
- resolutionIndex: lastLiveAnchor(scenario.steps),
- pollReceipts: false,
- }),
+ test.each(progressSchedules(scenarios))(progressScheduleTitle, (scenario) =>
+ runProgressScenario(scenario, {
+ resolutionIndex: lastLiveAnchor(scenario.steps),
+ pollReceipts: false,
+ }),
);
});
@@ -11905,26 +11814,11 @@ if __name__ == "__main__":
};
}),
];
- test.each(
- scenarios.flatMap((scenario) =>
- [false, true].flatMap((workerFirst) =>
- [false, true].flatMap((split) =>
- [false, true].map((stopBeforeResolution) => ({
- ...scenario,
- workerFirst,
- split,
- stopBeforeResolution,
- })),
- ),
- ),
- ),
- )(
- "retains $name (workers first=$workerFirst, stop=$stopBeforeResolution, split=$split)",
- (scenario) =>
- runProgressScenario(scenario, {
- resolutionIndex: lastLiveAnchor(scenario.steps),
- pollReceipts: false,
- }),
+ test.each(progressSchedules(scenarios))(progressScheduleTitle, (scenario) =>
+ runProgressScenario(scenario, {
+ resolutionIndex: lastLiveAnchor(scenario.steps),
+ pollReceipts: false,
+ }),
);
});
diff --git a/sdk/typescript/tests-ts/container-ci-workflow.test.ts b/sdk/typescript/tests-ts/container-ci-workflow.test.ts
index 7f878b6e0..65e88840e 100644
--- a/sdk/typescript/tests-ts/container-ci-workflow.test.ts
+++ b/sdk/typescript/tests-ts/container-ci-workflow.test.ts
@@ -5,23 +5,7 @@ import { join } from "node:path";
import { fileURLToPath } from "node:url";
import { createTemporaryDirectoriesSync } from "./support/temporary-directories.js";
import { expect, test } from "bun:test";
-
-type Job = {
- uses?: string;
- needs?: string | string[];
- if?: string;
- steps?: Array<{ name?: string }>;
- strategy?: { matrix: { include: Array<{ architecture: string }> } };
-};
-
-function workflow(name: string) {
- return Bun.YAML.parse(
- readFileSync(
- new URL(`../../../.github/workflows/${name}.yml`, import.meta.url),
- "utf8",
- ),
- ) as { on: Record<string, unknown>; jobs: Record<string, Job> };
-}
+import { workflow } from "./support/workflow.js";
const ci = workflow("node-ci");
@@ -48,11 +32,9 @@ test("shares one native build and container matrix in automatic CI", () => {
needs: "native",
uses: "./.github/workflows/container-validate.yml",
});
- expect(
- validation.jobs["validate"]?.strategy?.matrix.include.map(
- ({ architecture }) => architecture,
- ),
- ).toEqual(["amd64", "arm64"]);
+ expect(validation.jobs["validate"]?.strategy?.matrix).toMatchObject({
+ include: [{ architecture: "amd64" }, { architecture: "arm64" }],
+ });
const steps = validation.jobs["validate"]!.steps!;
for (const name of [
"Verify customer build excludes secrets and scan data",
diff --git a/sdk/typescript/tests-ts/container-release-workflow.test.ts b/sdk/typescript/tests-ts/container-release-workflow.test.ts
index b363320c8..eff43f40c 100644
--- a/sdk/typescript/tests-ts/container-release-workflow.test.ts
+++ b/sdk/typescript/tests-ts/container-release-workflow.test.ts
@@ -5,37 +5,8 @@ import { copyFileSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
import { delimiter, join } from "node:path";
import { createTemporaryDirectoriesSync } from "./support/temporary-directories.js";
import { runWorkflowScript } from "./support/workflow-script.js";
+import { workflow } from "./support/workflow.js";
-type Step = {
- name: string;
- uses?: string;
- run?: string;
- with?: Record<string, string | boolean>;
-};
-type Job = {
- needs?: string | string[];
- uses?: string;
- if?: string;
- environment?: string;
- permissions?: Record<string, string>;
- outputs?: Record<string, string>;
- with?: Record<string, string>;
- steps?: Step[];
-};
-function workflow(name: string) {
- return Bun.YAML.parse(
- readFileSync(
- new URL(`../../../.github/workflows/${name}.yml`, import.meta.url),
- "utf8",
- ),
- ) as {
- concurrency?: {
- group: string;
- queue?: string;
- };
- jobs: Record<string, Job>;
- };
-}
const release = workflow("container-publish");
const parent = workflow("node-github-release");
const directories = createTemporaryDirectoriesSync();
diff --git a/sdk/typescript/tests-ts/native-artifact-cache.test.ts b/sdk/typescript/tests-ts/native-artifact-cache.test.ts
index 889510ad1..be50b9672 100644
--- a/sdk/typescript/tests-ts/native-artifact-cache.test.ts
+++ b/sdk/typescript/tests-ts/native-artifact-cache.test.ts
@@ -5,36 +5,7 @@ import { join } from "node:path";
import { expect, test } from "bun:test";
import { git } from "./git-fixture.js";
import { bashCommand, writeSource } from "./support/shell.js";
-
-interface Step {
- name?: string;
- id?: string;
- uses?: string;
- run?: string;
- if?: string;
- with?: Record<string, unknown>;
- "continue-on-error"?: boolean;
-}
-
-function workflow(name: string) {
- return Bun.YAML.parse(
- readFileSync(
- new URL(`../../../.github/workflows/${name}.yml`, import.meta.url),
- "utf8",
- ),
- ) as {
- on: { workflow_call?: { inputs: Record<string, { default?: unknown }> } };
- jobs: Record<
- string,
- {
- needs?: string | string[];
- if?: string;
- with?: Record<string, unknown>;
- steps?: Step[];
- }
- >;
- };
-}
+import { workflow } from "./support/workflow.js";
const native = workflow("native-artifacts");
const prepare = native.jobs["prepare"]!;
@@ -216,9 +187,9 @@ test.each([
);
test("source CI opts in to native artifact reuse", () => {
- expect(native.on.workflow_call?.inputs["reuse-verified"]?.default).toBe(
- false,
- );
+ expect(native.on["workflow_call"]).toMatchObject({
+ inputs: { "reuse-verified": { default: false } },
+ });
expect(workflow("node-ci").jobs["native"]?.with?.["reuse-verified"]).toBe(
true,
);
diff --git a/sdk/typescript/tests-ts/skeleton.test.ts b/sdk/typescript/tests-ts/skeleton.test.ts
index cf4196716..ed558ab6e 100644
--- a/sdk/typescript/tests-ts/skeleton.test.ts
+++ b/sdk/typescript/tests-ts/skeleton.test.ts
@@ -10,41 +10,12 @@ import {
CodexSecurityError,
} from "../src/index.js";
import { bashCommand, runCommand } from "./support/shell.js";
-
-interface WorkflowStep {
- name?: string;
- id?: string;
- uses?: string;
- with?: Record<string, unknown>;
- run?: string;
- if?: string;
- shell?: string;
- env?: Record<string, unknown>;
- "continue-on-error"?: boolean;
-}
-
-interface WorkflowJob {
- name?: string;
- needs?: string | string[];
- env?: Record<string, unknown>;
- strategy?: { matrix: Record<string, unknown> | string };
- steps?: WorkflowStep[];
-}
-
-async function workflow(name: string) {
- return Bun.YAML.parse(
- await readFile(
- new URL(`../../../.github/workflows/${name}`, import.meta.url),
- "utf8",
- ),
- ) as {
- on: Record<string, unknown>;
- env?: Record<string, unknown>;
- jobs: Record<string, WorkflowJob>;
- };
-}
+import { workflow } from "./support/workflow.js";
describe("TypeScript package skeleton", () => {
+ const ci = workflow("node-ci");
+ const quality = workflow("test-quality");
+
test("exports typed attack-path aliases", () => {
const dataflow: AttackPathDataflow = {
transformations: ["decode archive entry"],
@@ -88,20 +59,19 @@ describe("TypeScript package skeleton", () => {
).toEqual([]);
});
- test("runs Bun once per OS and checks every supported Node runtime with the installed package", async () => {
- const { jobs } = await workflow("node-ci.yml");
- expect(jobs["test"]?.strategy?.matrix).toEqual({
+ test("runs Bun once per OS and checks every supported Node runtime with the installed package", () => {
+ expect(ci.jobs["test"]?.strategy?.matrix).toEqual({
os: ["ubuntu-latest", "macos-latest"],
shard: [1, 2, 3, 4, 5, 6],
});
- expect(jobs["compatibility"]?.strategy?.matrix).toBe(
+ expect(ci.jobs["compatibility"]?.strategy?.matrix).toBe(
"${{ fromJSON(needs.classify-changes.outputs.compatibility-matrix) }}",
);
- expect(jobs["windows-test"]?.strategy?.matrix).toEqual({
+ expect(ci.jobs["windows-test"]?.strategy?.matrix).toEqual({
shard: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],
});
- const verificationSteps = jobs["compatibility"]!.steps!;
- const shardPython = jobs["windows-test"]!.steps!.find(({ uses }) =>
+ const verificationSteps = ci.jobs["compatibility"]!.steps!;
+ const shardPython = ci.jobs["windows-test"]!.steps!.find(({ uses }) =>
uses?.startsWith("actions/setup-python@"),
);
const pythonSetup = verificationSteps.findIndex(({ uses }) =>
@@ -130,9 +100,8 @@ describe("TypeScript package skeleton", () => {
);
});
- test("reuses npm downloads after lockfile changes without skipping package installation", async () => {
- const { jobs } = await workflow("node-ci.yml");
- const steps = jobs["compatibility"]!.steps!;
+ test("reuses npm downloads after lockfile changes without skipping package installation", () => {
+ const steps = ci.jobs["compatibility"]!.steps!;
const setup = steps.findIndex(({ id }) => id === "node");
const resolver = steps.findIndex(({ id }) => id === "npm-cache");
const restore = steps.findIndex(({ uses }) =>
@@ -161,8 +130,7 @@ describe("TypeScript package skeleton", () => {
});
test("npm cache fallback shares lockfile versions within each platform and architecture", async () => {
- const { jobs } = await workflow("node-ci.yml");
- const script = jobs["compatibility"]!.steps!.find(
+ const script = ci.jobs["compatibility"]!.steps!.find(
({ id }) => id === "npm-cache",
)!.run!;
const directory = await mkdtemp(join(tmpdir(), "npm-cache-workflow-"));
@@ -211,7 +179,6 @@ describe("TypeScript package skeleton", () => {
const packageJson = JSON.parse(
await readFile(new URL("../package.json", import.meta.url), "utf8"),
);
- const { jobs } = await workflow("node-ci.yml");
const bunConfig = parse(
await readFile(new URL("../bunfig.toml", import.meta.url), "utf8"),
);
@@ -221,18 +188,17 @@ describe("TypeScript package skeleton", () => {
expect(bunConfig).toMatchObject({ test: { randomize: true } });
expect(packageJson.scripts["test:ci"]).toContain("pnpm run test ");
expect(
- jobs["test"]?.steps?.find(({ name }) => name === "Test")?.run,
+ ci.jobs["test"]?.steps?.find(({ name }) => name === "Test")?.run,
).toContain("--seed=${{ github.run_number }}");
- expect(jobs["windows-test"]?.steps).toContainEqual(
+ expect(ci.jobs["windows-test"]?.steps).toContainEqual(
expect.objectContaining({
run: "node --experimental-strip-types sdk/typescript/scripts/run-ci-tests.mts ${{ matrix.shard }}/14 --seed=${{ github.run_number }}",
}),
);
});
- test("covers the Python runtime floor and native platform paths", async () => {
- const { jobs } = await workflow("node-ci.yml");
- const job = jobs["plugin-source"]!;
+ test("covers the Python runtime floor and native platform paths", () => {
+ const job = ci.jobs["plugin-source"]!;
expect(job.strategy?.matrix).toBe(
"${{ fromJSON(needs.classify-changes.outputs.python-matrix) }}",
);
@@ -250,9 +216,8 @@ describe("TypeScript package skeleton", () => {
).toBe("matrix.os == 'ubuntu-latest' && matrix.python == '3.12'");
});
- test("requires a nonempty native Python report without skips", async () => {
- const { jobs } = await workflow("node-ci.yml");
- const step = jobs["plugin-source"]!.steps!.find(
+ test("requires a nonempty native Python report without skips", () => {
+ const step = ci.jobs["plugin-source"]!.steps!.find(
({ name }) => name === "Require native platform coverage",
)!;
expect(step).toMatchObject({
@@ -262,9 +227,8 @@ describe("TypeScript package skeleton", () => {
expect(step).not.toHaveProperty("continue-on-error");
});
- test("requires the deterministic eval suites and their cross-project dependency pin", async () => {
- const { jobs } = await workflow("node-ci.yml");
- const requiredSteps = jobs["eval-contracts"]!.steps!.filter(
+ test("requires the deterministic eval suites and their cross-project dependency pin", () => {
+ const requiredSteps = ci.jobs["eval-contracts"]!.steps!.filter(
(step) => !step.if && !step["continue-on-error"],
);
expect(requiredSteps).toContainEqual(
@@ -297,9 +261,8 @@ describe("TypeScript package skeleton", () => {
]);
});
- test("checks one archive and restores its plugin before every test shard", async () => {
- const { jobs } = await workflow("node-ci.yml");
- const uploads = jobs["package"]!.steps!;
+ test("checks one archive and restores its plugin before every test shard", () => {
+ const uploads = ci.jobs["package"]!.steps!;
const inspection = uploads.findIndex(
({ name }) => name === "Inspect archive contents",
);
@@ -314,7 +277,7 @@ describe("TypeScript package skeleton", () => {
});
expect(uploads[upload]).not.toHaveProperty("continue-on-error");
for (const name of ["test", "windows-test", "mcp", "compatibility"]) {
- const job = jobs[name]!;
+ const job = ci.jobs[name]!;
expect(job.needs).toContain("package");
expect(
job.steps!.find(
@@ -323,7 +286,7 @@ describe("TypeScript package skeleton", () => {
).toEqual({ name: "package-${{ github.sha }}", path: "dist" });
}
for (const name of ["test", "windows-test", "mcp"]) {
- const steps = jobs[name]!.steps!;
+ const steps = ci.jobs[name]!.steps!;
const restore = steps.findIndex(
({ name }) => name === "Restore bundled plugin",
);
@@ -340,11 +303,10 @@ describe("TypeScript package skeleton", () => {
}
});
- test("runs static checks independently and keeps diagnostic uploads non-blocking", async () => {
- const { jobs } = await workflow("node-ci.yml");
- const steps = Object.values(jobs).flatMap((job) => job.steps ?? []);
- expect(jobs["static-checks"]?.needs).toBe("classify-changes");
- expect(jobs["package"]?.needs).toEqual(["classify-changes", "native"]);
+ test("runs static checks independently and keeps diagnostic uploads non-blocking", () => {
+ const steps = Object.values(ci.jobs).flatMap((job) => job.steps ?? []);
+ expect(ci.jobs["static-checks"]?.needs).toBe("classify-changes");
+ expect(ci.jobs["package"]?.needs).toEqual(["classify-changes", "native"]);
for (const [name, job] of [
["Check plugin source boundary", "package"],
["Typecheck", "static-checks"],
@@ -353,7 +315,7 @@ describe("TypeScript package skeleton", () => {
["Audit production dependencies", "static-checks"],
] as const) {
expect(
- jobs[job]!.steps!.filter((step) => step.name === name),
+ ci.jobs[job]!.steps!.filter((step) => step.name === name),
).toHaveLength(1);
}
for (const name of [
@@ -369,8 +331,8 @@ describe("TypeScript package skeleton", () => {
}
});
- test("runs Windows native proofs with and without symbolic-link privileges", async () => {
- const { jobs } = await workflow("native-windows.yml");
+ test("runs Windows native proofs with and without symbolic-link privileges", () => {
+ const { jobs } = workflow("native-windows");
const job = jobs["primitives"]!;
expect(job.env?.["CODEX_SECURITY_TEST_WINDOWS_SYMLINKS"]).toBe("required");
const restricted = job.steps!.find(
@@ -382,8 +344,7 @@ describe("TypeScript package skeleton", () => {
expect(restricted).not.toHaveProperty("continue-on-error");
});
- test("keeps machine-wide policy changes out of shared and diagnostic shards", async () => {
- const ci = await workflow("node-ci.yml");
+ test("keeps machine-wide policy changes out of shared and diagnostic shards", () => {
const windows = ci.jobs["windows-test"]!.steps!;
expect(
windows.find((step) => step.name === "Test shard ${{ matrix.shard }}")
@@ -399,7 +360,6 @@ describe("TypeScript package skeleton", () => {
"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([
"schedule",
"workflow_call",
@@ -412,9 +372,7 @@ describe("TypeScript package skeleton", () => {
expect(quality.env?.["CODEX_SECURITY_INTEGRATION"]).toBe("0");
});
- test("keeps shard layouts reproducible and report uploads rerunnable", async () => {
- const ci = await workflow("node-ci.yml");
- const quality = await workflow("test-quality.yml");
+ test("keeps shard layouts reproducible and report uploads rerunnable", () => {
const runner = quality.jobs["runner"]!;
const seed =
"${{ github.event_name == 'pull_request' && 1 || github.run_number }}";
@@ -554,9 +512,8 @@ describe("TypeScript package skeleton", () => {
);
});
- test("blocks CI and releases when the production dependency audit fails", async () => {
- for (const workflowName of ["node-ci.yml", "node-release.yml"]) {
- const { jobs } = await workflow(workflowName);
+ test("blocks CI and releases when the production dependency audit fails", () => {
+ for (const { jobs } of [ci, workflow("node-release")]) {
const audits = Object.values(jobs)
.flatMap((job) => job.steps ?? [])
.filter((step) => step.name === "Audit production dependencies");
diff --git a/sdk/typescript/tests-ts/support/workflow.ts b/sdk/typescript/tests-ts/support/workflow.ts
new file mode 100644
index 000000000..6ad99fb20
--- /dev/null
+++ b/sdk/typescript/tests-ts/support/workflow.ts
@@ -0,0 +1,39 @@
+import { readFileSync } from "node:fs";
+
+interface WorkflowStep {
+ name?: string;
+ id?: string;
+ uses?: string;
+ with?: Record<string, unknown>;
+ run?: string;
+ if?: string;
+ shell?: string;
+ env?: Record<string, unknown>;
+ "continue-on-error"?: boolean;
+}
+
+interface WorkflowJob {
+ uses?: string;
+ needs?: string | string[];
+ if?: string;
+ environment?: string;
+ outputs?: Record<string, string>;
+ with?: Record<string, unknown>;
+ env?: Record<string, unknown>;
+ strategy?: { matrix: Record<string, unknown> | string };
+ steps?: WorkflowStep[];
+}
+
+export function workflow(name: string) {
+ return Bun.YAML.parse(
+ readFileSync(
+ new URL(`../../../../.github/workflows/${name}.yml`, import.meta.url),
+ "utf8",
+ ),
+ ) as {
+ on: Record<string, unknown>;
+ env?: Record<string, unknown>;
+ concurrency?: { group: string; queue?: string };
+ jobs: Record<string, WorkflowJob>;
+ };
+}