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

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());
});