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

ci: preserve Unix SDK test order on retries (#1941)

Michael D'Angelobc76a137e195
diff --git a/.github/workflows/node-ci.yml b/.github/workflows/node-ci.yml
index e5a5ef21f..edc2bd1af 100644
--- a/.github/workflows/node-ci.yml
+++ b/.github/workflows/node-ci.yml
@@ -189,7 +189,7 @@ jobs:
TMP: ${{ runner.temp }}
TMPDIR: ${{ runner.temp }}
CODEX_SECURITY_ALLOW_MACHINE_POLICY_TEST: "false"
- run: node --experimental-strip-types scripts/run-ci-tests.mts ${{ matrix.shard }}/6 ${{ matrix.os == 'ubuntu-latest' && '--coverage --coverage-reporter=text --coverage-reporter=lcov' || '' }}
+ run: node --experimental-strip-types scripts/run-ci-tests.mts ${{ matrix.shard }}/6 --seed=${{ github.run_number }} ${{ matrix.os == 'ubuntu-latest' && '--coverage --coverage-reporter=text --coverage-reporter=lcov' || '' }}
- name: Upload test reports
if: always()
continue-on-error: true
diff --git a/sdk/typescript/TESTING.md b/sdk/typescript/TESTING.md
index 0f5ba89cb..0eec2daed 100644
--- a/sdk/typescript/TESTING.md
+++ b/sdk/typescript/TESTING.md
@@ -43,6 +43,11 @@ executor receipts. To rerun just the installed-package check, use
Tests run in random order by default. To replay a failure, pass the seed from
Bun's summary to `pnpm run test --seed 12345`.
+The SDK shards in `node-ci` use the workflow run number as their seed, so
+rerunning a job repeats its test order. To replay a shard locally, use its
+platform, shard selector, and seed, for example
+`node --experimental-strip-types scripts/run-ci-tests.mts 2/6 --seed=12345`.
+
The local test commands pass a 30-second per-test timeout explicitly. Windows
CI and the Windows runner diagnostics allow 120 seconds for slower native
credential and document checks. `test:ci` writes `reports/junit.xml` and
diff --git a/sdk/typescript/tests-ts/skeleton.test.ts b/sdk/typescript/tests-ts/skeleton.test.ts
index 6eb88f816..bf4b7952c 100644
--- a/sdk/typescript/tests-ts/skeleton.test.ts
+++ b/sdk/typescript/tests-ts/skeleton.test.ts
@@ -259,6 +259,9 @@ 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,
+ ).toContain("--seed=${{ github.run_number }}");
expect(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 }}",