Support rust analysis
This is supposed to enable rust analysis for the staff ship only.
This commit is contained in:
parent
d99c7e8e5b
commit
a7b17782a9
16 changed files with 186 additions and 13 deletions
3
.github/workflows/__packaging-codescanning-config-inputs-js.yml
generated
vendored
3
.github/workflows/__packaging-codescanning-config-inputs-js.yml
generated
vendored
|
|
@ -79,8 +79,7 @@ jobs:
|
||||||
uses: ./../action/.github/actions/check-sarif
|
uses: ./../action/.github/actions/check-sarif
|
||||||
with:
|
with:
|
||||||
sarif-file: ${{ runner.temp }}/results/javascript.sarif
|
sarif-file: ${{ runner.temp }}/results/javascript.sarif
|
||||||
queries-run:
|
queries-run: javascript/example/empty-or-one-block,javascript/example/empty-or-one-block,javascript/example/other-query-block,javascript/example/two-block
|
||||||
javascript/example/empty-or-one-block,javascript/example/empty-or-one-block,javascript/example/other-query-block,javascript/example/two-block
|
|
||||||
queries-not-run: foo,bar
|
queries-not-run: foo,bar
|
||||||
|
|
||||||
- name: Assert Results
|
- name: Assert Results
|
||||||
|
|
|
||||||
3
.github/workflows/__packaging-config-inputs-js.yml
generated
vendored
3
.github/workflows/__packaging-config-inputs-js.yml
generated
vendored
|
|
@ -79,8 +79,7 @@ jobs:
|
||||||
uses: ./../action/.github/actions/check-sarif
|
uses: ./../action/.github/actions/check-sarif
|
||||||
with:
|
with:
|
||||||
sarif-file: ${{ runner.temp }}/results/javascript.sarif
|
sarif-file: ${{ runner.temp }}/results/javascript.sarif
|
||||||
queries-run:
|
queries-run: javascript/example/empty-or-one-block,javascript/example/empty-or-one-block,javascript/example/other-query-block,javascript/example/two-block
|
||||||
javascript/example/empty-or-one-block,javascript/example/empty-or-one-block,javascript/example/other-query-block,javascript/example/two-block
|
|
||||||
queries-not-run: foo,bar
|
queries-not-run: foo,bar
|
||||||
|
|
||||||
- name: Assert Results
|
- name: Assert Results
|
||||||
|
|
|
||||||
3
.github/workflows/__packaging-config-js.yml
generated
vendored
3
.github/workflows/__packaging-config-js.yml
generated
vendored
|
|
@ -78,8 +78,7 @@ jobs:
|
||||||
uses: ./../action/.github/actions/check-sarif
|
uses: ./../action/.github/actions/check-sarif
|
||||||
with:
|
with:
|
||||||
sarif-file: ${{ runner.temp }}/results/javascript.sarif
|
sarif-file: ${{ runner.temp }}/results/javascript.sarif
|
||||||
queries-run:
|
queries-run: javascript/example/empty-or-one-block,javascript/example/empty-or-one-block,javascript/example/other-query-block,javascript/example/two-block
|
||||||
javascript/example/empty-or-one-block,javascript/example/empty-or-one-block,javascript/example/other-query-block,javascript/example/two-block
|
|
||||||
queries-not-run: foo,bar
|
queries-not-run: foo,bar
|
||||||
|
|
||||||
- name: Assert Results
|
- name: Assert Results
|
||||||
|
|
|
||||||
3
.github/workflows/__packaging-inputs-js.yml
generated
vendored
3
.github/workflows/__packaging-inputs-js.yml
generated
vendored
|
|
@ -78,8 +78,7 @@ jobs:
|
||||||
uses: ./../action/.github/actions/check-sarif
|
uses: ./../action/.github/actions/check-sarif
|
||||||
with:
|
with:
|
||||||
sarif-file: ${{ runner.temp }}/results/javascript.sarif
|
sarif-file: ${{ runner.temp }}/results/javascript.sarif
|
||||||
queries-run:
|
queries-run: javascript/example/empty-or-one-block,javascript/example/empty-or-one-block,javascript/example/other-query-block,javascript/example/two-block
|
||||||
javascript/example/empty-or-one-block,javascript/example/empty-or-one-block,javascript/example/other-query-block,javascript/example/two-block
|
|
||||||
queries-not-run: foo,bar
|
queries-not-run: foo,bar
|
||||||
|
|
||||||
- name: Assert Results
|
- name: Assert Results
|
||||||
|
|
|
||||||
3
.github/workflows/__resolve-environment-action.yml
generated
vendored
3
.github/workflows/__resolve-environment-action.yml
generated
vendored
|
|
@ -83,8 +83,7 @@ jobs:
|
||||||
language: javascript-typescript
|
language: javascript-typescript
|
||||||
|
|
||||||
- name: Fail if JavaScript/TypeScript configuration present
|
- name: Fail if JavaScript/TypeScript configuration present
|
||||||
if:
|
if: fromJSON(steps.resolve-environment-js.outputs.environment).configuration.javascript
|
||||||
fromJSON(steps.resolve-environment-js.outputs.environment).configuration.javascript
|
|
||||||
run: exit 1
|
run: exit 1
|
||||||
env:
|
env:
|
||||||
CODEQL_ACTION_TEST_MODE: true
|
CODEQL_ACTION_TEST_MODE: true
|
||||||
|
|
|
||||||
71
.github/workflows/__rust.yml
generated
vendored
Normal file
71
.github/workflows/__rust.yml
generated
vendored
Normal file
|
|
@ -0,0 +1,71 @@
|
||||||
|
# Warning: This file is generated automatically, and should not be modified.
|
||||||
|
# Instead, please modify the template in the pr-checks directory and run:
|
||||||
|
# (cd pr-checks; pip install ruamel.yaml@0.17.31 && python3 sync.py)
|
||||||
|
# to regenerate this file.
|
||||||
|
|
||||||
|
name: PR Check - Rust analysis
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
GO111MODULE: auto
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
- releases/v*
|
||||||
|
pull_request:
|
||||||
|
types:
|
||||||
|
- opened
|
||||||
|
- synchronize
|
||||||
|
- reopened
|
||||||
|
- ready_for_review
|
||||||
|
schedule:
|
||||||
|
- cron: '0 5 * * *'
|
||||||
|
workflow_dispatch: {}
|
||||||
|
jobs:
|
||||||
|
rust:
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- os: ubuntu-latest
|
||||||
|
version: linked
|
||||||
|
- os: ubuntu-latest
|
||||||
|
version: default
|
||||||
|
- os: ubuntu-latest
|
||||||
|
version: nightly-latest
|
||||||
|
name: Rust analysis
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
security-events: read
|
||||||
|
timeout-minutes: 45
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
steps:
|
||||||
|
- name: Check out repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- name: Prepare test
|
||||||
|
id: prepare-test
|
||||||
|
uses: ./.github/actions/prepare-test
|
||||||
|
with:
|
||||||
|
version: ${{ matrix.version }}
|
||||||
|
use-all-platform-bundle: 'false'
|
||||||
|
setup-kotlin: 'true'
|
||||||
|
- uses: ./../action/init
|
||||||
|
with:
|
||||||
|
languages: rust
|
||||||
|
tools: ${{ steps.prepare-test.outputs.tools-url }}
|
||||||
|
env:
|
||||||
|
CODEQL_ACTION_RUST_ANALYSIS: true
|
||||||
|
- uses: ./../action/analyze
|
||||||
|
id: analysis
|
||||||
|
with:
|
||||||
|
upload-database: false
|
||||||
|
- name: Check database
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
RUST_DB="${{ fromJson(steps.analysis.outputs.db-locations).rust }}"
|
||||||
|
if [[ ! -d "$RUST_DB" ]]; then
|
||||||
|
echo "Did not create a database for Rust."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
env:
|
||||||
|
CODEQL_ACTION_TEST_MODE: true
|
||||||
6
lib/feature-flags.js
generated
6
lib/feature-flags.js
generated
|
|
@ -68,6 +68,7 @@ var Feature;
|
||||||
Feature["ExtractToToolcache"] = "extract_to_toolcache";
|
Feature["ExtractToToolcache"] = "extract_to_toolcache";
|
||||||
Feature["PythonDefaultIsToNotExtractStdlib"] = "python_default_is_to_not_extract_stdlib";
|
Feature["PythonDefaultIsToNotExtractStdlib"] = "python_default_is_to_not_extract_stdlib";
|
||||||
Feature["QaTelemetryEnabled"] = "qa_telemetry_enabled";
|
Feature["QaTelemetryEnabled"] = "qa_telemetry_enabled";
|
||||||
|
Feature["RustAnalysis"] = "rust_analysis";
|
||||||
Feature["ZstdBundleStreamingExtraction"] = "zstd_bundle_streaming_extraction";
|
Feature["ZstdBundleStreamingExtraction"] = "zstd_bundle_streaming_extraction";
|
||||||
})(Feature || (exports.Feature = Feature = {}));
|
})(Feature || (exports.Feature = Feature = {}));
|
||||||
exports.featureConfig = {
|
exports.featureConfig = {
|
||||||
|
|
@ -132,6 +133,11 @@ exports.featureConfig = {
|
||||||
minimumVersion: undefined,
|
minimumVersion: undefined,
|
||||||
toolsFeature: tools_features_1.ToolsFeature.PythonDefaultIsToNotExtractStdlib,
|
toolsFeature: tools_features_1.ToolsFeature.PythonDefaultIsToNotExtractStdlib,
|
||||||
},
|
},
|
||||||
|
[Feature.RustAnalysis]: {
|
||||||
|
defaultValue: false,
|
||||||
|
envVar: "CODEQL_ACTION_RUST_ANALYSIS",
|
||||||
|
minimumVersion: "2.19.3",
|
||||||
|
},
|
||||||
[Feature.QaTelemetryEnabled]: {
|
[Feature.QaTelemetryEnabled]: {
|
||||||
defaultValue: false,
|
defaultValue: false,
|
||||||
envVar: "CODEQL_ACTION_QA_TELEMETRY",
|
envVar: "CODEQL_ACTION_QA_TELEMETRY",
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
23
lib/init-action.js
generated
23
lib/init-action.js
generated
|
|
@ -345,6 +345,29 @@ async function run() {
|
||||||
logger.info(`Setting C++ build-mode: none to ${value}`);
|
logger.info(`Setting C++ build-mode: none to ${value}`);
|
||||||
core.exportVariable(bmnVar, value);
|
core.exportVariable(bmnVar, value);
|
||||||
}
|
}
|
||||||
|
// Set CODEQL_ENABLE_EXPERIMENTAL_FEATURES for rust
|
||||||
|
if (config.languages.includes(languages_1.Language.rust)) {
|
||||||
|
const feat = feature_flags_1.Feature.RustAnalysis;
|
||||||
|
const minVer = feature_flags_1.featureConfig[feat].minimumVersion;
|
||||||
|
if (!(await (0, util_1.codeQlVersionAtLeast)(codeql, minVer))) {
|
||||||
|
logger.error(`Experimental rust analysis requires CodeQL version ${minVer} or higher`);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
const envVar = feature_flags_1.featureConfig[feat].envVar;
|
||||||
|
const expVar = "CODEQL_ENABLE_EXPERIMENTAL_FEATURES";
|
||||||
|
if (process.env[envVar] === "true" ||
|
||||||
|
(await features.getValue(feat, codeql))) {
|
||||||
|
core.exportVariable(expVar, "true");
|
||||||
|
}
|
||||||
|
if (process.env[expVar] === "true") {
|
||||||
|
logger.info("Experimental rust analysis enabled");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
logger.error("Experimental rust analysis requested but not enabled. " +
|
||||||
|
"You must set the CODEQL_ENABLE_EXPERIMENTAL_FEATURES environment variable to true");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
// Restore dependency cache(s), if they exist.
|
// Restore dependency cache(s), if they exist.
|
||||||
if ((0, caching_utils_1.shouldRestoreCache)(config.dependencyCachingEnabled)) {
|
if ((0, caching_utils_1.shouldRestoreCache)(config.dependencyCachingEnabled)) {
|
||||||
await (0, dependency_caching_1.downloadDependencyCaches)(config.languages, logger);
|
await (0, dependency_caching_1.downloadDependencyCaches)(config.languages, logger);
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
23
pr-checks/checks/rust.yml
Normal file
23
pr-checks/checks/rust.yml
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
name: "Rust analysis"
|
||||||
|
description: "Tests creation of a Rust database"
|
||||||
|
versions: ["linked", "default", "nightly-latest"]
|
||||||
|
operatingSystems: ["ubuntu"]
|
||||||
|
steps:
|
||||||
|
- uses: ./../action/init
|
||||||
|
with:
|
||||||
|
languages: rust
|
||||||
|
tools: ${{ steps.prepare-test.outputs.tools-url }}
|
||||||
|
env:
|
||||||
|
CODEQL_ACTION_RUST_ANALYSIS: true
|
||||||
|
- uses: ./../action/analyze
|
||||||
|
id: analysis
|
||||||
|
with:
|
||||||
|
upload-database: false
|
||||||
|
- name: Check database
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
RUST_DB="${{ fromJson(steps.analysis.outputs.db-locations).rust }}"
|
||||||
|
if [[ ! -d "$RUST_DB" ]]; then
|
||||||
|
echo "Did not create a database for Rust."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
@ -53,6 +53,7 @@ export enum Feature {
|
||||||
ExtractToToolcache = "extract_to_toolcache",
|
ExtractToToolcache = "extract_to_toolcache",
|
||||||
PythonDefaultIsToNotExtractStdlib = "python_default_is_to_not_extract_stdlib",
|
PythonDefaultIsToNotExtractStdlib = "python_default_is_to_not_extract_stdlib",
|
||||||
QaTelemetryEnabled = "qa_telemetry_enabled",
|
QaTelemetryEnabled = "qa_telemetry_enabled",
|
||||||
|
RustAnalysis = "rust_analysis",
|
||||||
ZstdBundleStreamingExtraction = "zstd_bundle_streaming_extraction",
|
ZstdBundleStreamingExtraction = "zstd_bundle_streaming_extraction",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -148,6 +149,11 @@ export const featureConfig: Record<
|
||||||
minimumVersion: undefined,
|
minimumVersion: undefined,
|
||||||
toolsFeature: ToolsFeature.PythonDefaultIsToNotExtractStdlib,
|
toolsFeature: ToolsFeature.PythonDefaultIsToNotExtractStdlib,
|
||||||
},
|
},
|
||||||
|
[Feature.RustAnalysis]: {
|
||||||
|
defaultValue: false,
|
||||||
|
envVar: "CODEQL_ACTION_RUST_ANALYSIS",
|
||||||
|
minimumVersion: "2.19.3",
|
||||||
|
},
|
||||||
[Feature.QaTelemetryEnabled]: {
|
[Feature.QaTelemetryEnabled]: {
|
||||||
defaultValue: false,
|
defaultValue: false,
|
||||||
envVar: "CODEQL_ACTION_QA_TELEMETRY",
|
envVar: "CODEQL_ACTION_QA_TELEMETRY",
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ import {
|
||||||
makeDiagnostic,
|
makeDiagnostic,
|
||||||
} from "./diagnostics";
|
} from "./diagnostics";
|
||||||
import { EnvVar } from "./environment";
|
import { EnvVar } from "./environment";
|
||||||
import { Feature, Features } from "./feature-flags";
|
import { Feature, featureConfig, Features } from "./feature-flags";
|
||||||
import {
|
import {
|
||||||
checkInstallPython311,
|
checkInstallPython311,
|
||||||
cleanupDatabaseClusterDirectory,
|
cleanupDatabaseClusterDirectory,
|
||||||
|
|
@ -576,6 +576,34 @@ async function run() {
|
||||||
core.exportVariable(bmnVar, value);
|
core.exportVariable(bmnVar, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set CODEQL_ENABLE_EXPERIMENTAL_FEATURES for rust
|
||||||
|
if (config.languages.includes(Language.rust)) {
|
||||||
|
const feat = Feature.RustAnalysis;
|
||||||
|
const minVer = featureConfig[feat].minimumVersion as string;
|
||||||
|
if (!(await codeQlVersionAtLeast(codeql, minVer))) {
|
||||||
|
logger.error(
|
||||||
|
`Experimental rust analysis requires CodeQL version ${minVer} or higher`,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
const envVar = featureConfig[feat].envVar;
|
||||||
|
const expVar = "CODEQL_ENABLE_EXPERIMENTAL_FEATURES";
|
||||||
|
if (
|
||||||
|
process.env[envVar] === "true" ||
|
||||||
|
(await features.getValue(feat, codeql))
|
||||||
|
) {
|
||||||
|
core.exportVariable(expVar, "true");
|
||||||
|
}
|
||||||
|
if (process.env[expVar] === "true") {
|
||||||
|
logger.info("Experimental rust analysis enabled");
|
||||||
|
} else {
|
||||||
|
logger.error(
|
||||||
|
"Experimental rust analysis requested but not enabled. " +
|
||||||
|
"You must set the CODEQL_ENABLE_EXPERIMENTAL_FEATURES environment variable to true",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Restore dependency cache(s), if they exist.
|
// Restore dependency cache(s), if they exist.
|
||||||
if (shouldRestoreCache(config.dependencyCachingEnabled)) {
|
if (shouldRestoreCache(config.dependencyCachingEnabled)) {
|
||||||
await downloadDependencyCaches(config.languages, logger);
|
await downloadDependencyCaches(config.languages, logger);
|
||||||
|
|
|
||||||
7
tests/multi-language-repo/Cargo.lock
generated
Normal file
7
tests/multi-language-repo/Cargo.lock
generated
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
# This file is automatically @generated by Cargo.
|
||||||
|
# It is not intended for manual editing.
|
||||||
|
version = 4
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "test"
|
||||||
|
version = "0.0.1"
|
||||||
8
tests/multi-language-repo/Cargo.toml
Normal file
8
tests/multi-language-repo/Cargo.toml
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
[package]
|
||||||
|
name = "test"
|
||||||
|
version = "0.0.1"
|
||||||
|
edition = "2021"
|
||||||
|
[[bin]]
|
||||||
|
name = "main"
|
||||||
|
path = "main.rs"
|
||||||
|
|
||||||
6
tests/multi-language-repo/main.rs
Normal file
6
tests/multi-language-repo/main.rs
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
fn main() {
|
||||||
|
if true {
|
||||||
|
println!("Hello world!")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue