Skip to content

Commit a533ec6

Browse files
committed
Merge branch 'main' into henrymercer/remove-action-config-parsing
2 parents d7437a2 + 08ae9bf commit a533ec6

19 files changed

+74
-248
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Note that the only difference between `v2` and `v3` of the CodeQL Action is the
66

77
## [UNRELEASED]
88

9+
- We are rolling out a feature in January 2024 that will disable Python dependency installation by default for all users. This improves the speed of analysis while having only a very minor impact on results. You can override this behavior by setting `CODEQL_ACTION_DISABLE_PYTHON_DEPENDENCY_INSTALLATION=false` in your workflow, however we plan to remove this ability in future versions of the CodeQL Action. [#2031](https://github.com/github/codeql-action/pull/2031)
910
- The CodeQL Action now requires CodeQL version 2.11.6 or later. For more information, see [the corresponding changelog entry for CodeQL Action version 2.22.7](#2227---16-nov-2023). [#2009](https://github.com/github/codeql-action/pull/2009)
1011

1112
## 3.22.12 - 22 Dec 2023

lib/analyze.js

+1-1
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

+16-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

+7-2
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

+6-7
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ import {
1212
getCodeQL,
1313
} from "./codeql";
1414
import * as configUtils from "./config-utils";
15-
import { FeatureEnablement, Feature } from "./feature-flags";
15+
import {
16+
FeatureEnablement,
17+
Feature,
18+
isPythonDependencyInstallationDisabled,
19+
} from "./feature-flags";
1620
import { isScannedLanguage, Language } from "./languages";
1721
import { Logger } from "./logging";
1822
import { DatabaseCreationTimings, EventReport } from "./status-report";
@@ -122,12 +126,7 @@ async function setupPythonExtractor(
122126
return;
123127
}
124128

125-
if (
126-
await features.getValue(
127-
Feature.DisablePythonDependencyInstallationEnabled,
128-
codeql,
129-
)
130-
) {
129+
if (await isPythonDependencyInstallationDisabled(codeql, features)) {
131130
logger.warning(
132131
"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." +
133132
"\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

+26
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ export enum Feature {
4848
CppDependencyInstallation = "cpp_dependency_installation_enabled",
4949
DisableKotlinAnalysisEnabled = "disable_kotlin_analysis_enabled",
5050
DisablePythonDependencyInstallationEnabled = "disable_python_dependency_installation_enabled",
51+
PythonDefaultIsToSkipDependencyInstallationEnabled = "python_default_is_to_skip_dependency_installation_enabled",
5152
EvaluatorFineGrainedParallelismEnabled = "evaluator_fine_grained_parallelism_enabled",
5253
ExportDiagnosticsEnabled = "export_diagnostics_enabled",
5354
QaTelemetryEnabled = "qa_telemetry_enabled",
@@ -97,6 +98,15 @@ export const featureConfig: Record<
9798
minimumVersion: undefined,
9899
defaultValue: false,
99100
},
101+
[Feature.PythonDefaultIsToSkipDependencyInstallationEnabled]: {
102+
// we can reuse the same environment variable as above. If someone has set it to
103+
// `true` in their workflow this means dependencies are not installed, setting it to
104+
// `false` means dependencies _will_ be installed. The same semantics are applied
105+
// here!
106+
envVar: "CODEQL_ACTION_DISABLE_PYTHON_DEPENDENCY_INSTALLATION",
107+
minimumVersion: "2.16.0",
108+
defaultValue: false,
109+
},
100110
};
101111

102112
/**
@@ -441,3 +451,19 @@ class GitHubFeatureFlags {
441451
}
442452
}
443453
}
454+
455+
export async function isPythonDependencyInstallationDisabled(
456+
codeql: CodeQL,
457+
features: FeatureEnablement,
458+
): Promise<boolean> {
459+
return (
460+
(await features.getValue(
461+
Feature.DisablePythonDependencyInstallationEnabled,
462+
codeql,
463+
)) ||
464+
(await features.getValue(
465+
Feature.PythonDefaultIsToSkipDependencyInstallationEnabled,
466+
codeql,
467+
))
468+
);
469+
}

src/init-action.ts

+14-13
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,
@@ -289,12 +293,7 @@ async function run() {
289293
config.languages.includes(Language.python) &&
290294
getRequiredInput("setup-python-dependencies") === "true"
291295
) {
292-
if (
293-
await features.getValue(
294-
Feature.DisablePythonDependencyInstallationEnabled,
295-
codeql,
296-
)
297-
) {
296+
if (await isPythonDependencyInstallationDisabled(codeql, features)) {
298297
logger.info("Skipping python dependency installation");
299298
} else {
300299
try {
@@ -442,16 +441,18 @@ async function run() {
442441
}
443442

444443
// Disable Python dependency extraction if feature flag set
445-
if (
446-
await features.getValue(
447-
Feature.DisablePythonDependencyInstallationEnabled,
448-
codeql,
449-
)
450-
) {
444+
if (await isPythonDependencyInstallationDisabled(codeql, features)) {
451445
core.exportVariable(
452446
"CODEQL_EXTRACTOR_PYTHON_DISABLE_LIBRARY_EXTRACTION",
453447
"true",
454448
);
449+
} else {
450+
// From 2.16.0 the default for the python extractor is to not perform any library
451+
// extraction, so we need to set this flag to enable it.
452+
core.exportVariable(
453+
"CODEQL_EXTRACTOR_PYTHON_FORCE_ENABLE_LIBRARY_EXTRACTION_UNTIL_2_17_0",
454+
"true",
455+
);
455456
}
456457

457458
const sourceRoot = path.resolve(

tests/ml-powered-queries-repo/add-note.js

-21
This file was deleted.

tests/ml-powered-queries-repo/app.js

-68
This file was deleted.

tests/ml-powered-queries-repo/index.js

-7
This file was deleted.

tests/ml-powered-queries-repo/logger.js

-5
This file was deleted.

tests/ml-powered-queries-repo/models/note.js

-8
This file was deleted.

tests/ml-powered-queries-repo/models/user.js

-6
This file was deleted.

tests/ml-powered-queries-repo/notes-api.js

-44
This file was deleted.

0 commit comments

Comments
 (0)