Add isCCR helper, and update isDefaultSetup

This commit is contained in:
Michael B. Gale
2025-11-19 19:07:21 +00:00
parent 1512f400b3
commit 3eaf00092b
2 changed files with 37 additions and 1 deletions
+25
View File
@@ -5,6 +5,9 @@ import {
fixCodeQualityCategory,
getPullRequestBranches,
isAnalyzingPullRequest,
isCCR,
isDefaultSetup,
isDynamicWorkflow,
} from "./actions-util";
import { computeAutomationID } from "./api-client";
import { EnvVar } from "./environment";
@@ -246,3 +249,25 @@ test("fixCodeQualityCategory", (t) => {
},
);
});
test("isDynamicWorkflow() returns true if event name is `dynamic`", (t) => {
process.env.GITHUB_EVENT_NAME = "dynamic";
t.assert(isDynamicWorkflow());
process.env.GITHUB_EVENT_NAME = "push";
t.false(isDynamicWorkflow());
});
test("isCCR() returns true when expected", (t) => {
process.env.GITHUB_EVENT_NAME = "dynamic";
process.env.CODEQL_ACTION_ANALYSIS_KEY =
"dynamic/copilot-pull-request-reviewer";
t.assert(isCCR());
t.false(isDefaultSetup());
});
test("isDefaultSetup() returns true when expected", (t) => {
process.env.GITHUB_EVENT_NAME = "dynamic";
process.env.CODEQL_ACTION_ANALYSIS_KEY = "dynamic/github-code-scanning";
t.assert(isDefaultSetup());
t.false(isCCR());
});
+12 -1
View File
@@ -254,7 +254,18 @@ export function isDynamicWorkflow(): boolean {
/** Determines whether we are running in default setup. */
export function isDefaultSetup(): boolean {
return isDynamicWorkflow();
return isDynamicWorkflow() && !isCCR();
}
/** Determines whether we are running in CCR. */
export function isCCR(): boolean {
return (
(isDynamicWorkflow() &&
process.env["CODEQL_ACTION_ANALYSIS_KEY"]?.startsWith(
"dynamic/copilot-pull-request-reviewer",
)) ||
false
);
}
export function prettyPrintInvocation(cmd: string, args: string[]): string {