Enable direct tracing the autobuild build mode by default

This commit is contained in:
Henry Mercer 2024-06-26 19:38:13 +01:00
parent 9b7c22c3b3
commit a52b209ec8
33 changed files with 84 additions and 130 deletions

28
lib/tracer-config.js generated
View file

@ -29,15 +29,22 @@ exports.getTracerConfigForCluster = getTracerConfigForCluster;
exports.getCombinedTracerConfig = getCombinedTracerConfig;
const fs = __importStar(require("fs"));
const path = __importStar(require("path"));
const feature_flags_1 = require("./feature-flags");
const languages_1 = require("./languages");
const tools_features_1 = require("./tools-features");
const util_1 = require("./util");
async function shouldEnableIndirectTracing(codeql, config, features) {
return ((!config.buildMode ||
config.buildMode === util_1.BuildMode.Manual ||
!(await features.getValue(feature_flags_1.Feature.AutobuildDirectTracing, codeql))) &&
config.languages.some((l) => (0, languages_1.isTracedLanguage)(l)));
async function shouldEnableIndirectTracing(codeql, config) {
// We don't need to trace build mode none, or languages which unconditionally don't need tracing.
if (config.buildMode === util_1.BuildMode.None) {
return false;
}
// If the CLI supports `trace-command` with a `--build-mode`, we'll use direct tracing instead of
// indirect tracing.
if (config.buildMode === util_1.BuildMode.Autobuild &&
(await codeql.supportsFeature(tools_features_1.ToolsFeature.TraceCommandUseBuildMode))) {
return false;
}
// Otherwise, use direct tracing if any of the languages need to be traced.
return config.languages.some((l) => (0, languages_1.isTracedLanguage)(l));
}
/**
* Delete variables as specified by the end-tracing script
@ -48,8 +55,8 @@ async function shouldEnableIndirectTracing(codeql, config, features) {
*
* However, it will stop tracing for all steps past the current build step.
*/
async function endTracingForCluster(codeql, config, logger, features) {
if (!(await shouldEnableIndirectTracing(codeql, config, features)))
async function endTracingForCluster(codeql, config, logger) {
if (!(await shouldEnableIndirectTracing(codeql, config)))
return;
logger.info("Unsetting build tracing environment variables. Subsequent steps of this job will not be traced.");
const envVariablesFile = path.resolve(config.dbLocation, "temp/tracingEnvironment/end-tracing.json");
@ -77,9 +84,10 @@ async function getTracerConfigForCluster(config) {
env: tracingEnvVariables,
};
}
async function getCombinedTracerConfig(codeql, config, features) {
if (!(await shouldEnableIndirectTracing(codeql, config, features)))
async function getCombinedTracerConfig(codeql, config) {
if (!(await shouldEnableIndirectTracing(codeql, config))) {
return undefined;
}
const mainTracerConfig = await getTracerConfigForCluster(config);
// If the CLI doesn't yet support setting the CODEQL_RUNNER environment variable to
// the runner executable path, we set it here in the Action.