Skip to content

Commit d674a2f

Browse files
committed
init-action: check packs for overlay compatibility
1 parent cc993d6 commit d674a2f

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,
@@ -733,6 +734,36 @@ async function run() {
733734
logger,
734735
);
735736

737+
// To check custom query packs for compatibility with overlay analysis, we
738+
// need to first initialize the database cluster, which downloads the
739+
// user-specified custom query packs. But we also want to check custom query
740+
// pack compatibility first, because database cluster initialization depends
741+
// on the overlay database mode. The solution is to initialize the database
742+
// cluster first, check custom query pack compatibility, and if we need to
743+
// revert to `OverlayDatabaseMode.None`, re-initialize the database cluster
744+
// with the new overlay database mode.
745+
if (
746+
config.augmentationProperties.overlayDatabaseMode !==
747+
OverlayDatabaseMode.None &&
748+
!(await checkPacksForOverlayCompatibility(codeql, config, logger))
749+
) {
750+
logger.info(
751+
"Reverting overlay database mode to None due to incompatible packs.",
752+
);
753+
config.augmentationProperties.overlayDatabaseMode =
754+
OverlayDatabaseMode.None;
755+
cleanupDatabaseClusterDirectory(config, logger);
756+
await runDatabaseInitCluster(
757+
databaseInitEnvironment,
758+
codeql,
759+
config,
760+
sourceRoot,
761+
"Runner.Worker.exe",
762+
qlconfigFile,
763+
logger,
764+
);
765+
}
766+
736767
const tracerConfig = await getCombinedTracerConfig(codeql, config);
737768
if (tracerConfig !== undefined) {
738769
for (const [key, value] of Object.entries(tracerConfig.env)) {

0 commit comments

Comments
 (0)