@@ -50,31 +50,40 @@ test("Parsing analysis kinds requires at least one analysis kind", async (t) =>
5050 } ) ;
5151} ) ;
5252
53- test ( "getAnalysisKinds - returns expected analysis kinds for `analysis-kinds` input" , async ( t ) => {
54- const requiredInputStub = sinon . stub ( actionsUtil , "getRequiredInput" ) ;
55- requiredInputStub
56- . withArgs ( "analysis-kinds" )
57- . returns ( "code-scanning,code-quality" ) ;
58- const result = await getAnalysisKinds ( getRunnerLogger ( true ) , true ) ;
59- t . assert ( result . includes ( AnalysisKind . CodeScanning ) ) ;
60- t . assert ( result . includes ( AnalysisKind . CodeQuality ) ) ;
61- } ) ;
62-
63- test ( "getAnalysisKinds - includes `code-quality` when deprecated `quality-queries` input is used" , async ( t ) => {
64- const requiredInputStub = sinon . stub ( actionsUtil , "getRequiredInput" ) ;
65- requiredInputStub . withArgs ( "analysis-kinds" ) . returns ( "code-scanning" ) ;
66- const optionalInputStub = sinon . stub ( actionsUtil , "getOptionalInput" ) ;
67- optionalInputStub . withArgs ( "quality-queries" ) . returns ( "code-quality" ) ;
68- const result = await getAnalysisKinds ( getRunnerLogger ( true ) , true ) ;
69- t . assert ( result . includes ( AnalysisKind . CodeScanning ) ) ;
70- t . assert ( result . includes ( AnalysisKind . CodeQuality ) ) ;
71- } ) ;
72-
73- test ( "getAnalysisKinds - throws if `analysis-kinds` input is invalid" , async ( t ) => {
74- const requiredInputStub = sinon . stub ( actionsUtil , "getRequiredInput" ) ;
75- requiredInputStub . withArgs ( "analysis-kinds" ) . returns ( "no-such-thing" ) ;
76- await t . throwsAsync ( getAnalysisKinds ( getRunnerLogger ( true ) , true ) ) ;
77- } ) ;
53+ test . serial (
54+ "getAnalysisKinds - returns expected analysis kinds for `analysis-kinds` input" ,
55+ async ( t ) => {
56+ const requiredInputStub = sinon . stub ( actionsUtil , "getRequiredInput" ) ;
57+ requiredInputStub
58+ . withArgs ( "analysis-kinds" )
59+ . returns ( "code-scanning,code-quality" ) ;
60+ const result = await getAnalysisKinds ( getRunnerLogger ( true ) , true ) ;
61+ t . assert ( result . includes ( AnalysisKind . CodeScanning ) ) ;
62+ t . assert ( result . includes ( AnalysisKind . CodeQuality ) ) ;
63+ } ,
64+ ) ;
65+
66+ test . serial (
67+ "getAnalysisKinds - includes `code-quality` when deprecated `quality-queries` input is used" ,
68+ async ( t ) => {
69+ const requiredInputStub = sinon . stub ( actionsUtil , "getRequiredInput" ) ;
70+ requiredInputStub . withArgs ( "analysis-kinds" ) . returns ( "code-scanning" ) ;
71+ const optionalInputStub = sinon . stub ( actionsUtil , "getOptionalInput" ) ;
72+ optionalInputStub . withArgs ( "quality-queries" ) . returns ( "code-quality" ) ;
73+ const result = await getAnalysisKinds ( getRunnerLogger ( true ) , true ) ;
74+ t . assert ( result . includes ( AnalysisKind . CodeScanning ) ) ;
75+ t . assert ( result . includes ( AnalysisKind . CodeQuality ) ) ;
76+ } ,
77+ ) ;
78+
79+ test . serial (
80+ "getAnalysisKinds - throws if `analysis-kinds` input is invalid" ,
81+ async ( t ) => {
82+ const requiredInputStub = sinon . stub ( actionsUtil , "getRequiredInput" ) ;
83+ requiredInputStub . withArgs ( "analysis-kinds" ) . returns ( "no-such-thing" ) ;
84+ await t . throwsAsync ( getAnalysisKinds ( getRunnerLogger ( true ) , true ) ) ;
85+ } ,
86+ ) ;
7887
7988// Test the compatibility matrix by looping through all analysis kinds.
8089const analysisKinds = Object . values ( AnalysisKind ) ;
@@ -86,25 +95,31 @@ for (let i = 0; i < analysisKinds.length; i++) {
8695
8796 if ( analysisKind === otherAnalysis ) continue ;
8897 if ( compatibilityMatrix [ analysisKind ] . has ( otherAnalysis ) ) {
89- test ( `getAnalysisKinds - allows ${ analysisKind } with ${ otherAnalysis } ` , async ( t ) => {
90- const requiredInputStub = sinon . stub ( actionsUtil , "getRequiredInput" ) ;
91- requiredInputStub
92- . withArgs ( "analysis-kinds" )
93- . returns ( [ analysisKind , otherAnalysis ] . join ( "," ) ) ;
94- const result = await getAnalysisKinds ( getRunnerLogger ( true ) , true ) ;
95- t . is ( result . length , 2 ) ;
96- } ) ;
98+ test . serial (
99+ `getAnalysisKinds - allows ${ analysisKind } with ${ otherAnalysis } ` ,
100+ async ( t ) => {
101+ const requiredInputStub = sinon . stub ( actionsUtil , "getRequiredInput" ) ;
102+ requiredInputStub
103+ . withArgs ( "analysis-kinds" )
104+ . returns ( [ analysisKind , otherAnalysis ] . join ( "," ) ) ;
105+ const result = await getAnalysisKinds ( getRunnerLogger ( true ) , true ) ;
106+ t . is ( result . length , 2 ) ;
107+ } ,
108+ ) ;
97109 } else {
98- test ( `getAnalysisKinds - throws if ${ analysisKind } is enabled with ${ otherAnalysis } ` , async ( t ) => {
99- const requiredInputStub = sinon . stub ( actionsUtil , "getRequiredInput" ) ;
100- requiredInputStub
101- . withArgs ( "analysis-kinds" )
102- . returns ( [ analysisKind , otherAnalysis ] . join ( "," ) ) ;
103- await t . throwsAsync ( getAnalysisKinds ( getRunnerLogger ( true ) , true ) , {
104- instanceOf : ConfigurationError ,
105- message : `${ analysisKind } and ${ otherAnalysis } cannot be enabled at the same time` ,
106- } ) ;
107- } ) ;
110+ test . serial (
111+ `getAnalysisKinds - throws if ${ analysisKind } is enabled with ${ otherAnalysis } ` ,
112+ async ( t ) => {
113+ const requiredInputStub = sinon . stub ( actionsUtil , "getRequiredInput" ) ;
114+ requiredInputStub
115+ . withArgs ( "analysis-kinds" )
116+ . returns ( [ analysisKind , otherAnalysis ] . join ( "," ) ) ;
117+ await t . throwsAsync ( getAnalysisKinds ( getRunnerLogger ( true ) , true ) , {
118+ instanceOf : ConfigurationError ,
119+ message : `${ analysisKind } and ${ otherAnalysis } cannot be enabled at the same time` ,
120+ } ) ;
121+ } ,
122+ ) ;
108123 }
109124 }
110125}
@@ -122,44 +137,50 @@ test("Code Scanning configuration does not accept other SARIF extensions", (t) =
122137 }
123138} ) ;
124139
125- test ( "Risk Assessment configuration transforms SARIF upload payload" , ( t ) => {
126- process . env [ EnvVar . RISK_ASSESSMENT_ID ] = "1" ;
127- const payload = RiskAssessment . transformPayload ( {
128- commit_oid : "abc" ,
129- sarif : "sarif" ,
130- ref : "ref" ,
131- workflow_run_attempt : 1 ,
132- workflow_run_id : 1 ,
133- checkout_uri : "uri" ,
134- tool_names : [ ] ,
135- } ) as AssessmentPayload ;
136-
137- const expected : AssessmentPayload = { sarif : "sarif" , assessment_id : 1 } ;
138- t . deepEqual ( expected , payload ) ;
139- } ) ;
140-
141- test ( "Risk Assessment configuration throws for negative assessment IDs" , ( t ) => {
142- process . env [ EnvVar . RISK_ASSESSMENT_ID ] = "-1" ;
143- t . throws (
144- ( ) =>
145- RiskAssessment . transformPayload ( {
146- commit_oid : "abc" ,
147- sarif : "sarif" ,
148- ref : "ref" ,
149- workflow_run_attempt : 1 ,
150- workflow_run_id : 1 ,
151- checkout_uri : "uri" ,
152- tool_names : [ ] ,
153- } ) ,
154- {
155- instanceOf : Error ,
156- message : ( msg ) =>
157- msg . startsWith ( `${ EnvVar . RISK_ASSESSMENT_ID } must not be negative: ` ) ,
158- } ,
159- ) ;
160- } ) ;
161-
162- test ( "Risk Assessment configuration throws for invalid IDs" , ( t ) => {
140+ test . serial (
141+ "Risk Assessment configuration transforms SARIF upload payload" ,
142+ ( t ) => {
143+ process . env [ EnvVar . RISK_ASSESSMENT_ID ] = "1" ;
144+ const payload = RiskAssessment . transformPayload ( {
145+ commit_oid : "abc" ,
146+ sarif : "sarif" ,
147+ ref : "ref" ,
148+ workflow_run_attempt : 1 ,
149+ workflow_run_id : 1 ,
150+ checkout_uri : "uri" ,
151+ tool_names : [ ] ,
152+ } ) as AssessmentPayload ;
153+
154+ const expected : AssessmentPayload = { sarif : "sarif" , assessment_id : 1 } ;
155+ t . deepEqual ( expected , payload ) ;
156+ } ,
157+ ) ;
158+
159+ test . serial (
160+ "Risk Assessment configuration throws for negative assessment IDs" ,
161+ ( t ) => {
162+ process . env [ EnvVar . RISK_ASSESSMENT_ID ] = "-1" ;
163+ t . throws (
164+ ( ) =>
165+ RiskAssessment . transformPayload ( {
166+ commit_oid : "abc" ,
167+ sarif : "sarif" ,
168+ ref : "ref" ,
169+ workflow_run_attempt : 1 ,
170+ workflow_run_id : 1 ,
171+ checkout_uri : "uri" ,
172+ tool_names : [ ] ,
173+ } ) ,
174+ {
175+ instanceOf : Error ,
176+ message : ( msg ) =>
177+ msg . startsWith ( `${ EnvVar . RISK_ASSESSMENT_ID } must not be negative: ` ) ,
178+ } ,
179+ ) ;
180+ } ,
181+ ) ;
182+
183+ test . serial ( "Risk Assessment configuration throws for invalid IDs" , ( t ) => {
163184 process . env [ EnvVar . RISK_ASSESSMENT_ID ] = "foo" ;
164185 t . throws (
165186 ( ) =>
0 commit comments