@@ -3,6 +3,7 @@ import * as path from "path";
3
3
4
4
import * as core from "@actions/core" ;
5
5
import * as io from "@actions/io" ;
6
+ import * as semver from "semver" ;
6
7
import { v4 as uuidV4 } from "uuid" ;
7
8
8
9
import {
@@ -72,6 +73,7 @@ import {
72
73
getErrorMessage ,
73
74
} from "./util" ;
74
75
import { validateWorkflow } from "./workflow" ;
76
+ import { util } from "node-forge" ;
75
77
76
78
/** Fields of the init status report that can be sent before `config` is populated. */
77
79
interface InitStatusReport extends StatusReportBase {
@@ -580,28 +582,22 @@ async function run() {
580
582
if ( config . languages . includes ( Language . rust ) ) {
581
583
const feat = Feature . RustAnalysis ;
582
584
const minVer = featureConfig [ feat ] . minimumVersion as string ;
583
- if ( ! ( await codeQlVersionAtLeast ( codeql , minVer ) ) ) {
584
- logger . error (
585
- `Experimental rust analysis requires CodeQL version ${ minVer } or higher` ,
585
+ const envVar = "CODEQL_ENABLE_EXPERIMENTAL_FEATURES" ;
586
+ if ( await features . getValue ( feat , codeql ) ) {
587
+ core . exportVariable ( envVar , "true" ) ;
588
+ }
589
+ if ( process . env [ envVar ] !== "true" ) {
590
+ throw new ConfigurationError (
591
+ `Experimental and not officially supported Rust analysis requires setting {envVar}=true in the environment`
592
+ ) ;
593
+ }
594
+ const actualVer = ( await codeql . getVersion ( ) ) . version ;
595
+ if ( semver . lt ( actualVer , minVer ) ) {
596
+ throw new ConfigurationError (
597
+ `Experimental rust analysis is supported by CodeQL CLI version ${ minVer } or higher, but found version ${ actualVer } ` ,
586
598
) ;
587
- } else {
588
- const envVar = featureConfig [ feat ] . envVar ;
589
- const expVar = "CODEQL_ENABLE_EXPERIMENTAL_FEATURES" ;
590
- if (
591
- process . env [ envVar ] === "true" ||
592
- ( await features . getValue ( feat , codeql ) )
593
- ) {
594
- core . exportVariable ( expVar , "true" ) ;
595
- }
596
- if ( process . env [ expVar ] === "true" ) {
597
- logger . info ( "Experimental rust analysis enabled" ) ;
598
- } else {
599
- logger . error (
600
- "Experimental rust analysis requested but not enabled. " +
601
- "You must set the CODEQL_ENABLE_EXPERIMENTAL_FEATURES environment variable to true" ,
602
- ) ;
603
- }
604
599
}
600
+ logger . info ( "Experimental rust analysis enabled" ) ;
605
601
}
606
602
607
603
// Restore dependency cache(s), if they exist.
0 commit comments