Defer language aliasing to CLI when appropriate
This commit is contained in:
parent
0ac7669167
commit
e26ed57a22
8 changed files with 45 additions and 29 deletions
|
|
@ -128,7 +128,7 @@ export interface CodeQL {
|
|||
*/
|
||||
resolveBuildEnvironment(
|
||||
workingDir: string | undefined,
|
||||
language: Language,
|
||||
language: string,
|
||||
): Promise<ResolveBuildEnvironmentOutput>;
|
||||
|
||||
/**
|
||||
|
|
@ -780,7 +780,7 @@ export async function getCodeQLForCmd(
|
|||
},
|
||||
async resolveBuildEnvironment(
|
||||
workingDir: string | undefined,
|
||||
language: Language,
|
||||
language: string,
|
||||
) {
|
||||
const codeqlArgs = [
|
||||
"resolve",
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ import {
|
|||
import { getGitHubVersion } from "./api-client";
|
||||
import { CommandInvocationError } from "./codeql";
|
||||
import * as configUtils from "./config-utils";
|
||||
import { Language, parseLanguage } from "./languages";
|
||||
import { getActionsLogger } from "./logging";
|
||||
import { runResolveBuildEnvironment } from "./resolve-environment";
|
||||
import {
|
||||
|
|
@ -44,16 +43,6 @@ async function run() {
|
|||
return;
|
||||
}
|
||||
|
||||
const language: Language | undefined = parseLanguage(
|
||||
getRequiredInput("language"),
|
||||
);
|
||||
|
||||
if (language === undefined) {
|
||||
throw new Error(
|
||||
`Did not recognize the language "${getRequiredInput("language")}".`,
|
||||
);
|
||||
}
|
||||
|
||||
const gitHubVersion = await getGitHubVersion();
|
||||
checkGitHubVersionInRange(gitHubVersion, logger);
|
||||
|
||||
|
|
@ -69,7 +58,7 @@ async function run() {
|
|||
config.codeQLCmd,
|
||||
logger,
|
||||
workingDirectory,
|
||||
language,
|
||||
getRequiredInput("language"),
|
||||
);
|
||||
core.setOutput(ENVIRONMENT_OUTPUT_NAME, result);
|
||||
} catch (unwrappedError) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,9 @@
|
|||
import { CODEQL_VERSION_RESOLVE_ENVIRONMENT, getCodeQL } from "./codeql";
|
||||
import { Language } from "./languages";
|
||||
import {
|
||||
CODEQL_VERSION_LANGUAGE_ALIASING,
|
||||
CODEQL_VERSION_RESOLVE_ENVIRONMENT,
|
||||
getCodeQL,
|
||||
} from "./codeql";
|
||||
import { parseLanguage } from "./languages";
|
||||
import { Logger } from "./logging";
|
||||
import * as util from "./util";
|
||||
|
||||
|
|
@ -7,11 +11,26 @@ export async function runResolveBuildEnvironment(
|
|||
cmd: string,
|
||||
logger: Logger,
|
||||
workingDir: string | undefined,
|
||||
language: Language,
|
||||
languageInput: string,
|
||||
) {
|
||||
logger.startGroup(`Attempting to resolve build environment for ${language}`);
|
||||
logger.startGroup(
|
||||
`Attempting to resolve build environment for ${languageInput}`,
|
||||
);
|
||||
|
||||
const codeql = await getCodeQL(cmd);
|
||||
|
||||
let language = languageInput;
|
||||
if (await util.codeQlVersionAbove(codeql, CODEQL_VERSION_LANGUAGE_ALIASING)) {
|
||||
// Delegate to the CodeQL CLI to handle aliasing.
|
||||
} else {
|
||||
// Handle aliasing in the Action using `parseLanguage`.
|
||||
const parsedLanguage = parseLanguage(languageInput)?.toString();
|
||||
if (parsedLanguage === undefined) {
|
||||
throw new Error(`Did not recognize the language '${languageInput}'.`);
|
||||
}
|
||||
language = parsedLanguage;
|
||||
}
|
||||
|
||||
let result = {};
|
||||
|
||||
// If the CodeQL version in use does not support the `resolve build-environment`
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue