Skip to content

Commit

Permalink
Python: Don't install deps by default for all users
Browse files Browse the repository at this point in the history
  • Loading branch information
Rasmus Wriedt Larsen committed Dec 13, 2023
1 parent b995212 commit 2f93dd4
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/analyze.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ async function setupPythonExtractor(
await features.getValue(
Feature.DisablePythonDependencyInstallationEnabled,
codeql,
) ||
await features.getValue(
Feature.PythonDefaultIsToSkipDependencyInstallationEnabled,
codeql,
)
) {
logger.warning(
Expand Down
11 changes: 11 additions & 0 deletions src/feature-flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ export enum Feature {
CppDependencyInstallation = "cpp_dependency_installation_enabled",
DisableKotlinAnalysisEnabled = "disable_kotlin_analysis_enabled",
DisablePythonDependencyInstallationEnabled = "disable_python_dependency_installation_enabled",
// NOTE: `python_default_is_to_skip_dependency_installation_enabled` is never actually returned by the GitHub API.
PythonDefaultIsToSkipDependencyInstallationEnabled = "python_default_is_to_skip_dependency_installation_enabled",
EvaluatorFineGrainedParallelismEnabled = "evaluator_fine_grained_parallelism_enabled",
ExportDiagnosticsEnabled = "export_diagnostics_enabled",
QaTelemetryEnabled = "qa_telemetry_enabled",
Expand Down Expand Up @@ -103,6 +105,15 @@ export const featureConfig: Record<
minimumVersion: undefined,
defaultValue: false,
},
[Feature.PythonDefaultIsToSkipDependencyInstallationEnabled]: {
// we can reuse the same environment variable as above. If someone has set it to
// `true` in their workflow this means dependencies are not installed, setting it to
// `false` means dependencies _will_ be installed. The same semantics are applied
// here!
envVar: "CODEQL_ACTION_DISABLE_PYTHON_DEPENDENCY_INSTALLATION",
minimumVersion: "2.16.0",
defaultValue: true,
},
};

/**
Expand Down
8 changes: 8 additions & 0 deletions src/init-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,10 @@ async function run() {
await features.getValue(
Feature.DisablePythonDependencyInstallationEnabled,
codeql,
) ||
await features.getValue(
Feature.PythonDefaultIsToSkipDependencyInstallationEnabled,
codeql,
)
) {
logger.info("Skipping python dependency installation");
Expand Down Expand Up @@ -450,6 +454,10 @@ async function run() {
await features.getValue(
Feature.DisablePythonDependencyInstallationEnabled,
codeql,
) ||
await features.getValue(
Feature.PythonDefaultIsToSkipDependencyInstallationEnabled,
codeql,
)
) {
core.exportVariable(
Expand Down

0 comments on commit 2f93dd4

Please sign in to comment.