mirror of
https://github.com/github/codeql-action.git
synced 2026-04-27 17:39:15 +00:00
Add isCCR helper, and update isDefaultSetup
This commit is contained in:
@@ -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
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user