Skip to content

Commit 2e27b3c

Browse files
committed
Create helper isPythonDependencyInstallationDisabled
1 parent afef25e commit 2e27b3c

9 files changed

+37
-41
lines changed

lib/analyze.js

+1-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/analyze.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/feature-flags.js

+6-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/feature-flags.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/init-action.js

+2-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/init-action.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/analyze.ts

+2-10
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
Feature,
1919
logCodeScanningConfigInCli,
2020
useCodeScanningConfigInCli,
21+
isPythonDependencyInstallationDisabled,
2122
} from "./feature-flags";
2223
import { isScannedLanguage, Language } from "./languages";
2324
import { Logger } from "./logging";
@@ -104,16 +105,7 @@ async function setupPythonExtractor(
104105
return;
105106
}
106107

107-
if (
108-
(await features.getValue(
109-
Feature.DisablePythonDependencyInstallationEnabled,
110-
codeql,
111-
)) ||
112-
(await features.getValue(
113-
Feature.PythonDefaultIsToSkipDependencyInstallationEnabled,
114-
codeql,
115-
))
116-
) {
108+
if (await isPythonDependencyInstallationDisabled(codeql, features)) {
117109
logger.warning(
118110
"We recommend that you remove the CODEQL_PYTHON environment variable from your workflow. This environment variable was originally used to specify a Python executable that included the dependencies of your Python code, however Python analysis no longer uses these dependencies." +
119111
"\nIf you used CODEQL_PYTHON to force the version of Python to analyze as, please use CODEQL_EXTRACTOR_PYTHON_ANALYSIS_VERSION instead, such as 'CODEQL_EXTRACTOR_PYTHON_ANALYSIS_VERSION=2.7' or 'CODEQL_EXTRACTOR_PYTHON_ANALYSIS_VERSION=3.11'.",

src/feature-flags.ts

+16
Original file line numberDiff line numberDiff line change
@@ -484,3 +484,19 @@ export async function logCodeScanningConfigInCli(
484484
);
485485
}
486486
}
487+
488+
export async function isPythonDependencyInstallationDisabled(
489+
codeql: CodeQL,
490+
features: FeatureEnablement,
491+
): Promise<boolean> {
492+
return (
493+
(await features.getValue(
494+
Feature.DisablePythonDependencyInstallationEnabled,
495+
codeql,
496+
)) ||
497+
(await features.getValue(
498+
Feature.PythonDefaultIsToSkipDependencyInstallationEnabled,
499+
codeql,
500+
))
501+
);
502+
}

src/init-action.ts

+7-21
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ import { getGitHubVersion } from "./api-client";
1616
import { CodeQL } from "./codeql";
1717
import * as configUtils from "./config-utils";
1818
import { EnvVar } from "./environment";
19-
import { Feature, Features } from "./feature-flags";
19+
import {
20+
Feature,
21+
Features,
22+
isPythonDependencyInstallationDisabled,
23+
} from "./feature-flags";
2024
import {
2125
checkInstallPython311,
2226
initCodeQL,
@@ -293,16 +297,7 @@ async function run() {
293297
config.languages.includes(Language.python) &&
294298
getRequiredInput("setup-python-dependencies") === "true"
295299
) {
296-
if (
297-
(await features.getValue(
298-
Feature.DisablePythonDependencyInstallationEnabled,
299-
codeql,
300-
)) ||
301-
(await features.getValue(
302-
Feature.PythonDefaultIsToSkipDependencyInstallationEnabled,
303-
codeql,
304-
))
305-
) {
300+
if (await isPythonDependencyInstallationDisabled(codeql, features)) {
306301
logger.info("Skipping python dependency installation");
307302
} else {
308303
try {
@@ -450,16 +445,7 @@ async function run() {
450445
}
451446

452447
// Disable Python dependency extraction if feature flag set
453-
if (
454-
(await features.getValue(
455-
Feature.DisablePythonDependencyInstallationEnabled,
456-
codeql,
457-
)) ||
458-
(await features.getValue(
459-
Feature.PythonDefaultIsToSkipDependencyInstallationEnabled,
460-
codeql,
461-
))
462-
) {
448+
if (await isPythonDependencyInstallationDisabled(codeql, features)) {
463449
core.exportVariable(
464450
"CODEQL_EXTRACTOR_PYTHON_DISABLE_LIBRARY_EXTRACTION",
465451
"true",

0 commit comments

Comments
 (0)