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: skip source checks for body-only pull request edits (#1708)

Michael D'Angelo5534a5ede16d
diff --git a/.github/workflows/node-ci.yml b/.github/workflows/node-ci.yml
index 26e5c9ddc..433c391b9 100644
--- a/.github/workflows/node-ci.yml
+++ b/.github/workflows/node-ci.yml
@@ -10,11 +10,14 @@ permissions:
contents: read
concurrency:
- group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}
+ group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}${{ github.event.action == 'edited' && github.event.changes.body != null && github.event.changes.title == null && github.event.changes.base == null && '-body-edit' || '' }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
validate-title:
+ if: >-
+ github.event.action != 'edited' || github.event.changes.body == null ||
+ github.event.changes.title != null || github.event.changes.base != null
name: validate pull request
runs-on: ubuntu-latest
timeout-minutes: 10
@@ -468,7 +471,8 @@ jobs:
run: node --experimental-strip-types --test evals/secret-discovery/test_*.mts
required-test:
- name: ${{ matrix.os }} / node-22
+ # Skipped metadata checks must not replace required source check results.
+ name: ${{ github.event.action == 'edited' && github.event.changes.body != null && github.event.changes.title == null && github.event.changes.base == null && 'body edit / ' || '' }}${{ matrix.os }} / node-22
needs:
[
validate-title,
@@ -482,7 +486,9 @@ jobs:
plugin-source,
container-validate,
]
- if: always()
+ if: >-
+ always() && (github.event.action != 'edited' || github.event.changes.body == null ||
+ github.event.changes.title != null || github.event.changes.base != null)
runs-on: ubuntu-latest
strategy:
fail-fast: false
@@ -584,9 +590,11 @@ jobs:
run: node scripts/check-package.mjs ../../dist/*.tgz
windows:
- name: windows-latest / node-${{ matrix.node == '22.13.0' && '22' || matrix.node }}
+ name: ${{ github.event.action == 'edited' && github.event.changes.body != null && github.event.changes.title == null && github.event.changes.base == null && 'body edit / ' || '' }}windows-latest / node-${{ matrix.node == '22.13.0' && '22' || matrix.node }}
runs-on: ubuntu-latest
- if: always()
+ if: >-
+ always() && (github.event.action != 'edited' || github.event.changes.body == null ||
+ github.event.changes.title != null || github.event.changes.base != null)
needs:
[
validate-title,
diff --git a/sdk/typescript/tests-ts/container-ci-workflow.test.ts b/sdk/typescript/tests-ts/container-ci-workflow.test.ts
index ccb712b83..f4445d56b 100644
--- a/sdk/typescript/tests-ts/container-ci-workflow.test.ts
+++ b/sdk/typescript/tests-ts/container-ci-workflow.test.ts
@@ -139,7 +139,7 @@ test.each([
test("required CI rejects failed, cancelled, or skipped selected container checks", () => {
const gate = ci.jobs["required-test"]!;
expect(gate.needs).toContain("container-validate");
- expect(gate.if).toBe("always()");
+ expect(gate.if).toStartWith("always() && (");
const step = gate.steps!.find(
(step) => step.name === "Require selected container coverage",
)!;
diff --git a/sdk/typescript/tests-ts/release-automation.test.ts b/sdk/typescript/tests-ts/release-automation.test.ts
index 0d0efa0bb..1a1c94a8c 100644
--- a/sdk/typescript/tests-ts/release-automation.test.ts
+++ b/sdk/typescript/tests-ts/release-automation.test.ts
@@ -3656,7 +3656,7 @@ describe("GitHub release workflow safeguards", () => {
expect(nodeCiWorkflow).toContain("needs: validate-title");
});
- test("keeps required contexts stable for every change", async () => {
+ test("preserves source checks while isolating body-only edits", async () => {
const workflow = Bun.YAML.parse(nodeCiWorkflow) as {
concurrency: {
group: string;
@@ -3667,6 +3667,7 @@ describe("GitHub release workflow safeguards", () => {
{
name: string;
if?: string;
+ needs?: string | string[];
"timeout-minutes"?: number;
strategy?: { matrix: Record<string, string[]> };
steps: Array<{
@@ -3678,9 +3679,8 @@ describe("GitHub release workflow safeguards", () => {
>;
};
- expect(workflow.concurrency.group).toBe(
- "${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}",
- );
+ const sourceGroup =
+ "${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}";
expect(workflow.concurrency["cancel-in-progress"]).toBe(
"${{ github.event_name == 'pull_request' }}",
);
@@ -3705,9 +3705,16 @@ describe("GitHub release workflow safeguards", () => {
]) {
expect(workflow.jobs[job]?.if).toBeUndefined();
}
- const requiredJobCondition = "always()";
- expect(workflow.jobs["required-test"]?.if).toBe(requiredJobCondition);
- expect(workflow.jobs["windows"]?.if).toBe(requiredJobCondition);
+ for (const [name, job] of Object.entries(workflow.jobs)) {
+ if (["validate-title", "required-test", "windows"].includes(name)) {
+ continue;
+ }
+ expect([job.needs].flat(), name).toContain("validate-title");
+ expect(job.if ?? "", name).not.toMatch(/\b(always|failure|cancelled)\(/u);
+ }
+ for (const job of ["required-test", "windows"]) {
+ expect(workflow.jobs[job]?.if).toStartWith("always() && (");
+ }
const coverageGate = (job: string) =>
workflow.jobs[job]?.steps.find(
({ name }) =>
@@ -3803,23 +3810,89 @@ describe("GitHub release workflow safeguards", () => {
};
const unixJob = workflow.jobs["required-test"];
const windowsJob = workflow.jobs["windows"];
- const fullNames = [
- ...(unixJob?.strategy?.matrix["os"] ?? []).map((os) =>
- renderName(unixJob?.name ?? "", { os }),
- ),
- ...(windowsJob?.strategy?.matrix["node"] ?? []).map((node) =>
- renderName(windowsJob?.name ?? "", { node }),
- ),
- ];
const requiredContexts = new Set([
"ubuntu-latest / node-22",
"macos-latest / node-22",
"windows-latest / node-22",
]);
-
- expect(
- fullNames.filter((name) => requiredContexts.has(name)).sort(),
- ).toEqual([...requiredContexts].sort());
+ const unixPrefix = /^\$\{\{ (.+) && 'body edit \/ ' \|\| '' \}\}/u.exec(
+ unixJob?.name ?? "",
+ )!;
+ const windowsPrefix = /^\$\{\{ (.+) && 'body edit \/ ' \|\| '' \}\}/u.exec(
+ windowsJob?.name ?? "",
+ )!;
+ const groupSuffix = /\$\{\{ (.+) && '-body-edit' \|\| '' \}\}$/u.exec(
+ workflow.concurrency.group.slice(sourceGroup.length),
+ )!;
+ expect(unixPrefix).not.toBeNull();
+ expect(windowsPrefix).not.toBeNull();
+ expect(groupSuffix).not.toBeNull();
+ expect(workflow.concurrency.group).toBe(sourceGroup + groupSuffix[0]);
+
+ for (const [action, body, title, base, runSource] of [
+ ["null", "null", "null", "null", true], // push
+ ["opened", "null", "null", "null", true],
+ ["reopened", "null", "null", "null", true],
+ ["synchronize", "null", "null", "null", true],
+ ["edited", "changed", "null", "null", false],
+ ["edited", "null", "changed", "null", true],
+ ["edited", "changed", "changed", "null", true],
+ ["edited", "null", "null", "changed", true],
+ ["edited", "changed", "null", "changed", true],
+ ["edited", "null", "null", "null", true],
+ ] as const) {
+ const values = {
+ "always()": "true",
+ "github.event.action": action,
+ "github.event.changes.body": body,
+ "github.event.changes.title": title,
+ "github.event.changes.base": base,
+ };
+ const guards = ["validate-title", "required-test", "windows"].map(
+ (job) => workflow.jobs[job]?.if ?? "",
+ );
+ const results = await evaluateWorkflowConditions(
+ [...guards, unixPrefix[1]!, windowsPrefix[1]!, groupSuffix[1]!].map(
+ (condition) => ({ condition, values }),
+ ),
+ );
+ expect(results, JSON.stringify(values)).toEqual([
+ runSource,
+ runSource,
+ runSource,
+ !runSource,
+ !runSource,
+ !runSource,
+ ]);
+ const prefix = results[3] ? "body edit / " : "";
+ const names = [
+ ...(unixJob?.strategy?.matrix["os"] ?? []).map((os) =>
+ renderName(unixJob!.name.replace(unixPrefix[0], prefix), { os }),
+ ),
+ ...(windowsJob?.strategy?.matrix["node"] ?? []).map((node) =>
+ renderName(windowsJob!.name.replace(windowsPrefix[0], prefix), {
+ node,
+ }),
+ ),
+ ];
+ expect(names).toEqual(
+ [
+ "ubuntu-latest / node-22",
+ "macos-latest / node-22",
+ "windows-latest / node-22",
+ "windows-latest / node-24",
+ ].map((name) => prefix + name),
+ );
+ expect(names.filter((name) => requiredContexts.has(name)).sort()).toEqual(
+ runSource ? [...requiredContexts].sort() : [],
+ );
+ expect(
+ workflow.concurrency.group.replace(
+ groupSuffix[0],
+ results[5] ? "-body-edit" : "",
+ ),
+ ).toBe(sourceGroup + (runSource ? "" : "-body-edit"));
+ }
});
test("documents a canonical historical-summary prefix block", () => {
diff --git a/sdk/typescript/tests-ts/skeleton.test.ts b/sdk/typescript/tests-ts/skeleton.test.ts
index 802ff933e..9a4b37c89 100644
--- a/sdk/typescript/tests-ts/skeleton.test.ts
+++ b/sdk/typescript/tests-ts/skeleton.test.ts
@@ -177,7 +177,7 @@ describe("TypeScript package skeleton", () => {
expect([false, "false"]).not.toContain(
verificationSteps[pythonSetup]?.with?.["update-environment"],
);
- expect(jobs["required-test"]?.name).toBe("${{ matrix.os }} / node-22");
+ expect(jobs["required-test"]?.name).toEndWith("${{ matrix.os }} / node-22");
expect(jobs["required-test"]?.needs).toEqual([
"validate-title",
"workflow-quality",
diff --git a/sdk/typescript/tests-ts/workflow-quality.test.ts b/sdk/typescript/tests-ts/workflow-quality.test.ts
index 6b81be85e..f96d25c2a 100644
--- a/sdk/typescript/tests-ts/workflow-quality.test.ts
+++ b/sdk/typescript/tests-ts/workflow-quality.test.ts
@@ -207,7 +207,7 @@ bashTest(
"required Unix checks fail when selected workflow checks do not pass",
() => {
const aggregate = ci.jobs["required-test"]!;
- expect(aggregate.if).toBe("always()");
+ expect(aggregate.if).toStartWith("always() && (");
const gate = aggregate.steps.find(
(step) => step.name === "Require selected workflow checks",
)!;