C++: introduce automatic installation of dependencies in the autobuilder
This introduces the possibility to automatically install dependencies when running the C++ autobuilder on an Ubuntu runner, that will be available with upcoming version 2.15.0. An experimental `cpp-autoinstall-dependencies` input is added to the `autobuild` action. When not set, the default is driven by a feature flag.
This commit is contained in:
parent
8e0b1c74b1
commit
c4c06786f2
7 changed files with 145 additions and 4 deletions
64
lib/autobuild.js
generated
64
lib/autobuild.js
generated
|
|
@ -1,8 +1,37 @@
|
|||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.runAutobuild = exports.determineAutobuildLanguages = void 0;
|
||||
const core = __importStar(require("@actions/core"));
|
||||
const actions_util_1 = require("./actions-util");
|
||||
const api_client_1 = require("./api-client");
|
||||
const codeql_1 = require("./codeql");
|
||||
const feature_flags_1 = require("./feature-flags");
|
||||
const languages_1 = require("./languages");
|
||||
const repository_1 = require("./repository");
|
||||
const util_1 = require("./util");
|
||||
async function determineAutobuildLanguages(config, logger) {
|
||||
// Attempt to find a language to autobuild
|
||||
// We want pick the dominant language in the repo from the ones we're able to build
|
||||
|
|
@ -70,9 +99,44 @@ async function determineAutobuildLanguages(config, logger) {
|
|||
return languages;
|
||||
}
|
||||
exports.determineAutobuildLanguages = determineAutobuildLanguages;
|
||||
async function setupCppAutobuild(codeql, logger) {
|
||||
const envVar = "CODEQL_EXTRACTOR_CPP_AUTOINSTALL_DEPENDENCIES";
|
||||
const actionInput = (0, actions_util_1.getOptionalInput)("cpp-autoinstall-dependencies");
|
||||
const featureName = "C++ automatic installation of dependencies";
|
||||
if (actionInput === "true") {
|
||||
if (!(await (0, util_1.codeQlVersionAbove)(codeql, "2.15.0"))) {
|
||||
logger.warning(`${featureName} was explicitly requested but is only available starting from CodeQL version 2.15.0, disabling it`);
|
||||
core.exportVariable(envVar, "false");
|
||||
}
|
||||
else {
|
||||
logger.info(`${actionInput === "true" ? "Enabling" : "Disabling"} ${featureName} explicitly requested`);
|
||||
core.exportVariable(envVar, actionInput);
|
||||
}
|
||||
}
|
||||
else if (process.env["RUNNER_ENVIRONMENT"] === "self-hosted") {
|
||||
logger.info(`Disabling ${featureName} which is the default for self-hosted runners`);
|
||||
core.exportVariable(envVar, "false");
|
||||
}
|
||||
else {
|
||||
const gitHubVersion = await (0, api_client_1.getGitHubVersion)();
|
||||
const repositoryNwo = (0, repository_1.parseRepositoryNwo)((0, util_1.getRequiredEnvParam)("GITHUB_REPOSITORY"));
|
||||
const features = new feature_flags_1.Features(gitHubVersion, repositoryNwo, (0, actions_util_1.getTemporaryDirectory)(), logger);
|
||||
if (await features.getValue(feature_flags_1.Feature.CppDependencyInstallation, codeql)) {
|
||||
logger.info(`Enabling ${featureName}`);
|
||||
core.exportVariable(envVar, "true");
|
||||
}
|
||||
else {
|
||||
logger.info(`Disabling ${featureName}`);
|
||||
core.exportVariable(envVar, "false");
|
||||
}
|
||||
}
|
||||
}
|
||||
async function runAutobuild(language, config, logger) {
|
||||
logger.startGroup(`Attempting to automatically build ${language} code`);
|
||||
const codeQL = await (0, codeql_1.getCodeQL)(config.codeQLCmd);
|
||||
if (language === languages_1.Language.cpp) {
|
||||
await setupCppAutobuild(codeQL, logger);
|
||||
}
|
||||
await codeQL.runAutobuild(language);
|
||||
logger.endGroup();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue