Create helper isPythonDependencyInstallationDisabled
This commit is contained in:
parent
afef25e1e7
commit
2e27b3c56b
9 changed files with 37 additions and 41 deletions
3
lib/analyze.js
generated
3
lib/analyze.js
generated
|
|
@ -56,8 +56,7 @@ async function setupPythonExtractor(logger, features, codeql) {
|
|||
// If CODEQL_PYTHON is not set, no dependencies were installed, so we don't need to do anything
|
||||
return;
|
||||
}
|
||||
if ((await features.getValue(feature_flags_1.Feature.DisablePythonDependencyInstallationEnabled, codeql)) ||
|
||||
(await features.getValue(feature_flags_1.Feature.PythonDefaultIsToSkipDependencyInstallationEnabled, codeql))) {
|
||||
if (await (0, feature_flags_1.isPythonDependencyInstallationDisabled)(codeql, features)) {
|
||||
logger.warning("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." +
|
||||
"\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'.");
|
||||
return;
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
7
lib/feature-flags.js
generated
7
lib/feature-flags.js
generated
|
|
@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.logCodeScanningConfigInCli = exports.useCodeScanningConfigInCli = exports.Features = exports.FEATURE_FLAGS_FILE_NAME = exports.featureConfig = exports.Feature = exports.CODEQL_VERSION_FINE_GRAINED_PARALLELISM = exports.CODEQL_VERSION_BUNDLE_SEMANTICALLY_VERSIONED = void 0;
|
||||
exports.isPythonDependencyInstallationDisabled = exports.logCodeScanningConfigInCli = exports.useCodeScanningConfigInCli = exports.Features = exports.FEATURE_FLAGS_FILE_NAME = exports.featureConfig = exports.Feature = exports.CODEQL_VERSION_FINE_GRAINED_PARALLELISM = exports.CODEQL_VERSION_BUNDLE_SEMANTICALLY_VERSIONED = void 0;
|
||||
const fs = __importStar(require("fs"));
|
||||
const path = __importStar(require("path"));
|
||||
const semver = __importStar(require("semver"));
|
||||
|
|
@ -359,4 +359,9 @@ async function logCodeScanningConfigInCli(codeql, features, logger) {
|
|||
}
|
||||
}
|
||||
exports.logCodeScanningConfigInCli = logCodeScanningConfigInCli;
|
||||
async function isPythonDependencyInstallationDisabled(codeql, features) {
|
||||
return (await features.getValue(Feature.DisablePythonDependencyInstallationEnabled, codeql)) ||
|
||||
(await features.getValue(Feature.PythonDefaultIsToSkipDependencyInstallationEnabled, codeql));
|
||||
}
|
||||
exports.isPythonDependencyInstallationDisabled = isPythonDependencyInstallationDisabled;
|
||||
//# sourceMappingURL=feature-flags.js.map
|
||||
File diff suppressed because one or more lines are too long
6
lib/init-action.js
generated
6
lib/init-action.js
generated
|
|
@ -146,8 +146,7 @@ async function run() {
|
|||
await (0, init_1.checkInstallPython311)(config.languages, codeql);
|
||||
if (config.languages.includes(languages_1.Language.python) &&
|
||||
(0, actions_util_1.getRequiredInput)("setup-python-dependencies") === "true") {
|
||||
if ((await features.getValue(feature_flags_1.Feature.DisablePythonDependencyInstallationEnabled, codeql)) ||
|
||||
(await features.getValue(feature_flags_1.Feature.PythonDefaultIsToSkipDependencyInstallationEnabled, codeql))) {
|
||||
if (await (0, feature_flags_1.isPythonDependencyInstallationDisabled)(codeql, features)) {
|
||||
logger.info("Skipping python dependency installation");
|
||||
}
|
||||
else {
|
||||
|
|
@ -247,8 +246,7 @@ async function run() {
|
|||
}
|
||||
}
|
||||
// Disable Python dependency extraction if feature flag set
|
||||
if ((await features.getValue(feature_flags_1.Feature.DisablePythonDependencyInstallationEnabled, codeql)) ||
|
||||
(await features.getValue(feature_flags_1.Feature.PythonDefaultIsToSkipDependencyInstallationEnabled, codeql))) {
|
||||
if (await (0, feature_flags_1.isPythonDependencyInstallationDisabled)(codeql, features)) {
|
||||
core.exportVariable("CODEQL_EXTRACTOR_PYTHON_DISABLE_LIBRARY_EXTRACTION", "true");
|
||||
}
|
||||
else {
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -18,6 +18,7 @@ import {
|
|||
Feature,
|
||||
logCodeScanningConfigInCli,
|
||||
useCodeScanningConfigInCli,
|
||||
isPythonDependencyInstallationDisabled,
|
||||
} from "./feature-flags";
|
||||
import { isScannedLanguage, Language } from "./languages";
|
||||
import { Logger } from "./logging";
|
||||
|
|
@ -104,16 +105,7 @@ async function setupPythonExtractor(
|
|||
return;
|
||||
}
|
||||
|
||||
if (
|
||||
(await features.getValue(
|
||||
Feature.DisablePythonDependencyInstallationEnabled,
|
||||
codeql,
|
||||
)) ||
|
||||
(await features.getValue(
|
||||
Feature.PythonDefaultIsToSkipDependencyInstallationEnabled,
|
||||
codeql,
|
||||
))
|
||||
) {
|
||||
if (await isPythonDependencyInstallationDisabled(codeql, features)) {
|
||||
logger.warning(
|
||||
"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." +
|
||||
"\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'.",
|
||||
|
|
|
|||
|
|
@ -484,3 +484,19 @@ export async function logCodeScanningConfigInCli(
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
export async function isPythonDependencyInstallationDisabled(
|
||||
codeql: CodeQL,
|
||||
features: FeatureEnablement,
|
||||
): Promise<boolean> {
|
||||
return (
|
||||
(await features.getValue(
|
||||
Feature.DisablePythonDependencyInstallationEnabled,
|
||||
codeql,
|
||||
)) ||
|
||||
(await features.getValue(
|
||||
Feature.PythonDefaultIsToSkipDependencyInstallationEnabled,
|
||||
codeql,
|
||||
))
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,11 @@ import { getGitHubVersion } from "./api-client";
|
|||
import { CodeQL } from "./codeql";
|
||||
import * as configUtils from "./config-utils";
|
||||
import { EnvVar } from "./environment";
|
||||
import { Feature, Features } from "./feature-flags";
|
||||
import {
|
||||
Feature,
|
||||
Features,
|
||||
isPythonDependencyInstallationDisabled,
|
||||
} from "./feature-flags";
|
||||
import {
|
||||
checkInstallPython311,
|
||||
initCodeQL,
|
||||
|
|
@ -293,16 +297,7 @@ async function run() {
|
|||
config.languages.includes(Language.python) &&
|
||||
getRequiredInput("setup-python-dependencies") === "true"
|
||||
) {
|
||||
if (
|
||||
(await features.getValue(
|
||||
Feature.DisablePythonDependencyInstallationEnabled,
|
||||
codeql,
|
||||
)) ||
|
||||
(await features.getValue(
|
||||
Feature.PythonDefaultIsToSkipDependencyInstallationEnabled,
|
||||
codeql,
|
||||
))
|
||||
) {
|
||||
if (await isPythonDependencyInstallationDisabled(codeql, features)) {
|
||||
logger.info("Skipping python dependency installation");
|
||||
} else {
|
||||
try {
|
||||
|
|
@ -450,16 +445,7 @@ async function run() {
|
|||
}
|
||||
|
||||
// Disable Python dependency extraction if feature flag set
|
||||
if (
|
||||
(await features.getValue(
|
||||
Feature.DisablePythonDependencyInstallationEnabled,
|
||||
codeql,
|
||||
)) ||
|
||||
(await features.getValue(
|
||||
Feature.PythonDefaultIsToSkipDependencyInstallationEnabled,
|
||||
codeql,
|
||||
))
|
||||
) {
|
||||
if (await isPythonDependencyInstallationDisabled(codeql, features)) {
|
||||
core.exportVariable(
|
||||
"CODEQL_EXTRACTOR_PYTHON_DISABLE_LIBRARY_EXTRACTION",
|
||||
"true",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue