Skip to content

Fix using the resolve-environment Action with language aliases #1923

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Defer language aliasing to CLI when appropriate
  • Loading branch information
henrymercer committed Oct 5, 2023
commit e26ed57a228512338332f937ef0f121a739d548c
2 changes: 1 addition & 1 deletion lib/codeql.js.map

Large diffs are not rendered by default.

7 changes: 1 addition & 6 deletions lib/resolve-environment-action.js

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

2 changes: 1 addition & 1 deletion lib/resolve-environment-action.js.map

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

17 changes: 15 additions & 2 deletions lib/resolve-environment.js

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

2 changes: 1 addition & 1 deletion lib/resolve-environment.js.map

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

4 changes: 2 additions & 2 deletions src/codeql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export interface CodeQL {
*/
resolveBuildEnvironment(
workingDir: string | undefined,
language: Language,
language: string,
): Promise<ResolveBuildEnvironmentOutput>;

/**
Expand Down Expand Up @@ -780,7 +780,7 @@ export async function getCodeQLForCmd(
},
async resolveBuildEnvironment(
workingDir: string | undefined,
language: Language,
language: string,
) {
const codeqlArgs = [
"resolve",
Expand Down
13 changes: 1 addition & 12 deletions src/resolve-environment-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);

Expand All @@ -69,7 +58,7 @@ async function run() {
config.codeQLCmd,
logger,
workingDirectory,
language,
getRequiredInput("language"),
);
core.setOutput(ENVIRONMENT_OUTPUT_NAME, result);
} catch (unwrappedError) {
Expand Down
27 changes: 23 additions & 4 deletions src/resolve-environment.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,36 @@
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";

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`
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy