Skip to content

Rust: remove shipped feature flag #2960

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 0 additions & 2 deletions .github/workflows/__rust.yml

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

6 changes: 0 additions & 6 deletions lib/feature-flags.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/feature-flags.js.map

Large diffs are not rendered by default.

28 changes: 9 additions & 19 deletions lib/init-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/init-action.js.map

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions pr-checks/checks/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ steps:
with:
languages: rust
tools: ${{ steps.prepare-test.outputs.tools-url }}
env:
CODEQL_ACTION_RUST_ANALYSIS: true
- uses: ./../action/analyze
id: analysis
with:
Expand Down
6 changes: 0 additions & 6 deletions src/feature-flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ export enum Feature {
OverlayAnalysisSwift = "overlay_analysis_swift",
PythonDefaultIsToNotExtractStdlib = "python_default_is_to_not_extract_stdlib",
QaTelemetryEnabled = "qa_telemetry_enabled",
RustAnalysis = "rust_analysis",
ZstdBundleStreamingExtraction = "zstd_bundle_streaming_extraction",
}

Expand Down Expand Up @@ -275,11 +274,6 @@ export const featureConfig: Record<
minimumVersion: undefined,
toolsFeature: ToolsFeature.PythonDefaultIsToNotExtractStdlib,
},
[Feature.RustAnalysis]: {
defaultValue: false,
envVar: "CODEQL_ACTION_RUST_ANALYSIS",
minimumVersion: "2.19.3",
},
[Feature.QaTelemetryEnabled]: {
defaultValue: false,
envVar: "CODEQL_ACTION_QA_TELEMETRY",
Expand Down
37 changes: 12 additions & 25 deletions src/init-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import * as path from "path";

import * as core from "@actions/core";
import * as io from "@actions/io";
import * as semver from "semver";
import { v4 as uuidV4 } from "uuid";

import {
Expand All @@ -14,7 +13,6 @@ import {
getRequiredInput,
getTemporaryDirectory,
persistInputs,
isDefaultSetup,
} from "./actions-util";
import { getGitHubVersion } from "./api-client";
import {
Expand All @@ -32,7 +30,7 @@ import {
makeDiagnostic,
} from "./diagnostics";
import { EnvVar } from "./environment";
import { Feature, featureConfig, Features } from "./feature-flags";
import { Feature, Features } from "./feature-flags";
import {
checkInstallPython311,
cleanupDatabaseClusterDirectory,
Expand Down Expand Up @@ -631,32 +629,21 @@ async function run() {
core.exportVariable(bmnVar, value);
}

// For rust: set CODEQL_ENABLE_EXPERIMENTAL_FEATURES, unless codeql already supports rust without it
// For rust, if `codeql` does not support it, we are in two possible situations:
// * either we run `codeql` prior to 2.19.3, which means no rust support is possible
// * or we run a version between 2.19.3 and 2.22.1 (excluded), when rust support was
// experimental and required explicitly setting CODEQL_ENABLE_EXPERIMENTAL_FEATURES,
// and that env variable is not set
// However, there is no need to let users know about the experimental feature flag at
// this point, if they want rust support they should chose a version which supports it
// publicly.
Comment on lines +638 to +639
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might break Rust analysis for users who have pinned v3 (or similar) of the Action as well as a CodeQL CLI >= 2.19.3 && < 2.22.1 and who used CODEQL_ENABLE_EXPERIMENTAL_FEATURES. I agree that it's not unreasonable to ask users to upgrade to a newer CLI version in that case, but perhaps we should give them some warning first before breaking their workflows over night when the next Action release happens? That said, it's not clear to me that a warning in the output would necessarily be noticed. I don't know if we have any data to know how many people would be affected.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in that situation (version 2.19.3..2.22.1 and CODEQL_ENABLE_EXPERIMENTAL_FEATURES=true) codeql resolve languages does give rust, which means that (await codeql.resolveLanguages()).rust is not undefined. The only change then is that users lose the Experimental Rust analysis enabled log line, but no functional change happens.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uh, actually, now I see that that log line was dead code anyway!

if (
config.languages.includes(Language.rust) &&
!(await codeql.resolveLanguages()).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");
throw new ConfigurationError(
"Rust analysis is supported from CodeQL version 2.22.1 or higher.",
);
}

// Restore dependency cache(s), if they exist.
Expand Down
Loading