From 64fce5856f4e93a083fa06ffbbe22c3564e86bd5 Mon Sep 17 00:00:00 2001 From: Chuan-kai Lin Date: Wed, 9 Jul 2025 14:20:02 -0700 Subject: [PATCH] Use exclude-from-incremental also for overlay analysis --- src/config-utils.test.ts | 6 ------ src/config-utils.ts | 33 +++++++++++++++------------------ src/testing-utils.ts | 1 + 3 files changed, 16 insertions(+), 24 deletions(-) diff --git a/src/config-utils.test.ts b/src/config-utils.test.ts index 269c26427..75b32410c 100644 --- a/src/config-utils.test.ts +++ b/src/config-utils.test.ts @@ -818,13 +818,10 @@ const calculateAugmentationMacro = test.macro({ ) => { const actualAugmentationProperties = await configUtils.calculateAugmentation( - getCachedCodeQL(), - createFeatures([]), rawPacksInput, rawQueriesInput, rawQualityQueriesInput, languages, - mockLogger, ); t.deepEqual(actualAugmentationProperties, expectedAugmentationProperties); }, @@ -947,13 +944,10 @@ const calculateAugmentationErrorMacro = test.macro({ await t.throwsAsync( () => configUtils.calculateAugmentation( - getCachedCodeQL(), - createFeatures([]), rawPacksInput, rawQueriesInput, rawQualityQueriesInput, languages, - mockLogger, ), { message: expectedError }, ); diff --git a/src/config-utils.ts b/src/config-utils.ts index be6642634..ff06b02a3 100644 --- a/src/config-utils.ts +++ b/src/config-utils.ts @@ -195,7 +195,7 @@ export interface AugmentationProperties { /** * Extra query exclusions to append to the config. */ - extraQueryExclusions?: ExcludeQueryFilter[]; + extraQueryExclusions: ExcludeQueryFilter[]; /** * The overlay database mode to use. @@ -496,13 +496,10 @@ export async function getDefaultConfig({ ); const augmentationProperties = await calculateAugmentation( - codeql, - features, packsInput, queriesInput, qualityQueriesInput, languages, - logger, ); const { trapCaches, trapCacheDownloadTime } = await downloadCacheWithTime( @@ -579,14 +576,11 @@ async function loadUserConfig( * and the CLI does not know about these inputs so we need to inject them into * the config file sent to the CLI. * - * @param codeql The CodeQL object. - * @param features The feature enablement object. * @param rawPacksInput The packs input from the action configuration. * @param rawQueriesInput The queries input from the action configuration. * @param languages The languages that the config file is for. If the packs input * is non-empty, then there must be exactly one language. Otherwise, an * error is thrown. - * @param logger The logger to use for logging. * * @returns The properties that need to be augmented in the config file. * @@ -595,13 +589,10 @@ async function loadUserConfig( */ // exported for testing. export async function calculateAugmentation( - codeql: CodeQL, - features: FeatureEnablement, rawPacksInput: string | undefined, rawQueriesInput: string | undefined, rawQualityQueriesInput: string | undefined, languages: Language[], - logger: Logger, ): Promise { const packsInputCombines = shouldCombine(rawPacksInput); const packsInput = parsePacksFromInput( @@ -620,20 +611,13 @@ export async function calculateAugmentation( false, ); - const extraQueryExclusions: ExcludeQueryFilter[] = []; - if (await shouldPerformDiffInformedAnalysis(codeql, features, logger)) { - extraQueryExclusions.push({ - exclude: { tags: "exclude-from-incremental" }, - }); - } - return { packsInputCombines, packsInput: packsInput?.[languages[0]], queriesInput, queriesInputCombines, qualityQueriesInput, - extraQueryExclusions, + extraQueryExclusions: [], overlayDatabaseMode: OverlayDatabaseMode.None, useOverlayDatabaseCaching: false, }; @@ -999,6 +983,19 @@ export async function initConfig(inputs: InitConfigInputs): Promise { augmentationProperties.overlayDatabaseMode = overlayDatabaseMode; augmentationProperties.useOverlayDatabaseCaching = useOverlayDatabaseCaching; + if ( + overlayDatabaseMode === OverlayDatabaseMode.Overlay || + (await shouldPerformDiffInformedAnalysis( + inputs.codeql, + inputs.features, + logger, + )) + ) { + augmentationProperties.extraQueryExclusions.push({ + exclude: { tags: "exclude-from-incremental" }, + }); + } + // Save the config so we can easily access it again in the future await saveConfig(config, logger); return config; diff --git a/src/testing-utils.ts b/src/testing-utils.ts index f42b0b1e7..11899cf39 100644 --- a/src/testing-utils.ts +++ b/src/testing-utils.ts @@ -335,6 +335,7 @@ export function createTestConfig(overrides: Partial): Config { augmentationProperties: { packsInputCombines: false, queriesInputCombines: false, + extraQueryExclusions: [], }, trapCaches: {}, trapCacheDownloadTime: 0,