@@ -2,6 +2,7 @@ import test, { ExecutionContext } from "ava";
22import * as sinon from "sinon" ;
33
44import * as actionsUtil from "./actions-util" ;
5+ import { AnalysisKind } from "./analyses" ;
56import * as codeql from "./codeql" ;
67import * as configUtils from "./config-utils" ;
78import { Feature } from "./feature-flags" ;
@@ -296,6 +297,17 @@ test("uploading failed SARIF run fails when workflow does not reference github/c
296297 t . truthy ( result . upload_failed_run_stack_trace ) ;
297298} ) ;
298299
300+ test ( "not uploading failed SARIF when `code-quality` is the only analysis kind" , async ( t ) => {
301+ const result = await testFailedSarifUpload ( t , createTestWorkflow ( [ ] ) , {
302+ analysisKinds : [ AnalysisKind . CodeQuality ] ,
303+ expectUpload : false ,
304+ } ) ;
305+ t . is (
306+ result . upload_failed_run_skipped_because ,
307+ "Code Quality is the only enabled analysis kind." ,
308+ ) ;
309+ } ) ;
310+
299311function createTestWorkflow (
300312 steps : workflow . WorkflowJobStep [ ] ,
301313) : workflow . Workflow {
@@ -328,15 +340,18 @@ async function testFailedSarifUpload(
328340 expectUpload = true ,
329341 exportDiagnosticsEnabled = false ,
330342 matrix = { } ,
343+ analysisKinds = [ AnalysisKind . CodeScanning ] ,
331344 } : {
332345 category ?: string ;
333346 databaseExists ?: boolean ;
334347 expectUpload ?: boolean ;
335348 exportDiagnosticsEnabled ?: boolean ;
336349 matrix ?: { [ key : string ] : string } ;
350+ analysisKinds ?: AnalysisKind [ ] ;
337351 } = { } ,
338352) : Promise < initActionPostHelper . UploadFailedSarifResult > {
339353 const config = createTestConfig ( {
354+ analysisKinds,
340355 codeQLCmd : "codeql" ,
341356 debugMode : true ,
342357 languages : [ ] ,
0 commit comments