Skip to content

Commit de47bf1

Browse files
committed
databaseInitCluster: use overlayDatabaseMode from config
This commit changes databaseInitCluster() to use overlayDatabaseMode from AugmentationProperties instead of the overlayDatabaseMode parameter. There is no behavior change because both overlayDatabaseMode values are computed the same way. The commit then cleans up the overlayDatabaseMode parameter and the code paths that feed into it.
1 parent 21d41e1 commit de47bf1

File tree

5 files changed

+7
-67
lines changed

5 files changed

+7
-67
lines changed

src/codeql.test.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import { DocUrl } from "./doc-url";
2424
import { FeatureEnablement } from "./feature-flags";
2525
import { Language } from "./languages";
2626
import { getRunnerLogger } from "./logging";
27-
import { OverlayDatabaseMode } from "./overlay-database-utils";
2827
import { ToolsSource } from "./setup-codeql";
2928
import {
3029
setupTests,
@@ -515,7 +514,6 @@ const injectedConfigMacro = test.macro({
515514
"",
516515
undefined,
517516
undefined,
518-
OverlayDatabaseMode.None,
519517
getRunnerLogger(true),
520518
);
521519

@@ -726,7 +724,6 @@ test("passes a code scanning config AND qlconfig to the CLI", async (t: Executio
726724
"",
727725
undefined,
728726
"/path/to/qlconfig.yml",
729-
OverlayDatabaseMode.None,
730727
getRunnerLogger(true),
731728
);
732729

@@ -756,7 +753,6 @@ test("does not pass a qlconfig to the CLI when it is undefined", async (t: Execu
756753
"",
757754
undefined,
758755
undefined, // undefined qlconfigFile
759-
OverlayDatabaseMode.None,
760756
getRunnerLogger(true),
761757
);
762758

@@ -1010,7 +1006,6 @@ test("Avoids duplicating --overwrite flag if specified in CODEQL_ACTION_EXTRA_OP
10101006
"sourceRoot",
10111007
undefined,
10121008
undefined,
1013-
OverlayDatabaseMode.None,
10141009
getRunnerLogger(false),
10151010
);
10161011

src/codeql.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ export interface CodeQL {
8787
sourceRoot: string,
8888
processName: string | undefined,
8989
qlconfigFile: string | undefined,
90-
overlayDatabaseMode: OverlayDatabaseMode,
9190
logger: Logger,
9291
): Promise<void>;
9392
/**
@@ -558,7 +557,6 @@ export async function getCodeQLForCmd(
558557
sourceRoot: string,
559558
processName: string | undefined,
560559
qlconfigFile: string | undefined,
561-
overlayDatabaseMode: OverlayDatabaseMode,
562560
logger: Logger,
563561
) {
564562
const extraArgs = config.languages.map(
@@ -596,6 +594,8 @@ export async function getCodeQLForCmd(
596594
? "--force-overwrite"
597595
: "--overwrite";
598596

597+
const overlayDatabaseMode =
598+
config.augmentationProperties.overlayDatabaseMode;
599599
if (overlayDatabaseMode === OverlayDatabaseMode.Overlay) {
600600
const overlayChangesFile = await writeOverlayChangesFile(
601601
config,

src/config-utils.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,7 @@ export async function calculateAugmentation(
695695
buildMode,
696696
logger,
697697
);
698+
logger.info(`Using overlay database mode: ${overlayDatabaseMode}`);
698699

699700
const qualityQueriesInput = parseQueriesFromInput(
700701
rawQualityQueriesInput,

src/init-action.ts

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ import { Feature, featureConfig, Features } from "./feature-flags";
3636
import {
3737
checkInstallPython311,
3838
cleanupDatabaseClusterDirectory,
39-
getOverlayDatabaseMode,
4039
initCodeQL,
4140
initConfig,
4241
runInit,
@@ -396,15 +395,10 @@ async function run() {
396395
}
397396

398397
try {
399-
const overlayDatabaseMode = await getOverlayDatabaseMode(
400-
(await codeql.getVersion()).version,
401-
config,
402-
sourceRoot,
403-
logger,
404-
);
405-
logger.info(`Using overlay database mode: ${overlayDatabaseMode}`);
406-
407-
if (overlayDatabaseMode !== OverlayDatabaseMode.Overlay) {
398+
if (
399+
config.augmentationProperties.overlayDatabaseMode !==
400+
OverlayDatabaseMode.Overlay
401+
) {
408402
cleanupDatabaseClusterDirectory(config, logger);
409403
}
410404

@@ -676,7 +670,6 @@ async function run() {
676670
"Runner.Worker.exe",
677671
getOptionalInput("registries"),
678672
apiDetails,
679-
overlayDatabaseMode,
680673
logger,
681674
);
682675
if (tracerConfig !== undefined) {

src/init.ts

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,14 @@ import * as path from "path";
33

44
import * as toolrunner from "@actions/exec/lib/toolrunner";
55
import * as io from "@actions/io";
6-
import * as semver from "semver";
76

87
import { getOptionalInput, isSelfHostedRunner } from "./actions-util";
98
import { GitHubApiCombinedDetails, GitHubApiDetails } from "./api-client";
109
import { CodeQL, setupCodeQL } from "./codeql";
1110
import * as configUtils from "./config-utils";
1211
import { CodeQLDefaultVersionInfo, FeatureEnablement } from "./feature-flags";
13-
import { getGitRoot } from "./git-utils";
1412
import { Language } from "./languages";
1513
import { Logger, withGroupAsync } from "./logging";
16-
import {
17-
CODEQL_OVERLAY_MINIMUM_VERSION,
18-
OverlayDatabaseMode,
19-
} from "./overlay-database-utils";
2014
import { ToolsSource } from "./setup-codeql";
2115
import { ZstdAvailability } from "./tar";
2216
import { ToolsDownloadStatusReport } from "./tools-download";
@@ -74,55 +68,13 @@ export async function initConfig(
7468
});
7569
}
7670

77-
export async function getOverlayDatabaseMode(
78-
codeqlVersion: string,
79-
config: configUtils.Config,
80-
sourceRoot: string,
81-
logger: Logger,
82-
): Promise<OverlayDatabaseMode> {
83-
const overlayDatabaseMode = process.env.CODEQL_OVERLAY_DATABASE_MODE;
84-
85-
if (
86-
overlayDatabaseMode === OverlayDatabaseMode.Overlay ||
87-
overlayDatabaseMode === OverlayDatabaseMode.OverlayBase
88-
) {
89-
if (config.buildMode !== util.BuildMode.None) {
90-
logger.warning(
91-
`Cannot build an ${overlayDatabaseMode} database because ` +
92-
`build-mode is set to "${config.buildMode}" instead of "none". ` +
93-
"Falling back to creating a normal full database instead.",
94-
);
95-
return OverlayDatabaseMode.None;
96-
}
97-
if (semver.lt(codeqlVersion, CODEQL_OVERLAY_MINIMUM_VERSION)) {
98-
logger.warning(
99-
`Cannot build an ${overlayDatabaseMode} database because ` +
100-
`the CodeQL CLI is older than ${CODEQL_OVERLAY_MINIMUM_VERSION}. ` +
101-
"Falling back to creating a normal full database instead.",
102-
);
103-
return OverlayDatabaseMode.None;
104-
}
105-
if ((await getGitRoot(sourceRoot)) === undefined) {
106-
logger.warning(
107-
`Cannot build an ${overlayDatabaseMode} database because ` +
108-
`the source root "${sourceRoot}" is not inside a git repository. ` +
109-
"Falling back to creating a normal full database instead.",
110-
);
111-
return OverlayDatabaseMode.None;
112-
}
113-
return overlayDatabaseMode as OverlayDatabaseMode;
114-
}
115-
return OverlayDatabaseMode.None;
116-
}
117-
11871
export async function runInit(
11972
codeql: CodeQL,
12073
config: configUtils.Config,
12174
sourceRoot: string,
12275
processName: string | undefined,
12376
registriesInput: string | undefined,
12477
apiDetails: GitHubApiCombinedDetails,
125-
overlayDatabaseMode: OverlayDatabaseMode,
12678
logger: Logger,
12779
): Promise<TracerConfig | undefined> {
12880
fs.mkdirSync(config.dbLocation, { recursive: true });
@@ -146,7 +98,6 @@ export async function runInit(
14698
sourceRoot,
14799
processName,
148100
qlconfigFile,
149-
overlayDatabaseMode,
150101
logger,
151102
),
152103
);

0 commit comments

Comments
 (0)