Skip to content

Commit 4d7cdc5

Browse files
committed
init-action: check packs for overlay compatibility
1 parent 1992b8e commit 4d7cdc5

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

src/init-action.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import { EnvVar } from "./environment";
3535
import { Feature, featureConfig, Features } from "./feature-flags";
3636
import {
3737
checkInstallPython311,
38+
checkPacksForOverlayCompatibility,
3839
cleanupDatabaseClusterDirectory,
3940
initCodeQL,
4041
initConfig,
@@ -766,6 +767,36 @@ async function run() {
766767
logger,
767768
);
768769

770+
// To check custom query packs for compatibility with overlay analysis, we
771+
// need to first initialize the database cluster, which downloads the
772+
// user-specified custom query packs. But we also want to check custom query
773+
// pack compatibility first, because database cluster initialization depends
774+
// on the overlay database mode. The solution is to initialize the database
775+
// cluster first, check custom query pack compatibility, and if we need to
776+
// revert to `OverlayDatabaseMode.None`, re-initialize the database cluster
777+
// with the new overlay database mode.
778+
if (
779+
config.augmentationProperties.overlayDatabaseMode !==
780+
OverlayDatabaseMode.None &&
781+
!(await checkPacksForOverlayCompatibility(codeql, config, logger))
782+
) {
783+
logger.info(
784+
"Reverting overlay database mode to None due to incompatible packs.",
785+
);
786+
config.augmentationProperties.overlayDatabaseMode =
787+
OverlayDatabaseMode.None;
788+
cleanupDatabaseClusterDirectory(config, logger);
789+
await runDatabaseInitCluster(
790+
databaseInitEnvironment,
791+
codeql,
792+
config,
793+
sourceRoot,
794+
"Runner.Worker.exe",
795+
qlconfigFile,
796+
logger,
797+
);
798+
}
799+
769800
const tracerConfig = await getCombinedTracerConfig(codeql, config);
770801
if (tracerConfig !== undefined) {
771802
for (const [key, value] of Object.entries(tracerConfig.env)) {

0 commit comments

Comments
 (0)