@@ -14,7 +14,6 @@ import {
14
14
getRequiredInput ,
15
15
getTemporaryDirectory ,
16
16
persistInputs ,
17
- isDefaultSetup ,
18
17
} from "./actions-util" ;
19
18
import { getGitHubVersion } from "./api-client" ;
20
19
import {
@@ -32,7 +31,7 @@ import {
32
31
makeDiagnostic ,
33
32
} from "./diagnostics" ;
34
33
import { EnvVar } from "./environment" ;
35
- import { Feature , featureConfig , Features } from "./feature-flags" ;
34
+ import { Feature , Features } from "./feature-flags" ;
36
35
import {
37
36
checkInstallPython311 ,
38
37
checkPacksForOverlayCompatibility ,
@@ -360,37 +359,29 @@ async function run() {
360
359
}
361
360
core . endGroup ( ) ;
362
361
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`).
366
366
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.
369
369
configUtils
370
370
. getRawLanguagesNoAutodetect ( getOptionalInput ( "languages" ) )
371
371
. includes ( KnownLanguage . rust )
372
372
) {
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" ;
387
375
const actualVer = ( await codeql . getVersion ( ) ) . version ;
388
- if ( semver . lt ( actualVer , minVer ) ) {
376
+ if ( semver . lt ( actualVer , experimental ) ) {
389
377
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 } ` ,
391
379
) ;
392
380
}
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
+ }
394
385
}
395
386
396
387
config = await initConfig ( {
@@ -665,34 +656,6 @@ async function run() {
665
656
core . exportVariable ( bmnVar , value ) ;
666
657
}
667
658
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
-
696
659
// Restore dependency cache(s), if they exist.
697
660
if ( shouldRestoreCache ( config . dependencyCachingEnabled ) ) {
698
661
await downloadDependencyCaches ( config . languages , logger ) ;
0 commit comments