@@ -8,38 +8,41 @@ import { Logger } from "./logging";
88import * as upload_lib from "./upload-lib" ;
99import { GitHubVersion , unsafeEntriesInvariant } from "./util" ;
1010
11+ export interface UploadSarifState {
12+ /** The cached `CodeQL` instance, if any. */
13+ cachedCodeQL : CodeQL | undefined ;
14+ }
15+
1116// Maps analysis kinds to SARIF IDs.
1217export type UploadSarifResults = Partial <
1318 Record < analyses . AnalysisKind , upload_lib . UploadResult >
1419> ;
1520
16- /** The cached `CodeQL` instance, if any. */
17- let cachedCodeQL : CodeQL | undefined ;
18-
1921/** Get or initialise a `CodeQL` instance for use by the `upload-sarif` action. */
2022export async function getOrInitCodeQL (
23+ actionState : UploadSarifState ,
2124 logger : Logger ,
2225 gitHubVersion : GitHubVersion ,
2326 features : FeatureEnablement ,
2427 config : Config | undefined ,
2528) : Promise < CodeQL > {
2629 // Return the cached instance, if we have one.
27- if ( cachedCodeQL !== undefined ) return cachedCodeQL ;
30+ if ( actionState . cachedCodeQL !== undefined ) return actionState . cachedCodeQL ;
2831
2932 // If we have been able to load a `Config` from an earlier CodeQL Action step in the job,
3033 // then use the CodeQL executable that we have used previously. Otherwise, initialise the
3134 // CLI specifically for `upload-sarif`. Either way, we cache the instance.
3235 if ( config !== undefined ) {
33- cachedCodeQL = await codeql . getCodeQL ( config . codeQLCmd ) ;
36+ actionState . cachedCodeQL = await codeql . getCodeQL ( config . codeQLCmd ) ;
3437 } else {
35- cachedCodeQL = await upload_lib . minimalInitCodeQL (
38+ actionState . cachedCodeQL = await upload_lib . minimalInitCodeQL (
3639 logger ,
3740 gitHubVersion ,
3841 features ,
3942 ) ;
4043 }
4144
42- return cachedCodeQL ;
45+ return actionState . cachedCodeQL ;
4346}
4447
4548/**
0 commit comments