Skip to content

Commit 9022c73

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

File tree

3 files changed

+50
-5
lines changed

3 files changed

+50
-5
lines changed

src/config-utils.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ function createTestInitConfigInputs(
6262
tempDir: "",
6363
codeql: {} as CodeQL,
6464
workspacePath: "",
65+
sourceRoot: "",
6566
githubVersion,
6667
apiDetails: {
6768
auth: "token",
@@ -819,6 +820,8 @@ const calculateAugmentationMacro = test.macro({
819820
rawQueriesInput,
820821
rawQualityQueriesInput,
821822
languages,
823+
"", // sourceRoot
824+
undefined, // buildMode
822825
mockLogger,
823826
);
824827
t.deepEqual(actualAugmentationProperties, expectedAugmentationProperties);
@@ -948,6 +951,8 @@ const calculateAugmentationErrorMacro = test.macro({
948951
rawQueriesInput,
949952
rawQualityQueriesInput,
950953
languages,
954+
"", // sourceRoot
955+
undefined, // buildMode
951956
mockLogger,
952957
),
953958
{ 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 {
@@ -189,6 +190,11 @@ export interface AugmentationProperties {
189190
* Extra query exclusions to append to the config.
190191
*/
191192
extraQueryExclusions?: ExcludeQueryFilter[];
193+
194+
/**
195+
* The overlay database mode to use.
196+
*/
197+
overlayDatabaseMode: OverlayDatabaseMode;
192198
}
193199

194200
/**
@@ -202,6 +208,7 @@ export const defaultAugmentationProperties: AugmentationProperties = {
202208
queriesInput: undefined,
203209
qualityQueriesInput: undefined,
204210
extraQueryExclusions: [],
211+
overlayDatabaseMode: OverlayDatabaseMode.None,
205212
};
206213
export type Packs = Partial<Record<Language, string[]>>;
207214

@@ -426,6 +433,7 @@ export interface InitConfigInputs {
426433
tempDir: string;
427434
codeql: CodeQL;
428435
workspacePath: string;
436+
sourceRoot: string;
429437
githubVersion: GitHubVersion;
430438
apiDetails: api.GitHubApiCombinedDetails;
431439
features: FeatureEnablement;
@@ -459,6 +467,7 @@ export async function getDefaultConfig({
459467
repository,
460468
tempDir,
461469
codeql,
470+
sourceRoot,
462471
githubVersion,
463472
features,
464473
logger,
@@ -484,6 +493,8 @@ export async function getDefaultConfig({
484493
queriesInput,
485494
qualityQueriesInput,
486495
languages,
496+
sourceRoot,
497+
buildMode,
487498
logger,
488499
);
489500

@@ -551,6 +562,7 @@ async function loadConfig({
551562
tempDir,
552563
codeql,
553564
workspacePath,
565+
sourceRoot,
554566
githubVersion,
555567
apiDetails,
556568
features,
@@ -595,6 +607,8 @@ async function loadConfig({
595607
queriesInput,
596608
qualityQueriesInput,
597609
languages,
610+
sourceRoot,
611+
buildMode,
598612
logger,
599613
);
600614

@@ -637,6 +651,8 @@ async function loadConfig({
637651
* @param languages The languages that the config file is for. If the packs input
638652
* is non-empty, then there must be exactly one language. Otherwise, an
639653
* error is thrown.
654+
* @param sourceRoot The source root of the repository.
655+
* @param buildMode The build mode to use.
640656
* @param logger The logger to use for logging.
641657
*
642658
* @returns The properties that need to be augmented in the config file.
@@ -652,6 +668,8 @@ export async function calculateAugmentation(
652668
rawQueriesInput: string | undefined,
653669
rawQualityQueriesInput: string | undefined,
654670
languages: Language[],
671+
sourceRoot: string,
672+
buildMode: BuildMode | undefined,
655673
logger: Logger,
656674
): Promise<AugmentationProperties> {
657675
const packsInputCombines = shouldCombine(rawPacksInput);
@@ -665,6 +683,13 @@ export async function calculateAugmentation(
665683
rawQueriesInput,
666684
queriesInputCombines,
667685
);
686+
const overlayDatabaseMode = await getOverlayDatabaseMode(
687+
codeql,
688+
features,
689+
sourceRoot,
690+
buildMode,
691+
logger,
692+
);
668693

669694
const qualityQueriesInput = parseQueriesFromInput(
670695
rawQualityQueriesInput,
@@ -685,6 +710,7 @@ export async function calculateAugmentation(
685710
queriesInputCombines,
686711
qualityQueriesInput,
687712
extraQueryExclusions,
713+
overlayDatabaseMode,
688714
};
689715
}
690716

@@ -711,6 +737,16 @@ function parseQueriesFromInput(
711737
return trimmedInput.split(",").map((query) => ({ uses: query.trim() }));
712738
}
713739

740+
async function getOverlayDatabaseMode(
741+
codeql: CodeQL,
742+
features: FeatureEnablement,
743+
sourceRoot: string,
744+
buildMode: BuildMode | undefined,
745+
logger: Logger,
746+
): Promise<OverlayDatabaseMode> {
747+
return OverlayDatabaseMode.None;
748+
}
749+
714750
/**
715751
* Pack names must be in the form of `scope/name`, with only alpha-numeric characters,
716752
* and `-` allowed as long as not the first or last char.

src/init-action.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,14 @@ async function run() {
297297

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

300+
// path.resolve() respects the intended semantics of source-root. If
301+
// source-root is relative, it is relative to the GITHUB_WORKSPACE. If
302+
// source-root is absolute, it is used as given.
303+
const sourceRoot = path.resolve(
304+
getRequiredEnvParam("GITHUB_WORKSPACE"),
305+
getOptionalInput("source-root") || "",
306+
);
307+
300308
try {
301309
const statusReportBase = await createStatusReportBase(
302310
ActionName.Init,
@@ -363,6 +371,7 @@ async function run() {
363371
tempDir: getTemporaryDirectory(),
364372
codeql,
365373
workspacePath: getRequiredEnvParam("GITHUB_WORKSPACE"),
374+
sourceRoot,
366375
githubVersion: gitHubVersion,
367376
apiDetails,
368377
features,
@@ -390,11 +399,6 @@ async function run() {
390399
}
391400

392401
try {
393-
const sourceRoot = path.resolve(
394-
getRequiredEnvParam("GITHUB_WORKSPACE"),
395-
getOptionalInput("source-root") || "",
396-
);
397-
398402
const overlayDatabaseMode = await getOverlayDatabaseMode(
399403
(await codeql.getVersion()).version,
400404
config,

0 commit comments

Comments
 (0)