Skip to content

Commit 60aa58a

Browse files
authored
Merge pull request #2960 from github/redsun82/rust
Rust: remove shipped feature flag
2 parents 9dfbcfd + df1ceac commit 60aa58a

File tree

9 files changed

+41
-108
lines changed

9 files changed

+41
-108
lines changed

lib/environment.js

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/environment.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/feature-flags.js

Lines changed: 0 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/feature-flags.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/init-action.js

Lines changed: 14 additions & 41 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/init-action.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/environment.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,4 +114,9 @@ export enum EnvVar {
114114
* Useful for testing purposes where multiple caches may be stored in the same repository.
115115
*/
116116
DEPENDENCY_CACHING_PREFIX = "CODEQL_ACTION_DEPENDENCY_CACHE_PREFIX",
117+
118+
/**
119+
* Whether to enable experimental extractors for CodeQL.
120+
*/
121+
EXPERIMENTAL_FEATURES = "CODEQL_ENABLE_EXPERIMENTAL_FEATURES",
117122
}

src/feature-flags.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ export enum Feature {
7474
OverlayAnalysisSwift = "overlay_analysis_swift",
7575
PythonDefaultIsToNotExtractStdlib = "python_default_is_to_not_extract_stdlib",
7676
QaTelemetryEnabled = "qa_telemetry_enabled",
77-
RustAnalysis = "rust_analysis",
7877
}
7978

8079
export const featureConfig: Record<
@@ -263,11 +262,6 @@ export const featureConfig: Record<
263262
minimumVersion: undefined,
264263
toolsFeature: ToolsFeature.PythonDefaultIsToNotExtractStdlib,
265264
},
266-
[Feature.RustAnalysis]: {
267-
defaultValue: false,
268-
envVar: "CODEQL_ACTION_RUST_ANALYSIS",
269-
minimumVersion: "2.19.3",
270-
},
271265
[Feature.QaTelemetryEnabled]: {
272266
defaultValue: false,
273267
envVar: "CODEQL_ACTION_QA_TELEMETRY",

src/init-action.ts

Lines changed: 15 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import {
1414
getRequiredInput,
1515
getTemporaryDirectory,
1616
persistInputs,
17-
isDefaultSetup,
1817
} from "./actions-util";
1918
import { getGitHubVersion } from "./api-client";
2019
import {
@@ -32,7 +31,7 @@ import {
3231
makeDiagnostic,
3332
} from "./diagnostics";
3433
import { EnvVar } from "./environment";
35-
import { Feature, featureConfig, Features } from "./feature-flags";
34+
import { Feature, Features } from "./feature-flags";
3635
import {
3736
checkInstallPython311,
3837
checkPacksForOverlayCompatibility,
@@ -360,37 +359,29 @@ async function run() {
360359
}
361360
core.endGroup();
362361

363-
// Set CODEQL_ENABLE_EXPERIMENTAL_FEATURES for Rust. We need to set this environment
364-
// variable before initializing the config, otherwise Rust analysis will not be
365-
// enabled.
362+
// Set CODEQL_ENABLE_EXPERIMENTAL_FEATURES for Rust if between 2.19.3 (included) and 2.22.1 (excluded)
363+
// We need to set this environment variable before initializing the config, otherwise Rust
364+
// analysis will not be enabled (experimental language packs are only active with that environment
365+
// variable set to `true`).
366366
if (
367-
// Only enable Rust analysis if the user has explicitly requested it - don't
368-
// enable it via language autodetection.
367+
// Only enable the experimental features env variable for Rust analysis if the user has explicitly
368+
// requested rust - don't enable it via language autodetection.
369369
configUtils
370370
.getRawLanguagesNoAutodetect(getOptionalInput("languages"))
371371
.includes(KnownLanguage.rust)
372372
) {
373-
const feat = Feature.RustAnalysis;
374-
const minVer = featureConfig[feat].minimumVersion as string;
375-
const envVar = "CODEQL_ENABLE_EXPERIMENTAL_FEATURES";
376-
// if in default setup, it means the feature flag was on when rust was enabled
377-
// if the feature flag gets turned off, let's not have rust analysis throwing a configuration error
378-
// in that case rust analysis will be disabled only when default setup is refreshed
379-
if (isDefaultSetup() || (await features.getValue(feat, codeql))) {
380-
core.exportVariable(envVar, "true");
381-
}
382-
if (process.env[envVar] !== "true") {
383-
throw new ConfigurationError(
384-
`Experimental and not officially supported Rust analysis requires setting ${envVar}=true in the environment`,
385-
);
386-
}
373+
const experimental = "2.19.3";
374+
const publicPreview = "2.22.1";
387375
const actualVer = (await codeql.getVersion()).version;
388-
if (semver.lt(actualVer, minVer)) {
376+
if (semver.lt(actualVer, experimental)) {
389377
throw new ConfigurationError(
390-
`Experimental rust analysis is supported by CodeQL CLI version ${minVer} or higher, but found version ${actualVer}`,
378+
`Rust analysis is supported by CodeQL CLI version ${experimental} or higher, but found version ${actualVer}`,
391379
);
392380
}
393-
logger.info("Experimental rust analysis enabled");
381+
if (semver.lt(actualVer, publicPreview)) {
382+
core.exportVariable(EnvVar.EXPERIMENTAL_FEATURES, "true");
383+
logger.info("Experimental Rust analysis enabled");
384+
}
394385
}
395386

396387
config = await initConfig({
@@ -665,34 +656,6 @@ async function run() {
665656
core.exportVariable(bmnVar, value);
666657
}
667658

668-
// For rust: set CODEQL_ENABLE_EXPERIMENTAL_FEATURES, unless codeql already supports rust without it
669-
if (
670-
config.languages.includes(KnownLanguage.rust) &&
671-
!(await codeql.resolveLanguages()).rust
672-
) {
673-
const feat = Feature.RustAnalysis;
674-
const minVer = featureConfig[feat].minimumVersion as string;
675-
const envVar = "CODEQL_ENABLE_EXPERIMENTAL_FEATURES";
676-
// if in default setup, it means the feature flag was on when rust was enabled
677-
// if the feature flag gets turned off, let's not have rust analysis throwing a configuration error
678-
// in that case rust analysis will be disabled only when default setup is refreshed
679-
if (isDefaultSetup() || (await features.getValue(feat, codeql))) {
680-
core.exportVariable(envVar, "true");
681-
}
682-
if (process.env[envVar] !== "true") {
683-
throw new ConfigurationError(
684-
`Experimental and not officially supported Rust analysis requires setting ${envVar}=true in the environment`,
685-
);
686-
}
687-
const actualVer = (await codeql.getVersion()).version;
688-
if (semver.lt(actualVer, minVer)) {
689-
throw new ConfigurationError(
690-
`Experimental rust analysis is supported by CodeQL CLI version ${minVer} or higher, but found version ${actualVer}`,
691-
);
692-
}
693-
logger.info("Experimental rust analysis enabled");
694-
}
695-
696659
// Restore dependency cache(s), if they exist.
697660
if (shouldRestoreCache(config.dependencyCachingEnabled)) {
698661
await downloadDependencyCaches(config.languages, logger);

0 commit comments

Comments
 (0)