From 502028f6bc3a4ce744e072e2633260dd3b546479 Mon Sep 17 00:00:00 2001 From: Rasmus Lerchedahl Petersen Date: Wed, 9 Oct 2024 15:30:49 +0200 Subject: [PATCH] Python: absolute basics probably still need to route some values around --- src/feature-flags.ts | 7 +++++++ src/init-action.ts | 10 ++++++++++ src/tools-features.ts | 1 + 3 files changed, 18 insertions(+) diff --git a/src/feature-flags.ts b/src/feature-flags.ts index 4768d8e7dd..f6a2a2dcef 100644 --- a/src/feature-flags.ts +++ b/src/feature-flags.ts @@ -47,6 +47,7 @@ export interface FeatureEnablement { export enum Feature { ArtifactV4Upgrade = "artifact_v4_upgrade", CleanupTrapCaches = "cleanup_trap_caches", + CodeqlActionPythonDefaultIsToNotExtractStdlib = "codeql_action_python_default_is_to_not_extract_stdlib", CppDependencyInstallation = "cpp_dependency_installation_enabled", DisableCsharpBuildless = "disable_csharp_buildless", DisableJavaBuildlessEnabled = "disable_java_buildless_enabled", @@ -97,6 +98,12 @@ export const featureConfig: Record< envVar: "CODEQL_ACTION_CLEANUP_TRAP_CACHES", minimumVersion: undefined, }, + [Feature.CodeqlActionPythonDefaultIsToNotExtractStdlib]: { + defaultValue: false, + envVar: "CODEQL_ACTION_DISABLE_PYTHON_STANDARD_LIBRARY_EXTRACTION", + minimumVersion: undefined, + toolsFeature: ToolsFeature.PythonDefaultIsToNotExtractStdlib, + }, [Feature.CppDependencyInstallation]: { defaultValue: false, envVar: "CODEQL_EXTRACTOR_CPP_AUTOINSTALL_DEPENDENCIES", diff --git a/src/init-action.ts b/src/init-action.ts index a787d43aaf..0efdb0703d 100644 --- a/src/init-action.ts +++ b/src/init-action.ts @@ -65,6 +65,7 @@ import { getErrorMessage, } from "./util"; import { validateWorkflow } from "./workflow"; +import { isFeatureAvailable } from "@actions/cache"; /** Fields of the init status report that can be sent before `config` is populated. */ interface InitStatusReport extends StatusReportBase { @@ -611,6 +612,15 @@ async function run() { ); } + if (await codeql.supportsFeature(ToolsFeature.PythonDefaultIsToNotExtractStdlib)) { + // We are in the case where the default has switched to not extracting the stdlib. + if (!(await features.getValue(Feature.CodeqlActionPythonDefaultIsToNotExtractStdlib, codeql))) { + // We are in a situation where the feature flag is not rolled out, + // so we need to suppress the new default behavior. + core.exportVariable("CODEQL_EXTRACTOR_PYTHON_EXTRACT_STDLIB", "true"); + } + } + const sourceRoot = path.resolve( getRequiredEnvParam("GITHUB_WORKSPACE"), getOptionalInput("source-root") || "", diff --git a/src/tools-features.ts b/src/tools-features.ts index 53835a6ecf..aa70459a96 100644 --- a/src/tools-features.ts +++ b/src/tools-features.ts @@ -10,6 +10,7 @@ export enum ToolsFeature { TraceCommandUseBuildMode = "traceCommandUseBuildMode", SarifMergeRunsFromEqualCategory = "sarifMergeRunsFromEqualCategory", ForceOverwrite = "forceOverwrite", + PythonDefaultIsToNotExtractStdlib = "pythonDefaultIsToNotExtractStdlib", } /**