@@ -16,7 +16,12 @@ import {
1616} from "./analyses" ;
1717import { EnvVar } from "./environment" ;
1818import { getRunnerLogger } from "./logging" ;
19- import { createFeatures , RecordingLogger , setupTests } from "./testing-utils" ;
19+ import {
20+ createFeatures ,
21+ RecordingLogger ,
22+ setupBaseActionsVars ,
23+ setupTests ,
24+ } from "./testing-utils" ;
2025import { AssessmentPayload } from "./upload-lib/types" ;
2126import { ConfigurationError } from "./util" ;
2227
@@ -72,6 +77,7 @@ test.serial(
7277test . serial (
7378 "getAnalysisKinds - only use `code-scanning` for multiple analysis kinds outside of test mode" ,
7479 async ( t ) => {
80+ setupBaseActionsVars ( ) ;
7581 process . env [ EnvVar . TEST_MODE ] = "false" ;
7682 const features = createFeatures ( [ ] ) ;
7783 const logger = new RecordingLogger ( ) ;
@@ -89,6 +95,44 @@ test.serial(
8995 } ,
9096) ;
9197
98+ test . serial (
99+ "getAnalysisKinds - logs error for non-default `analysis-kinds` in custom workflow" ,
100+ async ( t ) => {
101+ setupBaseActionsVars ( { GITHUB_EVENT_NAME : "push" } ) ;
102+ process . env [ EnvVar . TEST_MODE ] = "false" ;
103+ const features = createFeatures ( [ ] ) ;
104+ const logger = new RecordingLogger ( ) ;
105+ const requiredInputStub = sinon . stub ( actionsUtil , "getRequiredInput" ) ;
106+ requiredInputStub . withArgs ( "analysis-kinds" ) . returns ( "code-quality" ) ;
107+ const result = await getAnalysisKinds ( logger , features , true ) ;
108+ t . deepEqual ( result , [ AnalysisKind . CodeQuality ] ) ;
109+ t . assert (
110+ logger . hasMessage (
111+ "An analysis kind other than `code-scanning` was specified in a custom workflow." ,
112+ ) ,
113+ ) ;
114+ } ,
115+ ) ;
116+
117+ test . serial (
118+ "getAnalysisKinds - no error for non-default `analysis-kinds` in managed workflow" ,
119+ async ( t ) => {
120+ setupBaseActionsVars ( { GITHUB_EVENT_NAME : "dynamic" } ) ;
121+ process . env [ EnvVar . TEST_MODE ] = "false" ;
122+ const features = createFeatures ( [ ] ) ;
123+ const logger = new RecordingLogger ( ) ;
124+ const requiredInputStub = sinon . stub ( actionsUtil , "getRequiredInput" ) ;
125+ requiredInputStub . withArgs ( "analysis-kinds" ) . returns ( "code-quality" ) ;
126+ const result = await getAnalysisKinds ( logger , features , true ) ;
127+ t . deepEqual ( result , [ AnalysisKind . CodeQuality ] ) ;
128+ t . assert (
129+ ! logger . hasMessage (
130+ "An analysis kind other than `code-scanning` was specified in a custom workflow." ,
131+ ) ,
132+ ) ;
133+ } ,
134+ ) ;
135+
92136test . serial (
93137 "getAnalysisKinds - includes `code-quality` when deprecated `quality-queries` input is used" ,
94138 async ( t ) => {
@@ -133,6 +177,7 @@ for (let i = 0; i < analysisKinds.length; i++) {
133177 test . serial (
134178 `getAnalysisKinds - allows ${ analysisKind } with ${ otherAnalysis } ` ,
135179 async ( t ) => {
180+ setupBaseActionsVars ( ) ;
136181 process . env [ EnvVar . TEST_MODE ] = "true" ;
137182 const features = createFeatures ( [ ] ) ;
138183 const requiredInputStub = sinon . stub ( actionsUtil , "getRequiredInput" ) ;
@@ -151,6 +196,7 @@ for (let i = 0; i < analysisKinds.length; i++) {
151196 test . serial (
152197 `getAnalysisKinds - throws if ${ analysisKind } is enabled with ${ otherAnalysis } ` ,
153198 async ( t ) => {
199+ setupBaseActionsVars ( ) ;
154200 const features = createFeatures ( [ ] ) ;
155201 const requiredInputStub = sinon . stub ( actionsUtil , "getRequiredInput" ) ;
156202 requiredInputStub
0 commit comments