Honor the Lua tracer FF for database trace-command invocations for scanned languages.
In theory, a scanned language will not setup the build tracer, and so shouldn't care about lua versus legacy tracing. However, `go` is a special case where the autobuilder runs under the build tracer, that then gets disabled immediately again, unless a special environment variable is used. Therefore, we need to thread through the feature flag to this `database trace-command` invocation. For other scanned languages, this should be a no-op, as no tracing is ever set up.
This commit is contained in:
parent
47bcabd3e8
commit
f422a50448
12 changed files with 85 additions and 23 deletions
|
|
@ -12,9 +12,11 @@ import {
|
|||
runQueries,
|
||||
runFinalize,
|
||||
} from "./analyze";
|
||||
import { getGitHubVersionActionsOnly } from "./api-client";
|
||||
import { CODEQL_VERSION_NEW_TRACING, getCodeQL } from "./codeql";
|
||||
import { Config, getConfig } from "./config-utils";
|
||||
import { uploadDatabases } from "./database-upload";
|
||||
import { GitHubFeatureFlags } from "./feature-flags";
|
||||
import { getActionsLogger } from "./logging";
|
||||
import { parseRepositoryNwo } from "./repository";
|
||||
import * as upload_lib from "./upload-lib";
|
||||
|
|
@ -112,7 +114,16 @@ async function run() {
|
|||
util.getRequiredEnvParam("GITHUB_REPOSITORY")
|
||||
);
|
||||
|
||||
await runFinalize(outputDir, threads, memory, config, logger);
|
||||
const gitHubVersion = await getGitHubVersionActionsOnly();
|
||||
|
||||
const featureFlags = new GitHubFeatureFlags(
|
||||
gitHubVersion,
|
||||
apiDetails,
|
||||
repositoryNwo,
|
||||
logger
|
||||
);
|
||||
|
||||
await runFinalize(outputDir, threads, memory, config, logger, featureFlags);
|
||||
if (actionsUtil.getRequiredInput("skip-queries") !== "true") {
|
||||
runStats = await runQueries(
|
||||
outputDir,
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import {
|
|||
} from "./codeql";
|
||||
import * as configUtils from "./config-utils";
|
||||
import { countLoc } from "./count-loc";
|
||||
import { FeatureFlags } from "./feature-flags";
|
||||
import { isScannedLanguage, Language } from "./languages";
|
||||
import { Logger } from "./logging";
|
||||
import * as sharedEnv from "./shared-environment";
|
||||
|
|
@ -116,7 +117,8 @@ async function setupPythonExtractor(logger: Logger) {
|
|||
|
||||
async function createdDBForScannedLanguages(
|
||||
config: configUtils.Config,
|
||||
logger: Logger
|
||||
logger: Logger,
|
||||
featureFlags: FeatureFlags
|
||||
) {
|
||||
// Insert the LGTM_INDEX_X env vars at this point so they are set when
|
||||
// we extract any scanned languages.
|
||||
|
|
@ -136,7 +138,8 @@ async function createdDBForScannedLanguages(
|
|||
|
||||
await codeql.extractScannedLanguage(
|
||||
util.getCodeQLDatabasePath(config, language),
|
||||
language
|
||||
language,
|
||||
featureFlags
|
||||
);
|
||||
logger.endGroup();
|
||||
}
|
||||
|
|
@ -166,9 +169,10 @@ async function finalizeDatabaseCreation(
|
|||
config: configUtils.Config,
|
||||
threadsFlag: string,
|
||||
memoryFlag: string,
|
||||
logger: Logger
|
||||
logger: Logger,
|
||||
featureFlags: FeatureFlags
|
||||
) {
|
||||
await createdDBForScannedLanguages(config, logger);
|
||||
await createdDBForScannedLanguages(config, logger, featureFlags);
|
||||
|
||||
const codeql = await getCodeQL(config.codeQLCmd);
|
||||
for (const language of config.languages) {
|
||||
|
|
@ -425,7 +429,8 @@ export async function runFinalize(
|
|||
threadsFlag: string,
|
||||
memoryFlag: string,
|
||||
config: configUtils.Config,
|
||||
logger: Logger
|
||||
logger: Logger,
|
||||
featureFlags: FeatureFlags
|
||||
) {
|
||||
const codeql = await getCodeQL(config.codeQLCmd);
|
||||
if (await util.codeQlVersionAbove(codeql, CODEQL_VERSION_NEW_TRACING)) {
|
||||
|
|
@ -445,7 +450,13 @@ export async function runFinalize(
|
|||
}
|
||||
await fs.promises.mkdir(outputDir, { recursive: true });
|
||||
|
||||
await finalizeDatabaseCreation(config, threadsFlag, memoryFlag, logger);
|
||||
await finalizeDatabaseCreation(
|
||||
config,
|
||||
threadsFlag,
|
||||
memoryFlag,
|
||||
logger,
|
||||
featureFlags
|
||||
);
|
||||
}
|
||||
|
||||
export async function runCleanup(
|
||||
|
|
|
|||
|
|
@ -95,7 +95,11 @@ export interface CodeQL {
|
|||
* Extract code for a scanned language using 'codeql database trace-command'
|
||||
* and running the language extractor.
|
||||
*/
|
||||
extractScannedLanguage(database: string, language: Language): Promise<void>;
|
||||
extractScannedLanguage(
|
||||
database: string,
|
||||
language: Language,
|
||||
featureFlags: FeatureFlags
|
||||
): Promise<void>;
|
||||
/**
|
||||
* Finalize a database using 'codeql database finalize'.
|
||||
*/
|
||||
|
|
@ -789,7 +793,11 @@ async function getCodeQLForCmd(
|
|||
|
||||
await runTool(autobuildCmd);
|
||||
},
|
||||
async extractScannedLanguage(databasePath: string, language: Language) {
|
||||
async extractScannedLanguage(
|
||||
databasePath: string,
|
||||
language: Language,
|
||||
featureFlags: FeatureFlags
|
||||
) {
|
||||
// Get extractor location
|
||||
let extractorPath = "";
|
||||
await new toolrunner.ToolRunner(
|
||||
|
|
@ -821,6 +829,16 @@ async function getCodeQLForCmd(
|
|||
"tools",
|
||||
`autobuild${ext}`
|
||||
);
|
||||
const extraArgs: string[] = [];
|
||||
if (
|
||||
await util.codeQlVersionAbove(this, CODEQL_VERSION_LUA_TRACER_CONFIG)
|
||||
) {
|
||||
if (await featureFlags.getValue(FeatureFlag.LuaTracerConfigEnabled)) {
|
||||
extraArgs.push("--internal-use-lua-tracing");
|
||||
} else {
|
||||
extraArgs.push("--no-internal-use-lua-tracing");
|
||||
}
|
||||
}
|
||||
|
||||
// Run trace command
|
||||
await toolrunnerErrorCatcher(
|
||||
|
|
@ -828,6 +846,7 @@ async function getCodeQLForCmd(
|
|||
[
|
||||
"database",
|
||||
"trace-command",
|
||||
...extraArgs,
|
||||
...getExtraOptionsFromEnv(["database", "trace-command"]),
|
||||
databasePath,
|
||||
"--",
|
||||
|
|
|
|||
|
|
@ -501,7 +501,14 @@ program
|
|||
logger
|
||||
);
|
||||
const memory = getMemoryFlag(cmd.ram || initEnv["CODEQL_RAM"]);
|
||||
await runFinalize(outputDir, threads, memory, config, logger);
|
||||
await runFinalize(
|
||||
outputDir,
|
||||
threads,
|
||||
memory,
|
||||
config,
|
||||
logger,
|
||||
createFeatureFlags([])
|
||||
);
|
||||
await runQueries(
|
||||
outputDir,
|
||||
memory,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue