Skip to content

Commit 5094019

Browse files
committed
Refactor Config type out of config-utils
1 parent 708e106 commit 5094019

2 files changed

Lines changed: 132 additions & 120 deletions

File tree

src/config-utils.ts

Lines changed: 4 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ import {
1919
getAnalysisConfig,
2020
} from "./analyses";
2121
import * as api from "./api-client";
22-
import { CachingKind, getCachingKind } from "./caching-utils";
22+
import { getCachingKind } from "./caching-utils";
2323
import { type CodeQL } from "./codeql";
24+
import { type Config } from "./config/action-config";
2425
import {
2526
calculateAugmentation,
2627
ExcludeQueryFilter,
@@ -82,6 +83,8 @@ import {
8283
getEnv,
8384
} from "./util";
8485

86+
export { type Config } from "./config/action-config";
87+
8588
/**
8689
* The minimum available disk space (in MB) required to perform overlay analysis.
8790
* If the available disk space on the runner is below the threshold when deciding
@@ -143,125 +146,6 @@ export interface RegistryConfigNoCredentials {
143146
kind?: "github" | "docker";
144147
}
145148

146-
/**
147-
* Format of the parsed config file.
148-
*/
149-
export interface Config {
150-
/**
151-
* The version of the CodeQL Action that the configuration is for.
152-
*/
153-
version: string;
154-
/**
155-
* Set of analysis kinds that are enabled.
156-
*/
157-
analysisKinds: AnalysisKind[];
158-
/**
159-
* Set of languages to run analysis for.
160-
*/
161-
languages: Language[];
162-
/**
163-
* Build mode, if set. Currently only a single build mode is supported per job.
164-
*/
165-
buildMode: BuildMode | undefined;
166-
/**
167-
* A unaltered copy of the original user input.
168-
* Mainly intended to be used for status reporting.
169-
* If any field is useful for the actual processing
170-
* of the action then consider pulling it out to a
171-
* top-level field above.
172-
*/
173-
originalUserInput: UserConfig;
174-
/**
175-
* Directory to use for temporary files that should be
176-
* deleted at the end of the job.
177-
*/
178-
tempDir: string;
179-
/**
180-
* Path of the CodeQL executable.
181-
*/
182-
codeQLCmd: string;
183-
/**
184-
* Version of GitHub we are talking to.
185-
*/
186-
gitHubVersion: GitHubVersion;
187-
/**
188-
* The location where CodeQL databases should be stored.
189-
*/
190-
dbLocation: string;
191-
/**
192-
* Specifies whether we are debugging mode and should try to produce extra
193-
* output for debugging purposes when possible.
194-
*/
195-
debugMode: boolean;
196-
/**
197-
* Specifies the name of the debugging artifact if we are in debug mode.
198-
*/
199-
debugArtifactName: string;
200-
/**
201-
* Specifies the name of the database in the debugging artifact.
202-
*/
203-
debugDatabaseName: string;
204-
/**
205-
* The configuration we computed by combining `originalUserInput` with `augmentationProperties`,
206-
* as well as adjustments made to it based on unsupported or required options.
207-
*/
208-
computedConfig: UserConfig;
209-
210-
/**
211-
* Partial map from languages to locations of TRAP caches for that language.
212-
* If a key is omitted, then TRAP caching should not be used for that language.
213-
*/
214-
trapCaches: { [language: Language]: string };
215-
216-
/**
217-
* Time taken to download TRAP caches. Used for status reporting.
218-
*/
219-
trapCacheDownloadTime: number;
220-
221-
/** A value indicating how dependency caching should be used. */
222-
dependencyCachingEnabled: CachingKind;
223-
224-
/** The keys of caches that we restored, if any. */
225-
dependencyCachingRestoredKeys: string[];
226-
227-
/**
228-
* Extra query exclusions to append to the config.
229-
*/
230-
extraQueryExclusions: ExcludeQueryFilter[];
231-
232-
/**
233-
* The overlay database mode to use.
234-
*/
235-
overlayDatabaseMode: OverlayDatabaseMode;
236-
237-
/**
238-
* Whether to use caching for overlay databases. If it is true, the action
239-
* will upload the created overlay-base database to the actions cache, and
240-
* download an overlay-base database from the actions cache before it creates
241-
* a new overlay database. If it is false, the action assumes that the
242-
* workflow will be responsible for managing database storage and retrieval.
243-
*
244-
* This property has no effect unless `overlayDatabaseMode` is `Overlay` or
245-
* `OverlayBase`.
246-
*/
247-
useOverlayDatabaseCaching: boolean;
248-
249-
/**
250-
* Whether the overlay database mode was set explicitly.
251-
*/
252-
overlayModeSetExplicitly: boolean;
253-
254-
/**
255-
* A partial mapping from repository properties that affect us to their values.
256-
*/
257-
repositoryProperties: RepositoryProperties;
258-
259-
/**
260-
* Whether to enable file coverage information.
261-
*/
262-
enableFileCoverageInformation: boolean;
263-
}
264-
265149
async function getSupportedLanguageMap(
266150
codeql: CodeQL,
267151
logger: Logger,

src/config/action-config.ts

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
import type { AnalysisKind } from "../analyses";
2+
import type { CachingKind } from "../caching-utils";
3+
import type { RepositoryProperties } from "../feature-flags/properties";
4+
import type { Language } from "../languages";
5+
import type { OverlayDatabaseMode } from "../overlay/overlay-database-mode";
6+
import type { BuildMode, GitHubVersion } from "../util";
7+
8+
import type { ExcludeQueryFilter, UserConfig } from "./db-config";
9+
10+
/**
11+
* Format of the CodeQL Action configuration state that is persisted
12+
* between steps of the CodeQL Action in a CodeQL workflow.
13+
*/
14+
export interface Config {
15+
/**
16+
* The version of the CodeQL Action that the configuration is for.
17+
*/
18+
version: string;
19+
/**
20+
* Set of analysis kinds that are enabled.
21+
*/
22+
analysisKinds: AnalysisKind[];
23+
/**
24+
* Set of languages to run analysis for.
25+
*/
26+
languages: Language[];
27+
/**
28+
* Build mode, if set. Currently only a single build mode is supported per job.
29+
*/
30+
buildMode: BuildMode | undefined;
31+
/**
32+
* A unaltered copy of the original user input.
33+
* Mainly intended to be used for status reporting.
34+
* If any field is useful for the actual processing
35+
* of the action then consider pulling it out to a
36+
* top-level field above.
37+
*/
38+
originalUserInput: UserConfig;
39+
/**
40+
* Directory to use for temporary files that should be
41+
* deleted at the end of the job.
42+
*/
43+
tempDir: string;
44+
/**
45+
* Path of the CodeQL executable.
46+
*/
47+
codeQLCmd: string;
48+
/**
49+
* Version of GitHub we are talking to.
50+
*/
51+
gitHubVersion: GitHubVersion;
52+
/**
53+
* The location where CodeQL databases should be stored.
54+
*/
55+
dbLocation: string;
56+
/**
57+
* Specifies whether we are debugging mode and should try to produce extra
58+
* output for debugging purposes when possible.
59+
*/
60+
debugMode: boolean;
61+
/**
62+
* Specifies the name of the debugging artifact if we are in debug mode.
63+
*/
64+
debugArtifactName: string;
65+
/**
66+
* Specifies the name of the database in the debugging artifact.
67+
*/
68+
debugDatabaseName: string;
69+
/**
70+
* The configuration we computed by combining `originalUserInput` with `augmentationProperties`,
71+
* as well as adjustments made to it based on unsupported or required options.
72+
*/
73+
computedConfig: UserConfig;
74+
75+
/**
76+
* Partial map from languages to locations of TRAP caches for that language.
77+
* If a key is omitted, then TRAP caching should not be used for that language.
78+
*/
79+
trapCaches: { [language: Language]: string };
80+
81+
/**
82+
* Time taken to download TRAP caches. Used for status reporting.
83+
*/
84+
trapCacheDownloadTime: number;
85+
86+
/** A value indicating how dependency caching should be used. */
87+
dependencyCachingEnabled: CachingKind;
88+
89+
/** The keys of caches that we restored, if any. */
90+
dependencyCachingRestoredKeys: string[];
91+
92+
/**
93+
* Extra query exclusions to append to the config.
94+
*/
95+
extraQueryExclusions: ExcludeQueryFilter[];
96+
97+
/**
98+
* The overlay database mode to use.
99+
*/
100+
overlayDatabaseMode: OverlayDatabaseMode;
101+
102+
/**
103+
* Whether to use caching for overlay databases. If it is true, the action
104+
* will upload the created overlay-base database to the actions cache, and
105+
* download an overlay-base database from the actions cache before it creates
106+
* a new overlay database. If it is false, the action assumes that the
107+
* workflow will be responsible for managing database storage and retrieval.
108+
*
109+
* This property has no effect unless `overlayDatabaseMode` is `Overlay` or
110+
* `OverlayBase`.
111+
*/
112+
useOverlayDatabaseCaching: boolean;
113+
114+
/**
115+
* Whether the overlay database mode was set explicitly.
116+
*/
117+
overlayModeSetExplicitly: boolean;
118+
119+
/**
120+
* A partial mapping from repository properties that affect us to their values.
121+
*/
122+
repositoryProperties: RepositoryProperties;
123+
124+
/**
125+
* Whether to enable file coverage information.
126+
*/
127+
enableFileCoverageInformation: boolean;
128+
}

0 commit comments

Comments
 (0)