GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — C++: introduce automatic installation of dependencies in the autobuilder · github/codeql-action@1dc6288

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • autobuild
    • action.yml
  • lib
    • autobuild.js.map
    • autobuild.js
    • feature-flags.js.map
    • feature-flags.js
  • src
    • autobuild.ts
    • feature-flags.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎autobuild/action.yml‎

Copy file name to clipboardExpand all lines: autobuild/action.yml
+11Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,17 @@ inputs:
1212
working directory. If this input is not set, the autobuilder runs with
1313
$GITHUB_WORKSPACE as its working directory.
1414
required: false
15+
cpp-autoinstall-dependencies:
16+
description: >-
17+
Experimental input, the API may change in the future.
18+
Set to true to enable trying to automatically detect and install
19+
dependencies when running the C/C++ autobuilder, set to anything else
20+
to explicitly disable it. This only works when running on Ubuntu and
21+
is automatically disabled otherwise. If this input is not set the
22+
default is currently driven by the cpp_dependency_installation_enabled
23+
feature flag or the CODEQL_CPP_DEPENDENCY_INSTALLATION environment
24+
variable.
25+
required: false
1526
runs:
1627
using: 'node16'
1728
main: '../lib/autobuild-action.js'
Collapse file

‎lib/autobuild.js‎

Copy file name to clipboardExpand all lines: lib/autobuild.js
+64Lines changed: 64 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Collapse file

‎lib/autobuild.js.map‎

Copy file name to clipboardExpand all lines: lib/autobuild.js.map
+1-1Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Collapse file

‎lib/feature-flags.js‎

Copy file name to clipboardExpand all lines: lib/feature-flags.js
+6Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Collapse file

‎lib/feature-flags.js.map‎

Copy file name to clipboardExpand all lines: lib/feature-flags.js.map
+1-1Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Collapse file

‎src/autobuild.ts‎

Copy file name to clipboardExpand all lines: src/autobuild.ts
+56-2Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
1-
import { getCodeQL } from "./codeql";
1+
import * as core from "@actions/core";
2+
3+
import { getOptionalInput, getTemporaryDirectory } from "./actions-util";
4+
import { getGitHubVersion } from "./api-client";
5+
import { CodeQL, getCodeQL } from "./codeql";
26
import * as configUtils from "./config-utils";
3-
import { Language, isTracedLanguage } from "./languages";
7+
import { Feature, Features } from "./feature-flags";
8+
import { isTracedLanguage, Language } from "./languages";
49
import { Logger } from "./logging";
10+
import { parseRepositoryNwo } from "./repository";
11+
import { codeQlVersionAbove, getRequiredEnvParam } from "./util";
512

613
export async function determineAutobuildLanguages(
714
config: configUtils.Config,
@@ -91,13 +98,60 @@ export async function determineAutobuildLanguages(
9198
return languages;
9299
}
93100

101+
async function setupCppAutobuild(codeql: CodeQL, logger: Logger) {
102+
const envVar = "CODEQL_EXTRACTOR_CPP_AUTOINSTALL_DEPENDENCIES";
103+
const actionInput = getOptionalInput("cpp-autoinstall-dependencies");
104+
const featureName = "C++ automatic installation of dependencies";
105+
if (actionInput === "true") {
106+
if (!(await codeQlVersionAbove(codeql, "2.15.0"))) {
107+
logger.warning(
108+
`${featureName} was explicitly requested but is only available starting from CodeQL version 2.15.0, disabling it`,
109+
);
110+
core.exportVariable(envVar, "false");
111+
} else {
112+
logger.info(
113+
`${
114+
actionInput === "true" ? "Enabling" : "Disabling"
115+
} ${featureName} explicitly requested`,
116+
);
117+
core.exportVariable(envVar, actionInput);
118+
}
119+
} else if (process.env["RUNNER_ENVIRONMENT"] === "self-hosted") {
120+
logger.info(
121+
`Disabling ${featureName} which is the default for self-hosted runners`,
122+
);
123+
core.exportVariable(envVar, "false");
124+
} else {
125+
const gitHubVersion = await getGitHubVersion();
126+
const repositoryNwo = parseRepositoryNwo(
127+
getRequiredEnvParam("GITHUB_REPOSITORY"),
128+
);
129+
const features = new Features(
130+
gitHubVersion,
131+
repositoryNwo,
132+
getTemporaryDirectory(),
133+
logger,
134+
);
135+
if (await features.getValue(Feature.CppDependencyInstallation, codeql)) {
136+
logger.info(`Enabling ${featureName}`);
137+
core.exportVariable(envVar, "true");
138+
} else {
139+
logger.info(`Disabling ${featureName}`);
140+
core.exportVariable(envVar, "false");
141+
}
142+
}
143+
}
144+
94145
export async function runAutobuild(
95146
language: Language,
96147
config: configUtils.Config,
97148
logger: Logger,
98149
) {
99150
logger.startGroup(`Attempting to automatically build ${language} code`);
100151
const codeQL = await getCodeQL(config.codeQLCmd);
152+
if (language === Language.cpp) {
153+
await setupCppAutobuild(codeQL, logger);
154+
}
101155
await codeQL.runAutobuild(language);
102156
logger.endGroup();
103157
}
Collapse file

‎src/feature-flags.ts‎

Copy file name to clipboardExpand all lines: src/feature-flags.ts
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ export enum Feature {
5151
AnalysisSummaryV2Enabled = "analysis_summary_v2_enabled",
5252
CliConfigFileEnabled = "cli_config_file_enabled",
5353
CodeqlJavaLombokEnabled = "codeql_java_lombok_enabled",
54+
CppDependencyInstallation = "cpp_dependency_installation_enabled",
5455
DisableKotlinAnalysisEnabled = "disable_kotlin_analysis_enabled",
5556
DisablePythonDependencyInstallationEnabled = "disable_python_dependency_installation_enabled",
5657
EvaluatorIntraLayerParallelismEnabled = "evaluator_intra_layer_parallelism_enabled",
@@ -74,6 +75,11 @@ export const featureConfig: Record<
7475
minimumVersion: "2.14.0",
7576
defaultValue: false,
7677
},
78+
[Feature.CppDependencyInstallation]: {
79+
envVar: "CODEQL_CPP_DEPENDENCY_INSTALLATION",
80+
minimumVersion: "2.15.0",
81+
defaultValue: false,
82+
},
7783
[Feature.DisableKotlinAnalysisEnabled]: {
7884
envVar: "CODEQL_DISABLE_KOTLIN_ANALYSIS",
7985
minimumVersion: undefined,

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.