Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
96ca55b
Ava: Run all tests in `src/` directory
mbg Sep 20, 2025
4f9b2f7
Add initial client for repository properties
mbg Sep 19, 2025
3b00d03
Load repository properties and store them in the `Config`
mbg Sep 19, 2025
6150aff
Add and use `QuerySpec` type
mbg Sep 19, 2025
ed216a0
Include queries from repo properties in `AugmentationProperties`
mbg Sep 20, 2025
781a65a
Use appropriate error message in `parseQueriesFromInput` for repo pro…
mbg Sep 20, 2025
1bfb67d
Refactor combining queries into its own function
mbg Sep 20, 2025
d14a212
Include repo property queries in `combineQueries`
mbg Sep 20, 2025
c7eb488
Add tests
mbg Sep 20, 2025
d46a178
Sort `queries` array in `check-codescanning-config`
mbg Sep 22, 2025
6bb4ad3
Update .github/actions/check-codescanning-config/index.ts
mbg Sep 22, 2025
54746c8
Fix `expected-config-file-contents`
mbg Sep 22, 2025
889d482
Add logging to `combineQueries`
mbg Sep 22, 2025
05310c6
Ignore repository property query config if CQ-only analysis
mbg Sep 22, 2025
b4f966a
Add FF to control whether to fetch repository properties
mbg Sep 22, 2025
40262b1
Add `getRepositoryProperties` to `api-client`, for easier mocking
mbg Sep 23, 2025
07920e8
Fix using `keys` instead of `values`
mbg Sep 23, 2025
7f73f8c
Add unit tests for `properties` module
mbg Sep 23, 2025
0a75581
Check that we are on dotcom
mbg Sep 23, 2025
205b6ba
Rebuild
mbg Sep 23, 2025
4178e15
Only disable `loadPropertiesFromApi` on GHES
mbg Sep 23, 2025
54bbe82
Always log when queries are configured in the repository properties
mbg Sep 23, 2025
5a4aa83
Always log when combining queries is disabled in the repo properties
mbg Sep 23, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add logging to combineQueries
  • Loading branch information
mbg committed Sep 22, 2025
commit 889d482c541f722cde215c10a6ce573c94cc17d5
14 changes: 12 additions & 2 deletions lib/init-action.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/codeql.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -505,6 +507,7 @@ const injectedConfigMacro = test.macro({
tempDir,
};
thisStubConfig.computedConfig = generateCodeScanningConfig(
getRunnerLogger(true),
thisStubConfig.originalUserInput,
augmentationProperties,
);
Expand Down
1 change: 1 addition & 0 deletions src/config-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
Expand Down
15 changes: 15 additions & 0 deletions src/config/db-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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[] {
Expand All @@ -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.`,
);
Comment thread
mbg marked this conversation as resolved.
Outdated
}
return augmentationProperties.repoPropertyQueries.input;
} else {
// Otherwise, add them to the query array and continue.
Expand Down Expand Up @@ -414,6 +424,7 @@ function combineQueries(
}

export function generateCodeScanningConfig(
logger: Logger,
originalUserInput: UserConfig,
augmentationProperties: AugmentationProperties,
): UserConfig {
Expand All @@ -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;
}
Expand Down