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: show why selected checks did not pass (#1964)

Michael D'Angelo3d9afa7895ea
diff --git a/.github/scripts/check-ci-results.mjs b/.github/scripts/check-ci-results.mjs
index b40804f5f..922d19748 100644
--- a/.github/scripts/check-ci-results.mjs
+++ b/.github/scripts/check-ci-results.mjs
@@ -36,9 +36,18 @@ if (
process.argv[1] &&
import.meta.url === pathToFileURL(process.argv[1]).href
) {
- const failures = failedChecks(JSON.parse(process.env.CI_RESULTS));
+ const needs = JSON.parse(process.env.CI_RESULTS);
+ const failures = failedChecks(needs);
if (failures.length) {
- console.error(`Required CI checks did not pass: ${failures.join(", ")}`);
+ const details = failures.map((name) => {
+ if (name.endsWith(" classification"))
+ return `${name} (missing or invalid)`;
+ const result = needs[name]?.result;
+ if (name === "action-ci" && result === "success")
+ return `${name} (passed output was not "true")`;
+ return `${name} (${result || "missing result"})`;
+ });
+ console.error(`Required CI checks did not pass: ${details.join(", ")}`);
process.exitCode = 1;
} else console.log("All selected required CI checks passed.");
}
diff --git a/.github/scripts/test-ci-selection.mjs b/.github/scripts/test-ci-selection.mjs
index 7aaa22dd4..b5e1dafe4 100644
--- a/.github/scripts/test-ci-selection.mjs
+++ b/.github/scripts/test-ci-selection.mjs
@@ -1,4 +1,5 @@
import assert from "node:assert/strict";
+import { spawnSync } from "node:child_process";
import { readFileSync } from "node:fs";
import { test } from "node:test";
import { selectChecks } from "./select-ci-checks.mjs";
@@ -332,7 +333,7 @@ test("main, scheduled, manual, empty and retargeted changes receive full qualifi
assert.deepEqual(select([]), fullQualification);
});
-test("the final gate rejects every missing or unsuccessful selected check", () => {
+function successfulFullRun() {
const outputs = select([".github/workflows/node-ci.yml"]);
const needs = Object.fromEntries(
[
@@ -354,6 +355,11 @@ test("the final gate rejects every missing or unsuccessful selected check", () =
);
needs["action-ci"].outputs = { passed: "true" };
needs["classify-changes"] = { result: "success", outputs };
+ return needs;
+}
+
+test("the final gate rejects every missing or unsuccessful selected check", () => {
+ const needs = successfulFullRun();
assert.deepEqual(failedChecks(needs), []);
for (const name of Object.keys(needs)) {
for (const result of ["failure", "cancelled", "skipped", undefined]) {
@@ -365,6 +371,28 @@ test("the final gate rejects every missing or unsuccessful selected check", () =
}
});
+test("the final gate distinguishes a failed check from a skipped dependent job", () => {
+ const run = (needs) =>
+ spawnSync(process.execPath, ["check-ci-results.mjs"], {
+ cwd: new URL(".", import.meta.url),
+ env: { ...process.env, CI_RESULTS: JSON.stringify(needs) },
+ encoding: "utf8",
+ });
+ const needs = successfulFullRun();
+ const passed = run(needs);
+ assert.equal(passed.status, 0, passed.stderr);
+ assert.equal(passed.stdout.trim(), "All selected required CI checks passed.");
+
+ needs["static-checks"].result = "failure";
+ needs["container-validate"].result = "skipped";
+ const failed = run(needs);
+ assert.equal(failed.status, 1, failed.stderr);
+ assert.match(
+ failed.stderr,
+ /^Required CI checks did not pass: static-checks \(failure\), container-validate \(skipped\)$/m,
+ );
+});
+
test("documentation requires static checks and explicit selection, without skipped source failures", () => {
const outputs = select(["README.md"]);
const needs = {