mirror of
https://github.com/github/codeql-action.git
synced 2026-10-29 17:17:15 +00:00
Refactor resolveLanguages() to cache output according to CLI feature support
The output of `resolveLanguages()` can vary based on whether the flag `--filter-to-languages-with-queries` is included, but not all versions of the CLI support that. This makes caching a single execution problematic, so I opted to cache it based on whether it's supported. If it's supported, it's used; otherwise, it's not.
This commit is contained in:
34
lib/entry-points.js
generated
34
lib/entry-points.js
generated
@@ -151415,9 +151415,7 @@ async function getSupportedLanguageMap(codeql, logger) {
|
||||
const resolveSupportedLanguagesUsingCli = await codeql.supportsFeature(
|
||||
"builtinExtractorsSpecifyDefaultQueries" /* BuiltinExtractorsSpecifyDefaultQueries */
|
||||
);
|
||||
const resolveResult = await codeql.resolveLanguages({
|
||||
filterToLanguagesWithQueries: resolveSupportedLanguagesUsingCli
|
||||
});
|
||||
const resolveResult = await codeql.resolveLanguages();
|
||||
if (resolveSupportedLanguagesUsingCli) {
|
||||
logger.debug(
|
||||
`The CodeQL CLI supports the following languages: ${Object.keys(resolveResult.extractors).join(", ")}`
|
||||
@@ -153931,21 +153929,27 @@ async function getCodeQLForCmd(cmd, checkVersion) {
|
||||
];
|
||||
await runCli(cmd, args);
|
||||
},
|
||||
async resolveLanguages({
|
||||
filterToLanguagesWithQueries
|
||||
} = { filterToLanguagesWithQueries: false }) {
|
||||
async resolveLanguages() {
|
||||
return getCachedOrRun(
|
||||
"resolveLanguages" /* ResolveLanguages */,
|
||||
cmd,
|
||||
() => runCliJson(cmd, [
|
||||
"resolve",
|
||||
"languages",
|
||||
"--format=betterjson",
|
||||
"--extractor-options-verbosity=4",
|
||||
"--extractor-include-aliases",
|
||||
...filterToLanguagesWithQueries ? ["--filter-to-languages-with-queries"] : [],
|
||||
...getExtraOptionsFromEnv(["resolve", "languages"])
|
||||
]),
|
||||
async () => {
|
||||
const isFilterToLanguagesWithQueriesSupported = await this.supportsFeature(
|
||||
"builtinExtractorsSpecifyDefaultQueries" /* BuiltinExtractorsSpecifyDefaultQueries */
|
||||
);
|
||||
return runCliJson(cmd, [
|
||||
"resolve",
|
||||
"languages",
|
||||
"--format=betterjson",
|
||||
"--extractor-options-verbosity=4",
|
||||
"--extractor-include-aliases",
|
||||
// TODO: Unconditionally include `--filter-to-languages-with-queries`
|
||||
// once CODEQL_MINIMUM_VERSION is at least v2.23.0
|
||||
// — the first version to support this flag.
|
||||
...isFilterToLanguagesWithQueriesSupported ? ["--filter-to-languages-with-queries"] : [],
|
||||
...getExtraOptionsFromEnv(["resolve", "languages"])
|
||||
]);
|
||||
},
|
||||
isResolveLanguagesOutput
|
||||
);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user