mirror of
https://github.com/github/codeql-action.git
synced 2026-01-04 05:30:16 +08:00
Support features key in version JSON output
This commit is contained in:
@@ -75,7 +75,7 @@ export interface CodeQL {
|
||||
/**
|
||||
* Get a string containing the semver version of the CodeQL executable.
|
||||
*/
|
||||
getVersion(): Promise<string>;
|
||||
getVersion(): Promise<VersionOutput>;
|
||||
/**
|
||||
* Print version information about CodeQL.
|
||||
*/
|
||||
@@ -212,6 +212,19 @@ export interface CodeQL {
|
||||
resolveExtractor(language: Language): Promise<string>;
|
||||
}
|
||||
|
||||
export interface VersionOutput {
|
||||
productName: string;
|
||||
vendor: string;
|
||||
version: string;
|
||||
sha: string;
|
||||
branches: string[];
|
||||
copyright: string;
|
||||
unpackedLocation: string;
|
||||
configFileLocation: string;
|
||||
configFileFound: boolean;
|
||||
features?: { [name: string]: boolean };
|
||||
}
|
||||
|
||||
export interface ResolveLanguagesOutput {
|
||||
[language: string]: [string];
|
||||
}
|
||||
@@ -430,6 +443,21 @@ function resolveFunction<T>(
|
||||
return partialCodeql[methodName];
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a `VersionOutput` object for testing purposes only.
|
||||
*/
|
||||
export const makeVersionOutput = (version: string): VersionOutput => ({
|
||||
productName: "CodeQL",
|
||||
vendor: "GitHub",
|
||||
sha: "",
|
||||
branches: [],
|
||||
copyright: "",
|
||||
unpackedLocation: "",
|
||||
configFileLocation: "",
|
||||
configFileFound: false,
|
||||
version,
|
||||
});
|
||||
|
||||
/**
|
||||
* Set the functionality for CodeQL methods. Only for use in tests.
|
||||
*
|
||||
@@ -442,7 +470,7 @@ export function setCodeQL(partialCodeql: Partial<CodeQL>): CodeQL {
|
||||
getVersion: resolveFunction(
|
||||
partialCodeql,
|
||||
"getVersion",
|
||||
() => new Promise((resolve) => resolve("1.0.0")),
|
||||
() => new Promise((resolve) => resolve(makeVersionOutput("1.0.0"))),
|
||||
),
|
||||
printVersion: resolveFunction(partialCodeql, "printVersion"),
|
||||
databaseInitCluster: resolveFunction(partialCodeql, "databaseInitCluster"),
|
||||
@@ -528,7 +556,9 @@ export async function getCodeQLForCmd(
|
||||
async getVersion() {
|
||||
let result = util.getCachedCodeQlVersion();
|
||||
if (result === undefined) {
|
||||
result = (await runTool(cmd, ["version", "--format=terse"])).trim();
|
||||
result = JSON.parse(
|
||||
await runTool(cmd, ["version", "--format=json"]),
|
||||
) as VersionOutput;
|
||||
util.cacheCodeQlVersion(result);
|
||||
}
|
||||
return result;
|
||||
@@ -1095,15 +1125,18 @@ export async function getCodeQLForCmd(
|
||||
!(await util.codeQlVersionAbove(codeql, CODEQL_MINIMUM_VERSION))
|
||||
) {
|
||||
throw new Error(
|
||||
`Expected a CodeQL CLI with version at least ${CODEQL_MINIMUM_VERSION} but got version ${await codeql.getVersion()}`,
|
||||
`Expected a CodeQL CLI with version at least ${CODEQL_MINIMUM_VERSION} but got version ${
|
||||
(await codeql.getVersion()).version
|
||||
}`,
|
||||
);
|
||||
} else if (
|
||||
checkVersion &&
|
||||
process.env[EnvVar.SUPPRESS_DEPRECATED_SOON_WARNING] !== "true" &&
|
||||
!(await util.codeQlVersionAbove(codeql, CODEQL_NEXT_MINIMUM_VERSION))
|
||||
) {
|
||||
const result = await codeql.getVersion();
|
||||
core.warning(
|
||||
`CodeQL CLI version ${await codeql.getVersion()} was discontinued on ` +
|
||||
`CodeQL CLI version ${result.version} was discontinued on ` +
|
||||
`${GHES_MOST_RECENT_DEPRECATION_DATE} alongside GitHub Enterprise Server ` +
|
||||
`${GHES_VERSION_MOST_RECENTLY_DEPRECATED} and will not be supported by the next minor ` +
|
||||
`release of the CodeQL Action. Please update to CodeQL CLI version ` +
|
||||
@@ -1111,7 +1144,7 @@ export async function getCodeQLForCmd(
|
||||
"version of the CLI using the 'tools' input to the 'init' Action, you can remove this " +
|
||||
"input to use the default version.\n\n" +
|
||||
"Alternatively, if you want to continue using CodeQL CLI version " +
|
||||
`${await codeql.getVersion()}, you can replace 'github/codeql-action/*@v2' by ` +
|
||||
`${result.version}, you can replace 'github/codeql-action/*@v2' by ` +
|
||||
`'github/codeql-action/*@v${getActionVersion()}' in your code scanning workflow to ` +
|
||||
"continue using this version of the CodeQL Action.",
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user