mirror of
https://github.com/github/codeql-action.git
synced 2026-01-04 21:50:17 +08:00
Improve detection of Rust in languages input
This commit is contained in:
@@ -398,6 +398,15 @@ export async function getLanguages(
|
||||
return languages;
|
||||
}
|
||||
|
||||
export function getRawLanguagesNoAutodetect(
|
||||
languagesInput: string | undefined,
|
||||
): string[] {
|
||||
return (languagesInput || "")
|
||||
.split(",")
|
||||
.map((x) => x.trim().toLowerCase())
|
||||
.filter((x) => x.length > 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the set of languages in the current repository without checking to
|
||||
* see if these languages are actually supported by CodeQL.
|
||||
@@ -416,12 +425,8 @@ export async function getRawLanguages(
|
||||
rawLanguages: string[];
|
||||
autodetected: boolean;
|
||||
}> {
|
||||
// Obtain from action input 'languages' if set
|
||||
const languagesFromInput = (languagesInput || "")
|
||||
.split(",")
|
||||
.map((x) => x.trim().toLowerCase())
|
||||
.filter((x) => x.length > 0);
|
||||
// If the user has specified languages, use those.
|
||||
const languagesFromInput = getRawLanguagesNoAutodetect(languagesInput);
|
||||
if (languagesFromInput.length) {
|
||||
return { rawLanguages: languagesFromInput, autodetected: false };
|
||||
}
|
||||
|
||||
@@ -362,8 +362,16 @@ async function run() {
|
||||
}
|
||||
core.endGroup();
|
||||
|
||||
// Set CODEQL_ENABLE_EXPERIMENTAL_FEATURES for rust
|
||||
if (getOptionalInput("languages")?.includes(KnownLanguage.rust)) {
|
||||
// Set CODEQL_ENABLE_EXPERIMENTAL_FEATURES for Rust. We need to set this environment
|
||||
// variable before initializing the config, otherwise Rust analysis will not be
|
||||
// enabled.
|
||||
if (
|
||||
// Only enable Rust analysis if the user has explicitly requested it - don't
|
||||
// enable it via language autodetection.
|
||||
configUtils
|
||||
.getRawLanguagesNoAutodetect(getOptionalInput("languages"))
|
||||
.includes(KnownLanguage.rust)
|
||||
) {
|
||||
const feat = Feature.RustAnalysis;
|
||||
const minVer = featureConfig[feat].minimumVersion as string;
|
||||
const envVar = "CODEQL_ENABLE_EXPERIMENTAL_FEATURES";
|
||||
|
||||
Reference in New Issue
Block a user