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
Ignore repository property query config if CQ-only analysis
  • Loading branch information
mbg committed Sep 22, 2025
commit 05310c6f55c5e8bf6c3da2745cb66aaaecac96c1
9 changes: 9 additions & 0 deletions lib/init-action.js

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

58 changes: 58 additions & 0 deletions src/config-utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
getRecordingLogger,
LoggedMessage,
mockCodeQLVersion,
createTestConfig,
} from "./testing-utils";
import {
GitHubVariant,
Expand Down Expand Up @@ -230,6 +231,63 @@ test("load code quality config", async (t) => {
});
});

test("initActionState doesn't throw if there are queries configured in the repository properties", async (t) => {
return await withTmpDir(async (tempDir) => {
const logger = getRunnerLogger(true);
const languages = "javascript";

const codeql = createStubCodeQL({
async betterResolveLanguages() {
return {
extractors: {
javascript: [{ extractor_root: "" }],
},
};
},
});

// This should be ignored and no error should be thrown.
const repositoryProperties = {
"github-codeql-extra-queries": "+foo",
};

// Expected configuration for a CQ-only analysis.
const computedConfig: configUtils.UserConfig = {
"disable-default-queries": true,
queries: [{ uses: "code-quality" }],
"query-filters": [],
};

const expectedConfig = createTestConfig({
analysisKinds: [AnalysisKind.CodeQuality],
languages: [KnownLanguage.javascript],
codeQLCmd: codeql.getPath(),
computedConfig,
dbLocation: path.resolve(tempDir, "codeql_databases"),
debugArtifactName: "",
debugDatabaseName: "",
tempDir,
repositoryProperties,
});

await t.notThrowsAsync(async () => {
const config = await configUtils.initConfig(
createTestInitConfigInputs({
analysisKindsInput: "code-quality",
languagesInput: languages,
repository: { owner: "github", repo: "example" },
tempDir,
codeql,
repositoryProperties,
logger,
}),
);

t.deepEqual(config, expectedConfig);
});
});
});

test("loading a saved config produces the same config", async (t) => {
return await withTmpDir(async (tempDir) => {
const logger = getRunnerLogger(true);
Expand Down
18 changes: 18 additions & 0 deletions src/config-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,24 @@ export async function initActionState(
languages,
);

// If `code-quality` is the only enabled analysis kind, we don't support query customisation.
// It would be a problem if queries that are configured in repository properties cause `code-quality`-only
// analyses to break. We therefore ignore query customisations that are configured in repository properties
// if `code-quality` is the only enabled analysis kind.
if (
analysisKinds.length === 1 &&
analysisKinds.includes(AnalysisKind.CodeQuality) &&
augmentationProperties.repoPropertyQueries.input
) {
logger.info(
`Ignoring queries configured in the repository properties, because query customisations are not supported for Code Quality analyses.`,
);
augmentationProperties.repoPropertyQueries = {
combines: false,
input: undefined,
};
}

const { trapCaches, trapCacheDownloadTime } = await downloadCacheWithTime(
trapCachingEnabled,
codeql,
Expand Down
Loading