Skip to content

Commit 7707e09

Browse files
committed
Add overlayDatabaseMode to AugmentationProperties
This commit adds overlayDatabaseMode to AugmentationProperties and creates a placeholder getOverlayDatabaseMode() function, with the necessary inputs, to populate it.
1 parent 9b0bb13 commit 7707e09

File tree

3 files changed

+47
-5
lines changed

3 files changed

+47
-5
lines changed

src/config-utils.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ function createTestInitConfigInputs(
6161
tempDir: "",
6262
codeql: {} as CodeQL,
6363
workspacePath: "",
64+
sourceRoot: "",
6465
githubVersion,
6566
apiDetails: {
6667
auth: "token",
@@ -816,6 +817,8 @@ const calculateAugmentationMacro = test.macro({
816817
rawPacksInput,
817818
rawQueriesInput,
818819
languages,
820+
"", // sourceRoot
821+
undefined, // buildMode
819822
mockLogger,
820823
);
821824
t.deepEqual(actualAugmentationProperties, expectedAugmentationProperties);
@@ -901,6 +904,8 @@ const calculateAugmentationErrorMacro = test.macro({
901904
rawPacksInput,
902905
rawQueriesInput,
903906
languages,
907+
"", // sourceRoot
908+
undefined, // buildMode
904909
mockLogger,
905910
),
906911
{ message: expectedError },

src/config-utils.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { shouldPerformDiffInformedAnalysis } from "./diff-informed-analysis-util
1212
import { Feature, FeatureEnablement } from "./feature-flags";
1313
import { Language, parseLanguage } from "./languages";
1414
import { Logger } from "./logging";
15+
import { OverlayDatabaseMode } from "./overlay-database-utils";
1516
import { RepositoryNwo } from "./repository";
1617
import { downloadTrapCaches } from "./trap-caching";
1718
import {
@@ -184,6 +185,11 @@ export interface AugmentationProperties {
184185
* Default query filters to apply to the queries in the config.
185186
*/
186187
defaultQueryFilters?: QueryFilter[];
188+
189+
/**
190+
* The overlay database mode to use.
191+
*/
192+
overlayDatabaseMode: OverlayDatabaseMode;
187193
}
188194

189195
/**
@@ -196,6 +202,7 @@ export const defaultAugmentationProperties: AugmentationProperties = {
196202
packsInput: undefined,
197203
queriesInput: undefined,
198204
defaultQueryFilters: [],
205+
overlayDatabaseMode: OverlayDatabaseMode.None,
199206
};
200207
export type Packs = Partial<Record<Language, string[]>>;
201208

@@ -419,6 +426,7 @@ export interface InitConfigInputs {
419426
tempDir: string;
420427
codeql: CodeQL;
421428
workspacePath: string;
429+
sourceRoot: string;
422430
githubVersion: GitHubVersion;
423431
apiDetails: api.GitHubApiCombinedDetails;
424432
features: FeatureEnablement;
@@ -451,6 +459,7 @@ export async function getDefaultConfig({
451459
repository,
452460
tempDir,
453461
codeql,
462+
sourceRoot,
454463
githubVersion,
455464
features,
456465
logger,
@@ -475,6 +484,8 @@ export async function getDefaultConfig({
475484
packsInput,
476485
queriesInput,
477486
languages,
487+
sourceRoot,
488+
buildMode,
478489
logger,
479490
);
480491

@@ -541,6 +552,7 @@ async function loadConfig({
541552
tempDir,
542553
codeql,
543554
workspacePath,
555+
sourceRoot,
544556
githubVersion,
545557
apiDetails,
546558
features,
@@ -584,6 +596,8 @@ async function loadConfig({
584596
packsInput,
585597
queriesInput,
586598
languages,
599+
sourceRoot,
600+
buildMode,
587601
logger,
588602
);
589603

@@ -626,6 +640,8 @@ async function loadConfig({
626640
* @param languages The languages that the config file is for. If the packs input
627641
* is non-empty, then there must be exactly one language. Otherwise, an
628642
* error is thrown.
643+
* @param sourceRoot The source root of the repository.
644+
* @param buildMode The build mode to use.
629645
* @param logger The logger to use for logging.
630646
*
631647
* @returns The properties that need to be augmented in the config file.
@@ -640,6 +656,8 @@ export async function calculateAugmentation(
640656
rawPacksInput: string | undefined,
641657
rawQueriesInput: string | undefined,
642658
languages: Language[],
659+
sourceRoot: string,
660+
buildMode: BuildMode | undefined,
643661
logger: Logger,
644662
): Promise<AugmentationProperties> {
645663
const packsInputCombines = shouldCombine(rawPacksInput);
@@ -653,6 +671,13 @@ export async function calculateAugmentation(
653671
rawQueriesInput,
654672
queriesInputCombines,
655673
);
674+
const overlayDatabaseMode = await getOverlayDatabaseMode(
675+
codeql,
676+
features,
677+
sourceRoot,
678+
buildMode,
679+
logger,
680+
);
656681

657682
const defaultQueryFilters: QueryFilter[] = [];
658683
if (await shouldPerformDiffInformedAnalysis(codeql, features, logger)) {
@@ -665,6 +690,7 @@ export async function calculateAugmentation(
665690
queriesInput,
666691
queriesInputCombines,
667692
defaultQueryFilters,
693+
overlayDatabaseMode,
668694
};
669695
}
670696

@@ -691,6 +717,16 @@ function parseQueriesFromInput(
691717
return trimmedInput.split(",").map((query) => ({ uses: query.trim() }));
692718
}
693719

720+
async function getOverlayDatabaseMode(
721+
codeql: CodeQL,
722+
features: FeatureEnablement,
723+
sourceRoot: string,
724+
buildMode: BuildMode | undefined,
725+
logger: Logger,
726+
): Promise<OverlayDatabaseMode> {
727+
return OverlayDatabaseMode.None;
728+
}
729+
694730
/**
695731
* Pack names must be in the form of `scope/name`, with only alpha-numeric characters,
696732
* and `-` allowed as long as not the first or last char.

src/init-action.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,11 @@ async function run() {
298298

299299
const configFile = getOptionalInput("config-file");
300300

301+
const sourceRoot = path.resolve(
302+
getRequiredEnvParam("GITHUB_WORKSPACE"),
303+
getOptionalInput("source-root") || "",
304+
);
305+
301306
try {
302307
const statusReportBase = await createStatusReportBase(
303308
ActionName.Init,
@@ -366,6 +371,7 @@ async function run() {
366371
tempDir: getTemporaryDirectory(),
367372
codeql,
368373
workspacePath: getRequiredEnvParam("GITHUB_WORKSPACE"),
374+
sourceRoot,
369375
githubVersion: gitHubVersion,
370376
apiDetails,
371377
features,
@@ -395,11 +401,6 @@ async function run() {
395401
}
396402

397403
try {
398-
const sourceRoot = path.resolve(
399-
getRequiredEnvParam("GITHUB_WORKSPACE"),
400-
getOptionalInput("source-root") || "",
401-
);
402-
403404
const overlayDatabaseMode = await getOverlayDatabaseMode(
404405
(await codeql.getVersion()).version,
405406
config,

0 commit comments

Comments
 (0)