Skip to content

Commit 71ab101

Browse files
committed
Set default query filter for diff-informed analysis
1 parent da967b1 commit 71ab101

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

src/config-utils.test.ts

+6
Original file line numberDiff line numberDiff line change
@@ -811,9 +811,12 @@ const calculateAugmentationMacro = test.macro({
811811
) => {
812812
const actualAugmentationProperties =
813813
await configUtils.calculateAugmentation(
814+
getCachedCodeQL(),
815+
createFeatures([]),
814816
rawPacksInput,
815817
rawQueriesInput,
816818
languages,
819+
mockLogger,
817820
);
818821
t.deepEqual(actualAugmentationProperties, expectedAugmentationProperties);
819822
},
@@ -907,9 +910,12 @@ const calculateAugmentationErrorMacro = test.macro({
907910
await t.throwsAsync(
908911
() =>
909912
configUtils.calculateAugmentation(
913+
getCachedCodeQL(),
914+
createFeatures([]),
910915
rawPacksInput,
911916
rawQueriesInput,
912917
languages,
918+
mockLogger,
913919
),
914920
{ message: expectedError },
915921
);

src/config-utils.ts

+16
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import * as semver from "semver";
88
import * as api from "./api-client";
99
import { CachingKind, getCachingKind } from "./caching-utils";
1010
import { CodeQL } from "./codeql";
11+
import { shouldPerformDiffInformedAnalysis } from "./diff-informed-analysis-utils";
1112
import { Feature, FeatureEnablement } from "./feature-flags";
1213
import { Language, parseLanguage } from "./languages";
1314
import { Logger } from "./logging";
@@ -469,9 +470,12 @@ export async function getDefaultConfig({
469470
);
470471

471472
const augmentationProperties = await calculateAugmentation(
473+
codeql,
474+
features,
472475
packsInput,
473476
queriesInput,
474477
languages,
478+
logger,
475479
);
476480

477481
const { trapCaches, trapCacheDownloadTime } = await downloadCacheWithTime(
@@ -575,9 +579,12 @@ async function loadConfig({
575579
);
576580

577581
const augmentationProperties = await calculateAugmentation(
582+
codeql,
583+
features,
578584
packsInput,
579585
queriesInput,
580586
languages,
587+
logger,
581588
);
582589

583590
const { trapCaches, trapCacheDownloadTime } = await downloadCacheWithTime(
@@ -612,11 +619,14 @@ async function loadConfig({
612619
* and the CLI does not know about these inputs so we need to inject them into
613620
* the config file sent to the CLI.
614621
*
622+
* @param codeql The CodeQL object.
623+
* @param features The feature enablement object.
615624
* @param rawPacksInput The packs input from the action configuration.
616625
* @param rawQueriesInput The queries input from the action configuration.
617626
* @param languages The languages that the config file is for. If the packs input
618627
* is non-empty, then there must be exactly one language. Otherwise, an
619628
* error is thrown.
629+
* @param logger The logger to use for logging.
620630
*
621631
* @returns The properties that need to be augmented in the config file.
622632
*
@@ -625,9 +635,12 @@ async function loadConfig({
625635
*/
626636
// exported for testing.
627637
export async function calculateAugmentation(
638+
codeql: CodeQL,
639+
features: FeatureEnablement,
628640
rawPacksInput: string | undefined,
629641
rawQueriesInput: string | undefined,
630642
languages: Language[],
643+
logger: Logger,
631644
): Promise<AugmentationProperties> {
632645
const packsInputCombines = shouldCombine(rawPacksInput);
633646
const packsInput = parsePacksFromInput(
@@ -642,6 +655,9 @@ export async function calculateAugmentation(
642655
);
643656

644657
const defaultQueryFilters: QueryFilter[] = [];
658+
if (await shouldPerformDiffInformedAnalysis(codeql, features, logger)) {
659+
defaultQueryFilters.push({ exclude: { tags: "exclude-from-incremental" } });
660+
}
645661

646662
return {
647663
packsInputCombines,

0 commit comments

Comments
 (0)