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(ci): preserve source checks during metadata edits (#1858)

Michael D'Angelo1c78e00c1f33
diff --git a/.github/workflows/node-ci.yml b/.github/workflows/node-ci.yml
index cfb239100..66ac393ee 100644
--- a/.github/workflows/node-ci.yml
+++ b/.github/workflows/node-ci.yml
@@ -10,12 +10,14 @@ permissions:
contents: read
concurrency:
- group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}
+ # Metadata edits must not cancel source checks for the same pull request.
+ group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}${{ github.event_name == 'pull_request' && github.event.action == 'edited' && github.event.changes.base == null && '-metadata' || '' }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
- validate-title:
- name: validate pull request
+ classify-changes:
+ name: classify changes
+ if: github.event_name != 'pull_request' || github.event.action != 'edited' || github.event.changes.base != null
runs-on: ubuntu-latest
timeout-minutes: 10
outputs:
@@ -90,28 +92,14 @@ jobs:
printf 'test-quality=%s\n' "$test_quality" >> "$GITHUB_OUTPUT"
printf 'workflow-quality=%s\n' "$workflow_quality" >> "$GITHUB_OUTPUT"
- - name: Require a Conventional Commit pull request title
- if: github.event_name == 'pull_request'
- shell: bash
- env:
- PR_TITLE: ${{ github.event.pull_request.title }}
- run: |
- set -euo pipefail
- conventional_title='^([a-z][a-z0-9-]*)(\([a-z0-9][a-z0-9._/-]*\))?(!)?:[ ]([^[:space:]].*[^[:space:]]|[^[:space:]])$'
- if [[ "$PR_TITLE" == *$'\n'* || "$PR_TITLE" == *$'\r'* ||
- ! "$PR_TITLE" =~ $conventional_title ]]; then
- echo "Pull request title must follow <type>[optional scope][!]: <description>." >&2
- exit 1
- fi
-
workflow-quality:
- needs: validate-title
- if: needs.validate-title.outputs.workflow-quality == 'true'
+ needs: classify-changes
+ if: needs.classify-changes.outputs.workflow-quality == 'true'
uses: ./.github/workflows/workflow-quality.yml
static-checks:
name: typecheck and formatting
- needs: validate-title
+ needs: classify-changes
runs-on: ubuntu-latest
timeout-minutes: 20
permissions:
@@ -147,24 +135,24 @@ jobs:
run: pnpm --dir plugins/codex-security/mcp-app exec prettier --check "**/*.{cjs,cts,js,jsx,mjs,mts,ts,tsx}"
native:
- needs: validate-title
+ needs: classify-changes
uses: ./.github/workflows/native-artifacts.yml
container-validate:
- needs: [validate-title, native]
- if: needs.validate-title.outputs.container-validate == 'true'
+ needs: [classify-changes, native]
+ if: needs.classify-changes.outputs.container-validate == 'true'
uses: ./.github/workflows/container-validate.yml
test-quality:
- needs: [validate-title, native]
- if: needs.validate-title.outputs.test-quality == 'true'
+ needs: [classify-changes, native]
+ if: needs.classify-changes.outputs.test-quality == 'true'
uses: ./.github/workflows/test-quality.yml
with:
native-artifacts-ready: true
package:
name: build and check package
- needs: [validate-title, native]
+ needs: [classify-changes, native]
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
@@ -199,7 +187,7 @@ jobs:
test:
name: tests / ${{ matrix.os }} / shard-${{ matrix.shard }}
- needs: [validate-title, package]
+ needs: [classify-changes, package]
runs-on: ${{ matrix.os }}
timeout-minutes: 20
strategy:
@@ -254,7 +242,7 @@ jobs:
compatibility:
name: installed package / ${{ matrix.os }} / node-${{ matrix.node }}
- needs: [validate-title, package]
+ needs: [classify-changes, package]
runs-on: ${{ matrix.os }}
timeout-minutes: 20
strategy:
@@ -304,7 +292,7 @@ jobs:
mcp:
name: MCP app tests
- needs: [validate-title, package]
+ needs: [classify-changes, package]
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
@@ -338,7 +326,7 @@ jobs:
plugin-host:
name: standalone plugin / ${{ matrix.os }}
- needs: validate-title
+ needs: classify-changes
runs-on: ${{ matrix.os }}
timeout-minutes: 20
strategy:
@@ -361,7 +349,7 @@ jobs:
plugin-source:
name: plugin source contracts / ${{ matrix.os }} / python-${{ matrix.python }}
- needs: validate-title
+ needs: classify-changes
runs-on: ${{ matrix.os }}
timeout-minutes: 30
strategy:
@@ -472,10 +460,11 @@ jobs:
run: node --experimental-strip-types --test evals/workflow-routing/test_*.mts
required-test:
- name: ${{ matrix.os }} / node-22
+ # Skipped metadata jobs must not satisfy required source-check contexts.
+ name: ${{ github.event_name == 'pull_request' && github.event.action == 'edited' && github.event.changes.base == null && 'metadata / ' || '' }}${{ matrix.os }} / node-22
needs:
[
- validate-title,
+ classify-changes,
workflow-quality,
static-checks,
package,
@@ -486,7 +475,7 @@ jobs:
plugin-source,
container-validate,
]
- if: always()
+ if: &source-aggregate always() && (github.event_name != 'pull_request' || github.event.action != 'edited' || github.event.changes.base != null)
runs-on: ubuntu-latest
strategy:
fail-fast: false
@@ -494,18 +483,18 @@ jobs:
os: [ubuntu-latest, macos-latest]
steps:
- name: Require selected workflow checks
- if: needs.validate-title.outputs.workflow-quality == 'true' && needs.workflow-quality.result != 'success'
+ if: needs.classify-changes.outputs.workflow-quality == 'true' && needs.workflow-quality.result != 'success'
run: exit 1
- name: Require every Unix coverage job
- if: needs.validate-title.result != 'success' || (needs.static-checks.result != 'success' || needs.package.result != 'success' || needs.test.result != 'success' || needs.compatibility.result != 'success' || needs.mcp.result != 'success' || needs.plugin-host.result != 'success' || needs.plugin-source.result != 'success')
+ if: needs.classify-changes.result != 'success' || (needs.static-checks.result != 'success' || needs.package.result != 'success' || needs.test.result != 'success' || needs.compatibility.result != 'success' || needs.mcp.result != 'success' || needs.plugin-host.result != 'success' || needs.plugin-source.result != 'success')
run: exit 1
- name: Require selected container coverage
- if: needs.validate-title.outputs.container-validate == 'true' && needs.container-validate.result != 'success'
+ if: needs.classify-changes.outputs.container-validate == 'true' && needs.container-validate.result != 'success'
run: exit 1
windows-test:
name: windows-latest / node-22 / tests-${{ matrix.shard }}
- needs: [validate-title, package]
+ needs: [classify-changes, package]
runs-on: windows-latest
timeout-minutes: 40
strategy:
@@ -568,7 +557,7 @@ jobs:
windows-verify:
name: windows-latest / node-${{ matrix.node == '22.13.0' && '22' || matrix.node }} / verify
- needs: [validate-title, package]
+ needs: [classify-changes, package]
runs-on: windows-latest
timeout-minutes: 20
strategy: &windows-node-strategy
@@ -588,12 +577,12 @@ 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_name == 'pull_request' && github.event.action == 'edited' && github.event.changes.base == null && 'metadata / ' || '' }}windows-latest / node-${{ matrix.node == '22.13.0' && '22' || matrix.node }}
runs-on: ubuntu-latest
- if: always()
+ if: *source-aggregate
needs:
[
- validate-title,
+ classify-changes,
static-checks,
plugin-host,
plugin-source,
@@ -603,5 +592,5 @@ jobs:
strategy: *windows-node-strategy
steps:
- name: Require every Windows coverage job
- if: needs.validate-title.result != 'success' || (needs.static-checks.result != 'success' || needs.plugin-host.result != 'success' || needs.plugin-source.result != 'success' || needs.windows-test.result != 'success' || needs.windows-verify.result != 'success')
+ if: needs.classify-changes.result != 'success' || (needs.static-checks.result != 'success' || needs.plugin-host.result != 'success' || needs.plugin-source.result != 'success' || needs.windows-test.result != 'success' || needs.windows-verify.result != 'success')
run: exit 1
diff --git a/.github/workflows/validate-pr-title.yml b/.github/workflows/validate-pr-title.yml
index 08b810b74..92c84b4b3 100644
--- a/.github/workflows/validate-pr-title.yml
+++ b/.github/workflows/validate-pr-title.yml
@@ -2,7 +2,6 @@ name: Validate PR Title
on:
pull_request:
- branches: [main]
types: [opened, edited, reopened, synchronize]
permissions: {}
diff --git a/sdk/typescript/tests-ts/container-ci-workflow.test.ts b/sdk/typescript/tests-ts/container-ci-workflow.test.ts
index 84d381801..31330b63b 100644
--- a/sdk/typescript/tests-ts/container-ci-workflow.test.ts
+++ b/sdk/typescript/tests-ts/container-ci-workflow.test.ts
@@ -41,7 +41,7 @@ test("shares one native build and container matrix in automatic CI", () => {
),
).toEqual([ci.jobs["container-validate"]!]);
expect(ci.jobs["container-validate"]).toMatchObject({
- needs: ["validate-title", "native"],
+ needs: ["classify-changes", "native"],
uses: "./.github/workflows/container-validate.yml",
});
expect(container.jobs["container"]).toMatchObject({
@@ -105,7 +105,7 @@ test.each([
(eventName, baseChanged, path, selected) => {
const directory = mkdtempSync(join(tmpdir(), "container-ci-scope-"));
const output = join(directory, "outputs");
- const script = ci.jobs["validate-title"]!.steps!.find(
+ const script = ci.jobs["classify-changes"]!.steps!.find(
(step) => step.name === "Select additional checks",
)!.run!;
try {
@@ -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).toBe("always()");
+ expect(gate.if).toContain("always()");
const step = gate.steps!.find(
(step) => step.name === "Require selected container coverage",
)!;
@@ -151,7 +151,7 @@ test("required CI rejects failed, cancelled, or skipped selected container check
for (const result of ["success", "failure", "cancelled", "skipped"]) {
const condition = step
.if!.replaceAll(
- "needs.validate-title.outputs.container-validate",
+ "needs.classify-changes.outputs.container-validate",
`'${selected}'`,
)
.replaceAll("needs.container-validate.result", `'${result}'`);
diff --git a/sdk/typescript/tests-ts/release-automation.test.ts b/sdk/typescript/tests-ts/release-automation.test.ts
index 107e8d4d4..43a16ad74 100644
--- a/sdk/typescript/tests-ts/release-automation.test.ts
+++ b/sdk/typescript/tests-ts/release-automation.test.ts
@@ -3803,15 +3803,15 @@ describe("GitHub release workflow safeguards", () => {
)?.[1];
expect(releasePattern).toBeDefined();
- expect(ciPattern).toBe(releasePattern);
+ expect(ciPattern).toBeUndefined();
expect(titlePattern).toBe(releasePattern);
expect(nodeCiWorkflow).toContain(
"types: [opened, edited, reopened, synchronize]",
);
- expect(nodeCiWorkflow).toContain("needs: validate-title");
+ expect(nodeCiWorkflow).toContain("needs: classify-changes");
});
- test("runs source validation with required check names for every PR edit", async () => {
+ test("preserves source validation dependencies and fails closed on missing coverage", async () => {
const workflow = Bun.YAML.parse(nodeCiWorkflow) as {
concurrency: {
group: string;
@@ -3836,14 +3836,16 @@ 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.group).toStartWith(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["classify-changes"]?.["timeout-minutes"]).toBe(10);
+ expect(workflow.jobs["classify-changes"]?.if).toContain(
+ "github.event.changes.base != null",
+ );
expect(
- workflow.jobs["validate-title"]?.steps.find(
+ workflow.jobs["classify-changes"]?.steps.find(
({ name }) =>
name === "Checkout pull request for change classification",
)?.if,
@@ -3863,14 +3865,14 @@ describe("GitHub release workflow safeguards", () => {
expect(workflow.jobs[job]?.if).toBeUndefined();
}
for (const [name, job] of Object.entries(workflow.jobs)) {
- if (["validate-title", "required-test", "windows"].includes(name)) {
+ if (["classify-changes", "required-test", "windows"].includes(name)) {
continue;
}
- expect([job.needs].flat(), name).toContain("validate-title");
+ expect([job.needs].flat(), name).toContain("classify-changes");
expect(job.if ?? "", name).not.toMatch(/\b(always|failure|cancelled)\(/u);
}
for (const job of ["required-test", "windows"]) {
- expect(workflow.jobs[job]?.if).toBe("always()");
+ expect(workflow.jobs[job]?.if).toContain("always()");
}
const coverageGate = (job: string) =>
workflow.jobs[job]?.steps.find(
@@ -3897,7 +3899,7 @@ describe("GitHub release workflow safeguards", () => {
"needs.compatibility.result": upstream,
"needs.mcp.result": upstream,
"needs.test.result": upstream,
- "needs.validate-title.result": validation,
+ "needs.classify-changes.result": validation,
"needs.windows-test.result": upstream,
"needs.windows-verify.result": upstream,
};
@@ -3934,7 +3936,7 @@ describe("GitHub release workflow safeguards", () => {
conditionCases.push({
condition: coverageGate(gate)?.if ?? "",
values: {
- "needs.validate-title.result": "success",
+ "needs.classify-changes.result": "success",
...Object.fromEntries(
dependencies.map((job) => [
`needs.${job}.result`,
@@ -3954,41 +3956,6 @@ describe("GitHub release workflow safeguards", () => {
for (const [index, item] of conditionCases.entries()) {
expect(conditions[index], item.message).toBe(item.expected);
}
-
- const renderName = (template: string, values: Record<string, string>) => {
- let name = template;
- for (const [key, value] of Object.entries(values)) {
- name = name.replaceAll("${{ matrix." + key + " }}", value);
- }
- return name.replace(
- "${{ matrix.node == '22.13.0' && '22' || matrix.node }}",
- values["node"] === "22.13.0" ? "22" : (values["node"] ?? ""),
- );
- };
- const unixJob = workflow.jobs["required-test"];
- const windowsJob = workflow.jobs["windows"];
- const requiredContexts = new Set([
- "ubuntu-latest / node-22",
- "macos-latest / node-22",
- "windows-latest / node-22",
- ]);
- 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", () => {
@@ -4017,7 +3984,6 @@ describe("GitHub release workflow safeguards", () => {
"fix: preserve a trailing carriage return\r",
])("active title gates reject %s", (title) => {
for (const [workflow, step] of [
- [nodeCiWorkflow, "Require a Conventional Commit pull request title"],
[titleWorkflow, "Check conventional title"],
] as const) {
expect(
@@ -4034,7 +4000,6 @@ describe("GitHub release workflow safeguards", () => {
"dependency-update2: refresh release tooling",
])("active title gates accept previously valid title %s", (title) => {
for (const [workflow, step] of [
- [nodeCiWorkflow, "Require a Conventional Commit pull request title"],
[titleWorkflow, "Check conventional title"],
] as const) {
expect(
diff --git a/sdk/typescript/tests-ts/skeleton.test.ts b/sdk/typescript/tests-ts/skeleton.test.ts
index 9a4b37c89..6bff0df27 100644
--- a/sdk/typescript/tests-ts/skeleton.test.ts
+++ b/sdk/typescript/tests-ts/skeleton.test.ts
@@ -179,7 +179,7 @@ describe("TypeScript package skeleton", () => {
);
expect(jobs["required-test"]?.name).toEndWith("${{ matrix.os }} / node-22");
expect(jobs["required-test"]?.needs).toEqual([
- "validate-title",
+ "classify-changes",
"workflow-quality",
"static-checks",
"package",
@@ -191,7 +191,7 @@ describe("TypeScript package skeleton", () => {
"container-validate",
]);
expect(jobs["windows"]?.needs).toEqual([
- "validate-title",
+ "classify-changes",
"static-checks",
"plugin-host",
"plugin-source",
@@ -421,8 +421,8 @@ 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("validate-title");
- expect(jobs["package"]?.needs).toEqual(["validate-title", "native"]);
+ expect(jobs["static-checks"]?.needs).toBe("classify-changes");
+ expect(jobs["package"]?.needs).toEqual(["classify-changes", "native"]);
for (const [name, job] of [
["Check plugin source boundary", "package"],
["Typecheck", "static-checks"],
@@ -490,8 +490,8 @@ describe("TypeScript package skeleton", () => {
"workflow_dispatch",
]);
expect(ci.jobs["test-quality"]).toMatchObject({
- needs: ["validate-title", "native"],
- if: "needs.validate-title.outputs.test-quality == 'true'",
+ needs: ["classify-changes", "native"],
+ if: "needs.classify-changes.outputs.test-quality == 'true'",
uses: "./.github/workflows/test-quality.yml",
with: { "native-artifacts-ready": true },
});
diff --git a/sdk/typescript/tests-ts/workflow-quality.test.ts b/sdk/typescript/tests-ts/workflow-quality.test.ts
index 7ebb0a4f0..568228d48 100644
--- a/sdk/typescript/tests-ts/workflow-quality.test.ts
+++ b/sdk/typescript/tests-ts/workflow-quality.test.ts
@@ -10,15 +10,128 @@ const ci = Bun.YAML.parse(
"utf8",
),
) as {
+ on: { pull_request: { types: string[] } };
+ concurrency: { group: string; "cancel-in-progress": string };
jobs: Record<
string,
{
+ name: string;
+ needs?: string | string[];
if?: string;
+ strategy?: { matrix: Record<string, string[]> };
steps: { name: string; if?: string; run: string }[];
}
>;
};
+// These workflow expressions use boolean/string operators shared with JavaScript.
+// Evaluate the YAML itself so routing and check-name regressions are exercised.
+function expression(source: string, context: Record<string, unknown>): unknown {
+ return new Function(...Object.keys(context), `return (${source});`)(
+ ...Object.values(context),
+ );
+}
+
+function interpolate(source: string, context: Record<string, unknown>): string {
+ return source.replace(/\$\{\{(.*?)\}\}/g, (_, value: string) =>
+ String(expression(value, context)),
+ );
+}
+
+function eventContext(
+ action: string,
+ changes: Record<string, unknown> = {},
+ title = "test(ci): update checks",
+) {
+ return {
+ github: {
+ workflow: "node-ci",
+ event_name: action === "push" ? "push" : "pull_request",
+ event: {
+ action,
+ changes,
+ pull_request: action === "push" ? {} : { number: 1, title },
+ },
+ run_id: 123,
+ },
+ always: () => true,
+ };
+}
+
+const aggregates = [
+ ...ci.jobs["required-test"]!.strategy!.matrix["os"]!.map(
+ (os) => ["required-test", { os }, `${os} / node-22`] as const,
+ ),
+ ...ci.jobs["windows"]!.strategy!.matrix["node"]!.map(
+ (node) =>
+ [
+ "windows",
+ { node },
+ `windows-latest / node-${node === "22.13.0" ? "22" : node}`,
+ ] as const,
+ ),
+];
+
+test.each([
+ ["push", {}, true],
+ ["opened", {}, true],
+ ["synchronize", {}, true],
+ ["reopened", {}, true],
+ ["edited", { base: { ref: { from: "main" } } }, true],
+ ["edited", { title: { from: "Previous title" } }, false],
+ ["edited", { body: { from: "Previous body" } }, false],
+ ["edited", {}, false],
+] as const)(
+ "routes %s / %p without replacing required source checks",
+ (action, changes, sourceEvent) => {
+ const context = eventContext(action, changes);
+ const classifier = ci.jobs["classify-changes"]!;
+ expect(expression(classifier.if!, context)).toBe(sourceEvent);
+ for (const [id, matrix, name] of aggregates) {
+ const aggregate = ci.jobs[id]!;
+ expect(expression(aggregate.if!, context)).toBe(sourceEvent);
+ expect(interpolate(aggregate.name, { ...context, matrix })).toBe(
+ sourceEvent ? name : `metadata / ${name}`,
+ );
+ }
+ const sourceGroup = interpolate(
+ ci.concurrency.group,
+ eventContext("synchronize"),
+ );
+ const group = interpolate(ci.concurrency.group, context);
+ expect(group === sourceGroup).toBe(sourceEvent && action !== "push");
+ expect(interpolate(ci.concurrency["cancel-in-progress"], context)).toBe(
+ action === "push" ? "false" : "true",
+ );
+ },
+);
+
+test("all source jobs depend on classification and titles cannot block source checks", () => {
+ expect(aggregates.map(([, , name]) => name)).toEqual([
+ "ubuntu-latest / node-22",
+ "macos-latest / node-22",
+ "windows-latest / node-22",
+ "windows-latest / node-24",
+ ]);
+ expect(ci.on.pull_request.types).toEqual([
+ "opened",
+ "edited",
+ "reopened",
+ "synchronize",
+ ]);
+ for (const [id, job] of Object.entries(ci.jobs)) {
+ if (id !== "classify-changes") {
+ const dependencies = Array.isArray(job.needs) ? job.needs : [job.needs];
+ expect(dependencies, id).toContain("classify-changes");
+ }
+ }
+ const classifier = ci.jobs["classify-changes"]!;
+ expect(JSON.stringify(classifier)).not.toContain("PR_TITLE");
+ expect(
+ expression(classifier.if!, eventContext("opened", {}, "Invalid title")),
+ ).toBe(true);
+});
+
const musl = Bun.YAML.parse(
await readFile(
new URL("../../../.github/workflows/native-musl.yml", import.meta.url),
@@ -45,10 +158,44 @@ const musl = Bun.YAML.parse(
// These scripts run in Ubuntu Bash in CI, independent of the CLI platform.
const bashTest = test.skipIf(process.platform === "win32");
+bashTest(
+ "title corrections validate independently on every target branch",
+ async () => {
+ const titleWorkflow = Bun.YAML.parse(
+ await readFile(
+ new URL(
+ "../../../.github/workflows/validate-pr-title.yml",
+ import.meta.url,
+ ),
+ "utf8",
+ ),
+ ) as typeof ci;
+ expect(titleWorkflow.on.pull_request).not.toHaveProperty("branches");
+ expect(titleWorkflow.on.pull_request.types).toEqual(
+ ci.on.pull_request.types,
+ );
+ const step = titleWorkflow.jobs["validate-pr-title"]!.steps.find(
+ (candidate) => candidate.name === "Check conventional title",
+ )!;
+ for (const [title, expected] of [
+ ["Invalid title", 1],
+ ["test(ci): valid title", 0],
+ ["test(ci): valid title\nInvalid continuation", 1],
+ ["test(ci): corrected title", 0],
+ ] as const) {
+ const result = spawnSync("bash", ["-c", step.run], {
+ encoding: "utf8",
+ env: { ...process.env, PR_TITLE: title },
+ });
+ expect(result.status, result.stderr).toBe(expected);
+ }
+ },
+);
+
bashTest(
"selects workflow checks for workflow changes and main pushes",
async () => {
- const scope = ci.jobs["validate-title"]!.steps.find(
+ const scope = ci.jobs["classify-changes"]!.steps.find(
(step) => step.name === "Select additional checks",
)!;
const directory = await mkdtemp(join(tmpdir(), "workflow-quality-"));
@@ -225,13 +372,13 @@ 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).toContain("always()");
const gate = aggregate.steps.find(
(step) => step.name === "Require selected workflow checks",
)!;
const condition = gate
.if!.replaceAll(
- "needs.validate-title.outputs.workflow-quality",
+ "needs.classify-changes.outputs.workflow-quality",
'"$SELECTED"',
)
.replaceAll("needs.workflow-quality.result", '"$RESULT"');