File tree Expand file tree Collapse file tree 2 files changed +37
-1
lines changed
Expand file tree Collapse file tree 2 files changed +37
-1
lines changed Original file line number Diff line number Diff line change 55 fixCodeQualityCategory ,
66 getPullRequestBranches ,
77 isAnalyzingPullRequest ,
8+ isCCR ,
9+ isDefaultSetup ,
10+ isDynamicWorkflow ,
811} from "./actions-util" ;
912import { computeAutomationID } from "./api-client" ;
1013import { EnvVar } from "./environment" ;
@@ -246,3 +249,25 @@ test("fixCodeQualityCategory", (t) => {
246249 } ,
247250 ) ;
248251} ) ;
252+
253+ test ( "isDynamicWorkflow() returns true if event name is `dynamic`" , ( t ) => {
254+ process . env . GITHUB_EVENT_NAME = "dynamic" ;
255+ t . assert ( isDynamicWorkflow ( ) ) ;
256+ process . env . GITHUB_EVENT_NAME = "push" ;
257+ t . false ( isDynamicWorkflow ( ) ) ;
258+ } ) ;
259+
260+ test ( "isCCR() returns true when expected" , ( t ) => {
261+ process . env . GITHUB_EVENT_NAME = "dynamic" ;
262+ process . env . CODEQL_ACTION_ANALYSIS_KEY =
263+ "dynamic/copilot-pull-request-reviewer" ;
264+ t . assert ( isCCR ( ) ) ;
265+ t . false ( isDefaultSetup ( ) ) ;
266+ } ) ;
267+
268+ test ( "isDefaultSetup() returns true when expected" , ( t ) => {
269+ process . env . GITHUB_EVENT_NAME = "dynamic" ;
270+ process . env . CODEQL_ACTION_ANALYSIS_KEY = "dynamic/github-code-scanning" ;
271+ t . assert ( isDefaultSetup ( ) ) ;
272+ t . false ( isCCR ( ) ) ;
273+ } ) ;
Original file line number Diff line number Diff line change @@ -254,7 +254,18 @@ export function isDynamicWorkflow(): boolean {
254254
255255/** Determines whether we are running in default setup. */
256256export function isDefaultSetup ( ) : boolean {
257- return isDynamicWorkflow ( ) ;
257+ return isDynamicWorkflow ( ) && ! isCCR ( ) ;
258+ }
259+
260+ /** Determines whether we are running in CCR. */
261+ export function isCCR ( ) : boolean {
262+ return (
263+ ( isDynamicWorkflow ( ) &&
264+ process . env [ "CODEQL_ACTION_ANALYSIS_KEY" ] ?. startsWith (
265+ "dynamic/copilot-pull-request-reviewer" ,
266+ ) ) ||
267+ false
268+ ) ;
258269}
259270
260271export function prettyPrintInvocation ( cmd : string , args : string [ ] ) : string {
You can’t perform that action at this time.
0 commit comments