@@ -5,6 +5,7 @@ import test from "ava";
55import * as sinon from "sinon" ;
66
77import * as actionsUtil from "./actions-util" ;
8+ import { AnalysisKind } from "./analyses" ;
89import { GitHubApiDetails } from "./api-client" ;
910import * as apiClient from "./api-client" ;
1011import { createStubCodeQL } from "./codeql" ;
@@ -108,6 +109,39 @@ test("Abort database upload if 'upload-database' input set to false", async (t)
108109 } ) ;
109110} ) ;
110111
112+ test ( "Abort database upload if 'analysis-kinds: code-scanning' is not enabled" , async ( t ) => {
113+ await withTmpDir ( async ( tmpDir ) => {
114+ setupActionsVars ( tmpDir , tmpDir ) ;
115+ sinon
116+ . stub ( actionsUtil , "getRequiredInput" )
117+ . withArgs ( "upload-database" )
118+ . returns ( "true" ) ;
119+ sinon . stub ( gitUtils , "isAnalyzingDefaultBranch" ) . resolves ( true ) ;
120+
121+ await mockHttpRequests ( 201 ) ;
122+
123+ const loggedMessages = [ ] ;
124+ await uploadDatabases (
125+ testRepoName ,
126+ getCodeQL ( ) ,
127+ {
128+ ...getTestConfig ( tmpDir ) ,
129+ analysisKinds : [ AnalysisKind . CodeQuality ] ,
130+ } ,
131+ testApiDetails ,
132+ getRecordingLogger ( loggedMessages ) ,
133+ ) ;
134+ t . assert (
135+ loggedMessages . find (
136+ ( v : LoggedMessage ) =>
137+ v . type === "debug" &&
138+ v . message ===
139+ "Not uploading database because 'analysis-kinds: code-scanning' is not enabled." ,
140+ ) !== undefined ,
141+ ) ;
142+ } ) ;
143+ } ) ;
144+
111145test ( "Abort database upload if running against GHES" , async ( t ) => {
112146 await withTmpDir ( async ( tmpDir ) => {
113147 setupActionsVars ( tmpDir , tmpDir ) ;
0 commit comments