mirror of
https://github.com/github/codeql-action.git
synced 2026-04-28 01:48:48 +00:00
Add logging to combineQueries
This commit is contained in:
@@ -496,6 +496,8 @@ const injectedConfigMacro = test.macro({
|
||||
expectedConfig: any,
|
||||
) => {
|
||||
await util.withTmpDir(async (tempDir) => {
|
||||
sinon.stub(actionsUtil, "isDefaultSetup").resolves(false);
|
||||
|
||||
const runnerConstructorStub = stubToolRunnerConstructor();
|
||||
const codeqlObject = await stubCodeql();
|
||||
|
||||
@@ -505,6 +507,7 @@ const injectedConfigMacro = test.macro({
|
||||
tempDir,
|
||||
};
|
||||
thisStubConfig.computedConfig = generateCodeScanningConfig(
|
||||
getRunnerLogger(true),
|
||||
thisStubConfig.originalUserInput,
|
||||
augmentationProperties,
|
||||
);
|
||||
|
||||
@@ -473,6 +473,7 @@ export async function initActionState(
|
||||
// Compute the full Code Scanning configuration that combines the configuration from the
|
||||
// configuration file / `config` input with other inputs, such as `queries`.
|
||||
const computedConfig = generateCodeScanningConfig(
|
||||
logger,
|
||||
userConfig,
|
||||
augmentationProperties,
|
||||
);
|
||||
|
||||
@@ -2,12 +2,14 @@ import * as path from "path";
|
||||
|
||||
import * as semver from "semver";
|
||||
|
||||
import { isDefaultSetup } from "../actions-util";
|
||||
import * as errorMessages from "../error-messages";
|
||||
import {
|
||||
RepositoryProperties,
|
||||
RepositoryPropertyName,
|
||||
} from "../feature-flags/properties";
|
||||
import { Language } from "../languages";
|
||||
import { Logger } from "../logging";
|
||||
import { cloneObject, ConfigurationError, prettyPrintPack } from "../util";
|
||||
|
||||
export interface ExcludeQueryFilter {
|
||||
@@ -364,11 +366,13 @@ function parseQueriesFromInput(
|
||||
/**
|
||||
* Combines queries from various configuration sources.
|
||||
*
|
||||
* @param logger The logger to use.
|
||||
* @param config The loaded configuration file (either `config-file` or `config` input).
|
||||
* @param augmentationProperties Additional configuration data from other sources.
|
||||
* @returns Returns `augmentedConfig` with `queries` set to the computed array of queries.
|
||||
*/
|
||||
function combineQueries(
|
||||
logger: Logger,
|
||||
config: UserConfig,
|
||||
augmentationProperties: AugmentationProperties,
|
||||
): QuerySpec[] {
|
||||
@@ -383,6 +387,12 @@ function combineQueries(
|
||||
// settings. If they don't allow combining with other query configurations, return just the
|
||||
// ones configured in the repository properties.
|
||||
if (!augmentationProperties.repoPropertyQueries.combines) {
|
||||
if (!isDefaultSetup()) {
|
||||
logger.info(
|
||||
`Queries are configured in the repository properties and don't allow combining with other query settings. ` +
|
||||
`Any queries configured elsewhere will be ignored.`,
|
||||
);
|
||||
}
|
||||
return augmentationProperties.repoPropertyQueries.input;
|
||||
} else {
|
||||
// Otherwise, add them to the query array and continue.
|
||||
@@ -414,6 +424,7 @@ function combineQueries(
|
||||
}
|
||||
|
||||
export function generateCodeScanningConfig(
|
||||
logger: Logger,
|
||||
originalUserInput: UserConfig,
|
||||
augmentationProperties: AugmentationProperties,
|
||||
): UserConfig {
|
||||
@@ -422,9 +433,13 @@ export function generateCodeScanningConfig(
|
||||
|
||||
// Inject the queries from the input
|
||||
augmentedConfig.queries = combineQueries(
|
||||
logger,
|
||||
augmentedConfig,
|
||||
augmentationProperties,
|
||||
);
|
||||
logger.debug(
|
||||
`Combined queries: ${augmentedConfig.queries?.map((q) => q.uses).join(",")}`,
|
||||
);
|
||||
if (augmentedConfig.queries?.length === 0) {
|
||||
delete augmentedConfig.queries;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user