Set default query filter for diff-informed analysis
This commit is contained in:
parent
da967b1ade
commit
71ab101d38
2 changed files with 22 additions and 0 deletions
|
|
@ -811,9 +811,12 @@ const calculateAugmentationMacro = test.macro({
|
||||||
) => {
|
) => {
|
||||||
const actualAugmentationProperties =
|
const actualAugmentationProperties =
|
||||||
await configUtils.calculateAugmentation(
|
await configUtils.calculateAugmentation(
|
||||||
|
getCachedCodeQL(),
|
||||||
|
createFeatures([]),
|
||||||
rawPacksInput,
|
rawPacksInput,
|
||||||
rawQueriesInput,
|
rawQueriesInput,
|
||||||
languages,
|
languages,
|
||||||
|
mockLogger,
|
||||||
);
|
);
|
||||||
t.deepEqual(actualAugmentationProperties, expectedAugmentationProperties);
|
t.deepEqual(actualAugmentationProperties, expectedAugmentationProperties);
|
||||||
},
|
},
|
||||||
|
|
@ -907,9 +910,12 @@ const calculateAugmentationErrorMacro = test.macro({
|
||||||
await t.throwsAsync(
|
await t.throwsAsync(
|
||||||
() =>
|
() =>
|
||||||
configUtils.calculateAugmentation(
|
configUtils.calculateAugmentation(
|
||||||
|
getCachedCodeQL(),
|
||||||
|
createFeatures([]),
|
||||||
rawPacksInput,
|
rawPacksInput,
|
||||||
rawQueriesInput,
|
rawQueriesInput,
|
||||||
languages,
|
languages,
|
||||||
|
mockLogger,
|
||||||
),
|
),
|
||||||
{ message: expectedError },
|
{ message: expectedError },
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ import * as semver from "semver";
|
||||||
import * as api from "./api-client";
|
import * as api from "./api-client";
|
||||||
import { CachingKind, getCachingKind } from "./caching-utils";
|
import { CachingKind, getCachingKind } from "./caching-utils";
|
||||||
import { CodeQL } from "./codeql";
|
import { CodeQL } from "./codeql";
|
||||||
|
import { shouldPerformDiffInformedAnalysis } from "./diff-informed-analysis-utils";
|
||||||
import { Feature, FeatureEnablement } from "./feature-flags";
|
import { Feature, FeatureEnablement } from "./feature-flags";
|
||||||
import { Language, parseLanguage } from "./languages";
|
import { Language, parseLanguage } from "./languages";
|
||||||
import { Logger } from "./logging";
|
import { Logger } from "./logging";
|
||||||
|
|
@ -469,9 +470,12 @@ export async function getDefaultConfig({
|
||||||
);
|
);
|
||||||
|
|
||||||
const augmentationProperties = await calculateAugmentation(
|
const augmentationProperties = await calculateAugmentation(
|
||||||
|
codeql,
|
||||||
|
features,
|
||||||
packsInput,
|
packsInput,
|
||||||
queriesInput,
|
queriesInput,
|
||||||
languages,
|
languages,
|
||||||
|
logger,
|
||||||
);
|
);
|
||||||
|
|
||||||
const { trapCaches, trapCacheDownloadTime } = await downloadCacheWithTime(
|
const { trapCaches, trapCacheDownloadTime } = await downloadCacheWithTime(
|
||||||
|
|
@ -575,9 +579,12 @@ async function loadConfig({
|
||||||
);
|
);
|
||||||
|
|
||||||
const augmentationProperties = await calculateAugmentation(
|
const augmentationProperties = await calculateAugmentation(
|
||||||
|
codeql,
|
||||||
|
features,
|
||||||
packsInput,
|
packsInput,
|
||||||
queriesInput,
|
queriesInput,
|
||||||
languages,
|
languages,
|
||||||
|
logger,
|
||||||
);
|
);
|
||||||
|
|
||||||
const { trapCaches, trapCacheDownloadTime } = await downloadCacheWithTime(
|
const { trapCaches, trapCacheDownloadTime } = await downloadCacheWithTime(
|
||||||
|
|
@ -612,11 +619,14 @@ async function loadConfig({
|
||||||
* and the CLI does not know about these inputs so we need to inject them into
|
* and the CLI does not know about these inputs so we need to inject them into
|
||||||
* the config file sent to the CLI.
|
* 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 rawPacksInput The packs input from the action configuration.
|
||||||
* @param rawQueriesInput The queries 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
|
* @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
|
* is non-empty, then there must be exactly one language. Otherwise, an
|
||||||
* error is thrown.
|
* error is thrown.
|
||||||
|
* @param logger The logger to use for logging.
|
||||||
*
|
*
|
||||||
* @returns The properties that need to be augmented in the config file.
|
* @returns The properties that need to be augmented in the config file.
|
||||||
*
|
*
|
||||||
|
|
@ -625,9 +635,12 @@ async function loadConfig({
|
||||||
*/
|
*/
|
||||||
// exported for testing.
|
// exported for testing.
|
||||||
export async function calculateAugmentation(
|
export async function calculateAugmentation(
|
||||||
|
codeql: CodeQL,
|
||||||
|
features: FeatureEnablement,
|
||||||
rawPacksInput: string | undefined,
|
rawPacksInput: string | undefined,
|
||||||
rawQueriesInput: string | undefined,
|
rawQueriesInput: string | undefined,
|
||||||
languages: Language[],
|
languages: Language[],
|
||||||
|
logger: Logger,
|
||||||
): Promise<AugmentationProperties> {
|
): Promise<AugmentationProperties> {
|
||||||
const packsInputCombines = shouldCombine(rawPacksInput);
|
const packsInputCombines = shouldCombine(rawPacksInput);
|
||||||
const packsInput = parsePacksFromInput(
|
const packsInput = parsePacksFromInput(
|
||||||
|
|
@ -642,6 +655,9 @@ export async function calculateAugmentation(
|
||||||
);
|
);
|
||||||
|
|
||||||
const defaultQueryFilters: QueryFilter[] = [];
|
const defaultQueryFilters: QueryFilter[] = [];
|
||||||
|
if (await shouldPerformDiffInformedAnalysis(codeql, features, logger)) {
|
||||||
|
defaultQueryFilters.push({ exclude: { tags: "exclude-from-incremental" } });
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
packsInputCombines,
|
packsInputCombines,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue