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): run required checks after pull request edits (#1820)

Michael D'Angeloe8fb820caef7
diff --git a/.github/workflows/node-ci.yml b/.github/workflows/node-ci.yml
index c4301f128..bcf114640 100644
--- a/.github/workflows/node-ci.yml
+++ b/.github/workflows/node-ci.yml
@@ -10,14 +10,11 @@ permissions:
contents: read
concurrency:
- 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' || '' }}
+ group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}
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
@@ -474,8 +471,7 @@ jobs:
run: node --experimental-strip-types --test evals/workflow-routing/test_*.mts
required-test:
- # 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
+ name: ${{ matrix.os }} / node-22
needs:
[
validate-title,
@@ -489,9 +485,7 @@ jobs:
plugin-source,
container-validate,
]
- if: >-
- always() && (github.event.action != 'edited' || github.event.changes.body == null ||
- github.event.changes.title != null || github.event.changes.base != null)
+ if: always()
runs-on: ubuntu-latest
strategy:
fail-fast: false
@@ -593,11 +587,9 @@ jobs:
run: node scripts/check-package.mjs ../../dist/*.tgz
windows:
- 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 }}
+ name: windows-latest / node-${{ matrix.node == '22.13.0' && '22' || matrix.node }}
runs-on: ubuntu-latest
- if: >-
- always() && (github.event.action != 'edited' || github.event.changes.body == null ||
- github.event.changes.title != null || github.event.changes.base != null)
+ if: always()
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 24b4a3694..84d381801 100644
--- a/sdk/typescript/tests-ts/container-ci-workflow.test.ts
+++ b/sdk/typescript/tests-ts/container-ci-workflow.test.ts
@@ -142,7 +142,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).toStartWith("always() && (");
+ expect(gate.if).toBe("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 c812f3563..04580c724 100644
--- a/sdk/typescript/tests-ts/release-automation.test.ts
+++ b/sdk/typescript/tests-ts/release-automation.test.ts
@@ -3668,7 +3668,7 @@ describe("GitHub release workflow safeguards", () => {
expect(nodeCiWorkflow).toContain("needs: validate-title");
});
- test("preserves source checks while isolating body-only edits", async () => {
+ test("runs source validation with required check names for every PR edit", async () => {
const workflow = Bun.YAML.parse(nodeCiWorkflow) as {
concurrency: {
group: string;
@@ -3693,10 +3693,12 @@ describe("GitHub release workflow safeguards", () => {
const sourceGroup =
"${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}";
+ expect(workflow.concurrency.group).toBe(sourceGroup);
expect(workflow.concurrency["cancel-in-progress"]).toBe(
"${{ github.event_name == 'pull_request' }}",
);
expect(workflow.jobs["validate-title"]?.["timeout-minutes"]).toBe(10);
+ expect(workflow.jobs["validate-title"]?.if).toBeUndefined();
expect(
workflow.jobs["validate-title"]?.steps.find(
({ name }) =>
@@ -3725,7 +3727,7 @@ describe("GitHub release workflow safeguards", () => {
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() && (");
+ expect(workflow.jobs[job]?.if).toBe("always()");
}
const coverageGate = (job: string) =>
workflow.jobs[job]?.steps.find(
@@ -3827,84 +3829,23 @@ describe("GitHub release workflow safeguards", () => {
"macos-latest / node-22",
"windows-latest / node-22",
]);
- 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"));
- }
+ const names = [
+ ...(unixJob?.strategy?.matrix["os"] ?? []).map((os) =>
+ renderName(unixJob!.name, { os }),
+ ),
+ ...(windowsJob?.strategy?.matrix["node"] ?? []).map((node) =>
+ renderName(windowsJob!.name, { node }),
+ ),
+ ];
+ expect(names).toEqual([
+ "ubuntu-latest / node-22",
+ "macos-latest / node-22",
+ "windows-latest / node-22",
+ "windows-latest / node-24",
+ ]);
+ expect(names.filter((name) => requiredContexts.has(name)).sort()).toEqual(
+ [...requiredContexts].sort(),
+ );
});
test("documents a canonical historical-summary prefix block", () => {
diff --git a/sdk/typescript/tests-ts/workflow-quality.test.ts b/sdk/typescript/tests-ts/workflow-quality.test.ts
index f96d25c2a..6b81be85e 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).toStartWith("always() && (");
+ expect(aggregate.if).toBe("always()");
const gate = aggregate.steps.find(
(step) => step.name === "Require selected workflow checks",
)!;