mirror of
https://github.com/github/codeql-action.git
synced 2026-04-17 04:23:16 +00:00
Rust: Set experimental features variable before language parsing
This commit is contained in:
@@ -342,6 +342,31 @@ async function run() {
|
||||
}
|
||||
core.endGroup();
|
||||
|
||||
// Set CODEQL_ENABLE_EXPERIMENTAL_FEATURES for rust
|
||||
if (getOptionalInput("languages")?.includes(String(KnownLanguage.rust))) {
|
||||
const feat = Feature.RustAnalysis;
|
||||
const minVer = featureConfig[feat].minimumVersion as string;
|
||||
const envVar = "CODEQL_ENABLE_EXPERIMENTAL_FEATURES";
|
||||
// if in default setup, it means the feature flag was on when rust was enabled
|
||||
// if the feature flag gets turned off, let's not have rust analysis throwing a configuration error
|
||||
// in that case rust analysis will be disabled only when default setup is refreshed
|
||||
if (isDefaultSetup() || (await features.getValue(feat, codeql))) {
|
||||
core.exportVariable(envVar, "true");
|
||||
}
|
||||
if (process.env[envVar] !== "true") {
|
||||
throw new ConfigurationError(
|
||||
`Experimental and not officially supported Rust analysis requires setting ${envVar}=true in the environment`,
|
||||
);
|
||||
}
|
||||
const actualVer = (await codeql.getVersion()).version;
|
||||
if (semver.lt(actualVer, minVer)) {
|
||||
throw new ConfigurationError(
|
||||
`Experimental rust analysis is supported by CodeQL CLI version ${minVer} or higher, but found version ${actualVer}`,
|
||||
);
|
||||
}
|
||||
logger.info("Experimental rust analysis enabled");
|
||||
}
|
||||
|
||||
config = await initConfig({
|
||||
languagesInput: getOptionalInput("languages"),
|
||||
queriesInput: getOptionalInput("queries"),
|
||||
@@ -590,31 +615,6 @@ async function run() {
|
||||
core.exportVariable(bmnVar, value);
|
||||
}
|
||||
|
||||
// Set CODEQL_ENABLE_EXPERIMENTAL_FEATURES for rust
|
||||
if (config.languages.includes(KnownLanguage.rust)) {
|
||||
const feat = Feature.RustAnalysis;
|
||||
const minVer = featureConfig[feat].minimumVersion as string;
|
||||
const envVar = "CODEQL_ENABLE_EXPERIMENTAL_FEATURES";
|
||||
// if in default setup, it means the feature flag was on when rust was enabled
|
||||
// if the feature flag gets turned off, let's not have rust analysis throwing a configuration error
|
||||
// in that case rust analysis will be disabled only when default setup is refreshed
|
||||
if (isDefaultSetup() || (await features.getValue(feat, codeql))) {
|
||||
core.exportVariable(envVar, "true");
|
||||
}
|
||||
if (process.env[envVar] !== "true") {
|
||||
throw new ConfigurationError(
|
||||
`Experimental and not officially supported Rust analysis requires setting ${envVar}=true in the environment`,
|
||||
);
|
||||
}
|
||||
const actualVer = (await codeql.getVersion()).version;
|
||||
if (semver.lt(actualVer, minVer)) {
|
||||
throw new ConfigurationError(
|
||||
`Experimental rust analysis is supported by CodeQL CLI version ${minVer} or higher, but found version ${actualVer}`,
|
||||
);
|
||||
}
|
||||
logger.info("Experimental rust analysis enabled");
|
||||
}
|
||||
|
||||
// Restore dependency cache(s), if they exist.
|
||||
if (shouldRestoreCache(config.dependencyCachingEnabled)) {
|
||||
await downloadDependencyCaches(config.languages, logger);
|
||||
|
||||
Reference in New Issue
Block a user