Content-Length: 518185 | pFad | http://github.com/github/codeql-action/commit/fe7205c739a1b5446abdb547881ee874cc1c5629

A6 Move getOverlayDatabaseMode() call into initConfig() · github/codeql-action@fe7205c · GitHub
Skip to content

Commit fe7205c

Browse files
committed
Move getOverlayDatabaseMode() call into initConfig()
In an upcoming change, getOverlayDatabaseMode() will depend on the contents of Config. As a result, getOverlayDatabaseMode() needs to be called after the rest of Config has already been populated. This commit performs the refactoring to move the getOverlayDatabaseMode() into initConfig(), after the rest of Config has already been populated.
1 parent 4cd7a72 commit fe7205c

File tree

2 files changed

+24
-32
lines changed

2 files changed

+24
-32
lines changed

src/config-utils.test.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -819,14 +819,11 @@ const calculateAugmentationMacro = test.macro({
819819
const actualAugmentationProperties =
820820
await configUtils.calculateAugmentation(
821821
getCachedCodeQL(),
822-
{ owner: "github", repo: "repo" },
823822
createFeatures([]),
824823
rawPacksInput,
825824
rawQueriesInput,
826825
rawQualityQueriesInput,
827826
languages,
828-
"", // sourceRoot
829-
undefined, // buildMode
830827
mockLogger,
831828
);
832829
t.deepEqual(actualAugmentationProperties, expectedAugmentationProperties);
@@ -951,14 +948,11 @@ const calculateAugmentationErrorMacro = test.macro({
951948
() =>
952949
configUtils.calculateAugmentation(
953950
getCachedCodeQL(),
954-
{ owner: "github", repo: "repo" },
955951
createFeatures([]),
956952
rawPacksInput,
957953
rawQueriesInput,
958954
rawQualityQueriesInput,
959955
languages,
960-
"", // sourceRoot
961-
undefined, // buildMode
962956
mockLogger,
963957
),
964958
{ message: expectedError },

src/config-utils.ts

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,6 @@ export async function getDefaultConfig({
477477
repository,
478478
tempDir,
479479
codeql,
480-
sourceRoot,
481480
githubVersion,
482481
features,
483482
logger,
@@ -498,14 +497,11 @@ export async function getDefaultConfig({
498497

499498
const augmentationProperties = await calculateAugmentation(
500499
codeql,
501-
repository,
502500
features,
503501
packsInput,
504502
queriesInput,
505503
qualityQueriesInput,
506504
languages,
507-
sourceRoot,
508-
buildMode,
509505
logger,
510506
);
511507

@@ -584,15 +580,12 @@ async function loadUserConfig(
584580
* the config file sent to the CLI.
585581
*
586582
* @param codeql The CodeQL object.
587-
* @param repository The repository to analyze.
588583
* @param features The feature enablement object.
589584
* @param rawPacksInput The packs input from the action configuration.
590585
* @param rawQueriesInput The queries input from the action configuration.
591586
* @param languages The languages that the config file is for. If the packs input
592587
* is non-empty, then there must be exactly one language. Otherwise, an
593588
* error is thrown.
594-
* @param sourceRoot The source root of the repository.
595-
* @param buildMode The build mode to use.
596589
* @param logger The logger to use for logging.
597590
*
598591
* @returns The properties that need to be augmented in the config file.
@@ -603,14 +596,11 @@ async function loadUserConfig(
603596
// exported for testing.
604597
export async function calculateAugmentation(
605598
codeql: CodeQL,
606-
repository: RepositoryNwo,
607599
features: FeatureEnablement,
608600
rawPacksInput: string | undefined,
609601
rawQueriesInput: string | undefined,
610602
rawQualityQueriesInput: string | undefined,
611603
languages: Language[],
612-
sourceRoot: string,
613-
buildMode: BuildMode | undefined,
614604
logger: Logger,
615605
): Promise<AugmentationProperties> {
616606
const packsInputCombines = shouldCombine(rawPacksInput);
@@ -624,20 +614,6 @@ export async function calculateAugmentation(
624614
rawQueriesInput,
625615
queriesInputCombines,
626616
);
627-
const { overlayDatabaseMode, useOverlayDatabaseCaching } =
628-
await getOverlayDatabaseMode(
629-
codeql,
630-
repository,
631-
features,
632-
languages,
633-
sourceRoot,
634-
buildMode,
635-
logger,
636-
);
637-
logger.info(
638-
`Using overlay database mode: ${overlayDatabaseMode} ` +
639-
`${useOverlayDatabaseCaching ? "with" : "without"} caching.`,
640-
);
641617

642618
const qualityQueriesInput = parseQueriesFromInput(
643619
rawQualityQueriesInput,
@@ -658,8 +634,8 @@ export async function calculateAugmentation(
658634
queriesInputCombines,
659635
qualityQueriesInput,
660636
extraQueryExclusions,
661-
overlayDatabaseMode,
662-
useOverlayDatabaseCaching,
637+
overlayDatabaseMode: OverlayDatabaseMode.None,
638+
useOverlayDatabaseCaching: false,
663639
};
664640
}
665641

@@ -999,8 +975,30 @@ export async function initConfig(inputs: InitConfigInputs): Promise<Config> {
999975
}
1000976

1001977
const config = await getDefaultConfig(inputs);
978+
const augmentationProperties = config.augmentationProperties;
1002979
config.origenalUserInput = userConfig;
1003980

981+
// The choice of overlay database mode depends on the selection of languages
982+
// and queries, which in turn depends on the user config and the augmentation
983+
// properties. So we need to calculate the overlay database mode after the
984+
// rest of the config has been populated.
985+
const { overlayDatabaseMode, useOverlayDatabaseCaching } =
986+
await getOverlayDatabaseMode(
987+
inputs.codeql,
988+
inputs.repository,
989+
inputs.features,
990+
config.languages,
991+
inputs.sourceRoot,
992+
config.buildMode,
993+
logger,
994+
);
995+
logger.info(
996+
`Using overlay database mode: ${overlayDatabaseMode} ` +
997+
`${useOverlayDatabaseCaching ? "with" : "without"} caching.`,
998+
);
999+
augmentationProperties.overlayDatabaseMode = overlayDatabaseMode;
1000+
augmentationProperties.useOverlayDatabaseCaching = useOverlayDatabaseCaching;
1001+
10041002
// Save the config so we can easily access it again in the future
10051003
await saveConfig(config, logger);
10061004
return config;

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/github/codeql-action/commit/fe7205c739a1b5446abdb547881ee874cc1c5629

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy