mirror of
https://github.com/github/codeql-action.git
synced 2026-05-07 14:20:19 +00:00
Remove Go extraction reconciliation feature flag
This commit is contained in:
+4
-15
@@ -19,7 +19,7 @@ import { runAutobuild } from "./autobuild";
|
||||
import { getCodeQL } from "./codeql";
|
||||
import { Config, getConfig } from "./config-utils";
|
||||
import { uploadDatabases } from "./database-upload";
|
||||
import { FeatureEnablement, Features } from "./feature-flags";
|
||||
import { Features } from "./feature-flags";
|
||||
import { Language } from "./languages";
|
||||
import { getActionsLogger, Logger } from "./logging";
|
||||
import { parseRepositoryNwo } from "./repository";
|
||||
@@ -138,20 +138,10 @@ function doesGoExtractionOutputExist(config: Config): boolean {
|
||||
* - We approximate whether manual build steps are present by looking at
|
||||
* whether any extraction output already exists for Go.
|
||||
*/
|
||||
async function runAutobuildIfLegacyGoWorkflow(
|
||||
config: Config,
|
||||
featureEnablement: FeatureEnablement,
|
||||
logger: Logger
|
||||
) {
|
||||
async function runAutobuildIfLegacyGoWorkflow(config: Config, logger: Logger) {
|
||||
if (!config.languages.includes(Language.go)) {
|
||||
return;
|
||||
}
|
||||
if (!(await util.isGoExtractionReconciliationEnabled(featureEnablement))) {
|
||||
logger.debug(
|
||||
"Won't run Go autobuild since Go extraction reconciliation is not enabled."
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (process.env[util.DID_AUTOBUILD_GO_ENV_VAR_NAME] === "true") {
|
||||
// This log line is info level while Go extraction reconciliation is in beta.
|
||||
// We will make it debug level once Go extraction reconciliation is GA.
|
||||
@@ -235,15 +225,14 @@ async function run() {
|
||||
logger
|
||||
);
|
||||
|
||||
await runAutobuildIfLegacyGoWorkflow(config, features, logger);
|
||||
await runAutobuildIfLegacyGoWorkflow(config, logger);
|
||||
|
||||
dbCreationTimings = await runFinalize(
|
||||
outputDir,
|
||||
threads,
|
||||
memory,
|
||||
config,
|
||||
logger,
|
||||
features
|
||||
logger
|
||||
);
|
||||
|
||||
if (actionsUtil.getRequiredInput("skip-queries") !== "true") {
|
||||
|
||||
+7
-19
@@ -121,8 +121,7 @@ async function setupPythonExtractor(logger: Logger) {
|
||||
export async function createdDBForScannedLanguages(
|
||||
codeql: CodeQL,
|
||||
config: configUtils.Config,
|
||||
logger: Logger,
|
||||
featureEnablement: FeatureEnablement
|
||||
logger: Logger
|
||||
) {
|
||||
// Insert the LGTM_INDEX_X env vars at this point so they are set when
|
||||
// we extract any scanned languages.
|
||||
@@ -130,11 +129,7 @@ export async function createdDBForScannedLanguages(
|
||||
|
||||
for (const language of config.languages) {
|
||||
if (
|
||||
isScannedLanguage(
|
||||
language,
|
||||
await util.isGoExtractionReconciliationEnabled(featureEnablement),
|
||||
logger
|
||||
) &&
|
||||
isScannedLanguage(language, logger) &&
|
||||
!dbIsFinalized(config, language, logger)
|
||||
) {
|
||||
logger.startGroup(`Extracting ${language}`);
|
||||
@@ -172,13 +167,12 @@ async function finalizeDatabaseCreation(
|
||||
config: configUtils.Config,
|
||||
threadsFlag: string,
|
||||
memoryFlag: string,
|
||||
logger: Logger,
|
||||
featureEnablement: FeatureEnablement
|
||||
logger: Logger
|
||||
): Promise<DatabaseCreationTimings> {
|
||||
const codeql = await getCodeQL(config.codeQLCmd);
|
||||
|
||||
const extractionStart = performance.now();
|
||||
await createdDBForScannedLanguages(codeql, config, logger, featureEnablement);
|
||||
await createdDBForScannedLanguages(codeql, config, logger);
|
||||
const extractionTime = performance.now() - extractionStart;
|
||||
|
||||
const trapImportStart = performance.now();
|
||||
@@ -500,8 +494,7 @@ export async function runFinalize(
|
||||
threadsFlag: string,
|
||||
memoryFlag: string,
|
||||
config: configUtils.Config,
|
||||
logger: Logger,
|
||||
featureEnablement: FeatureEnablement
|
||||
logger: Logger
|
||||
): Promise<DatabaseCreationTimings> {
|
||||
try {
|
||||
await del(outputDir, { force: true });
|
||||
@@ -516,8 +509,7 @@ export async function runFinalize(
|
||||
config,
|
||||
threadsFlag,
|
||||
memoryFlag,
|
||||
logger,
|
||||
featureEnablement
|
||||
logger
|
||||
);
|
||||
|
||||
const codeql = await getCodeQL(config.codeQLCmd);
|
||||
@@ -528,11 +520,7 @@ export async function runFinalize(
|
||||
// step.
|
||||
if (await util.codeQlVersionAbove(codeql, CODEQL_VERSION_NEW_TRACING)) {
|
||||
// Delete variables as specified by the end-tracing script
|
||||
await endTracingForCluster(
|
||||
config,
|
||||
await util.isGoExtractionReconciliationEnabled(featureEnablement),
|
||||
logger
|
||||
);
|
||||
await endTracingForCluster(config, logger);
|
||||
} else {
|
||||
// Delete the tracer config env var to avoid tracing ourselves
|
||||
delete process.env[sharedEnv.ODASA_TRACER_CONFIGURATION];
|
||||
|
||||
+2
-12
@@ -8,18 +8,15 @@ import {
|
||||
sendStatusReport,
|
||||
StatusReportBase,
|
||||
} from "./actions-util";
|
||||
import { getApiDetails, getGitHubVersionActionsOnly } from "./api-client";
|
||||
import { getGitHubVersionActionsOnly } from "./api-client";
|
||||
import { determineAutobuildLanguages, runAutobuild } from "./autobuild";
|
||||
import * as configUtils from "./config-utils";
|
||||
import { Features } from "./feature-flags";
|
||||
import { Language } from "./languages";
|
||||
import { getActionsLogger } from "./logging";
|
||||
import { parseRepositoryNwo } from "./repository";
|
||||
import {
|
||||
DID_AUTOBUILD_GO_ENV_VAR_NAME,
|
||||
checkActionVersion,
|
||||
checkGitHubVersionInRange,
|
||||
getRequiredEnvParam,
|
||||
initializeEnvironment,
|
||||
Mode,
|
||||
} from "./util";
|
||||
@@ -76,13 +73,6 @@ async function run() {
|
||||
const gitHubVersion = await getGitHubVersionActionsOnly();
|
||||
checkGitHubVersionInRange(gitHubVersion, logger, Mode.actions);
|
||||
|
||||
const features = new Features(
|
||||
gitHubVersion,
|
||||
getApiDetails(),
|
||||
parseRepositoryNwo(getRequiredEnvParam("GITHUB_REPOSITORY")),
|
||||
logger
|
||||
);
|
||||
|
||||
const config = await configUtils.getConfig(getTemporaryDirectory(), logger);
|
||||
if (config === undefined) {
|
||||
throw new Error(
|
||||
@@ -90,7 +80,7 @@ async function run() {
|
||||
);
|
||||
}
|
||||
|
||||
languages = await determineAutobuildLanguages(config, features, logger);
|
||||
languages = await determineAutobuildLanguages(config, logger);
|
||||
if (languages !== undefined) {
|
||||
const workingDirectory = getOptionalInput("working-directory");
|
||||
if (workingDirectory) {
|
||||
|
||||
+1
-6
@@ -1,23 +1,18 @@
|
||||
import { getCodeQL } from "./codeql";
|
||||
import * as configUtils from "./config-utils";
|
||||
import { FeatureEnablement } from "./feature-flags";
|
||||
import { Language, isTracedLanguage } from "./languages";
|
||||
import { Logger } from "./logging";
|
||||
import * as util from "./util";
|
||||
|
||||
export async function determineAutobuildLanguages(
|
||||
config: configUtils.Config,
|
||||
featureEnablement: FeatureEnablement,
|
||||
logger: Logger
|
||||
): Promise<Language[] | undefined> {
|
||||
const isGoExtractionReconciliationEnabled =
|
||||
await util.isGoExtractionReconciliationEnabled(featureEnablement);
|
||||
// Attempt to find a language to autobuild
|
||||
// We want pick the dominant language in the repo from the ones we're able to build
|
||||
// The languages are sorted in order specified by user or by lines of code if we got
|
||||
// them from the GitHub API, so try to build the first language on the list.
|
||||
const autobuildLanguages = config.languages.filter((l) =>
|
||||
isTracedLanguage(l, isGoExtractionReconciliationEnabled, logger)
|
||||
isTracedLanguage(l, logger)
|
||||
);
|
||||
|
||||
if (!autobuildLanguages) {
|
||||
|
||||
+2
-10
@@ -815,12 +815,8 @@ async function getCodeQLForCmd(
|
||||
const extraArgs = config.languages.map(
|
||||
(language) => `--language=${language}`
|
||||
);
|
||||
const isGoExtractionReconciliationEnabled =
|
||||
await util.isGoExtractionReconciliationEnabled(featureEnablement);
|
||||
if (
|
||||
config.languages.filter((l) =>
|
||||
isTracedLanguage(l, isGoExtractionReconciliationEnabled, logger)
|
||||
).length > 0
|
||||
config.languages.filter((l) => isTracedLanguage(l, logger)).length > 0
|
||||
) {
|
||||
extraArgs.push("--begin-tracing");
|
||||
extraArgs.push(...(await getTrapCachingExtractorConfigArgs(config)));
|
||||
@@ -841,11 +837,7 @@ async function getCodeQLForCmd(
|
||||
CODEQL_VERSION_LUA_TRACER_CONFIG
|
||||
)) &&
|
||||
config.languages.includes(Language.go) &&
|
||||
isTracedLanguage(
|
||||
Language.go,
|
||||
isGoExtractionReconciliationEnabled,
|
||||
logger
|
||||
) &&
|
||||
isTracedLanguage(Language.go, logger) &&
|
||||
process.platform === "win32" &&
|
||||
!(await util.codeQlVersionAbove(
|
||||
this,
|
||||
|
||||
+1
-6
@@ -119,12 +119,7 @@ export async function runInit(
|
||||
} catch (e) {
|
||||
throw processError(e);
|
||||
}
|
||||
return await getCombinedTracerConfig(
|
||||
config,
|
||||
codeql,
|
||||
await util.isGoExtractionReconciliationEnabled(featureEnablement),
|
||||
logger
|
||||
);
|
||||
return await getCombinedTracerConfig(config, codeql, logger);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+22
-32
@@ -32,40 +32,30 @@ test("parseLanguage", async (t) => {
|
||||
t.deepEqual(parseLanguage(""), undefined);
|
||||
});
|
||||
|
||||
for (const isReconciliationOn of [false, true]) {
|
||||
test(`isTracedLanguage (go reconciliation ${
|
||||
isReconciliationOn ? "enabled" : "disabled"
|
||||
})`, async (t) => {
|
||||
const logger = getRunnerLogger(true);
|
||||
test("isTracedLanguage", async (t) => {
|
||||
const logger = getRunnerLogger(true);
|
||||
|
||||
t.true(isTracedLanguage(Language.cpp, isReconciliationOn, logger));
|
||||
t.true(isTracedLanguage(Language.java, isReconciliationOn, logger));
|
||||
t.true(isTracedLanguage(Language.csharp, isReconciliationOn, logger));
|
||||
t.true(isTracedLanguage(Language.cpp, logger));
|
||||
t.true(isTracedLanguage(Language.csharp, logger));
|
||||
t.true(isTracedLanguage(Language.go, logger));
|
||||
t.true(isTracedLanguage(Language.java, logger));
|
||||
t.true(isTracedLanguage(Language.swift, logger));
|
||||
|
||||
t.is(
|
||||
isTracedLanguage(Language.go, isReconciliationOn, logger),
|
||||
isReconciliationOn
|
||||
);
|
||||
t.false(isTracedLanguage(Language.javascript, logger));
|
||||
t.false(isTracedLanguage(Language.python, logger));
|
||||
t.false(isTracedLanguage(Language.ruby, logger));
|
||||
});
|
||||
|
||||
t.false(isTracedLanguage(Language.javascript, isReconciliationOn, logger));
|
||||
t.false(isTracedLanguage(Language.python, isReconciliationOn, logger));
|
||||
});
|
||||
test("isScannedLanguage", async (t) => {
|
||||
const logger = getRunnerLogger(true);
|
||||
|
||||
test(`isScannedLanguage (go reconciliation ${
|
||||
isReconciliationOn ? "enabled" : "disabled"
|
||||
}`, async (t) => {
|
||||
const logger = getRunnerLogger(true);
|
||||
t.false(isScannedLanguage(Language.cpp, logger));
|
||||
t.false(isScannedLanguage(Language.csharp, logger));
|
||||
t.false(isScannedLanguage(Language.go, logger));
|
||||
t.false(isScannedLanguage(Language.java, logger));
|
||||
t.false(isScannedLanguage(Language.swift, logger));
|
||||
|
||||
t.false(isScannedLanguage(Language.cpp, isReconciliationOn, logger));
|
||||
t.false(isScannedLanguage(Language.java, isReconciliationOn, logger));
|
||||
t.false(isScannedLanguage(Language.csharp, isReconciliationOn, logger));
|
||||
|
||||
t.is(
|
||||
isScannedLanguage(Language.go, isReconciliationOn, logger),
|
||||
!isReconciliationOn
|
||||
);
|
||||
|
||||
t.true(isScannedLanguage(Language.javascript, isReconciliationOn, logger));
|
||||
t.true(isScannedLanguage(Language.python, isReconciliationOn, logger));
|
||||
});
|
||||
}
|
||||
t.true(isScannedLanguage(Language.javascript, logger));
|
||||
t.true(isScannedLanguage(Language.python, logger));
|
||||
t.true(isScannedLanguage(Language.ruby, logger));
|
||||
});
|
||||
|
||||
+4
-19
@@ -38,31 +38,16 @@ export function parseLanguage(language: string): Language | undefined {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export function isTracedLanguage(
|
||||
language: Language,
|
||||
isGoExtractionReconciliationEnabled: boolean,
|
||||
logger: Logger
|
||||
): boolean {
|
||||
export function isTracedLanguage(language: Language, logger: Logger): boolean {
|
||||
if ("CODEQL_EXTRACTOR_GO_BUILD_TRACING" in process.env) {
|
||||
logger.warning(
|
||||
"The CODEQL_EXTRACTOR_GO_BUILD_TRACING environment variable is deprecated and its behavior is now the default behavior."
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
["cpp", "java", "csharp", "swift"].includes(language) ||
|
||||
(isGoExtractionReconciliationEnabled && language === Language.go)
|
||||
);
|
||||
return ["cpp", "csharp", "go", "java", "swift"].includes(language);
|
||||
}
|
||||
|
||||
export function isScannedLanguage(
|
||||
language: Language,
|
||||
isGoExtractionReconciliationEnabled: boolean,
|
||||
logger: Logger
|
||||
): boolean {
|
||||
return !isTracedLanguage(
|
||||
language,
|
||||
isGoExtractionReconciliationEnabled,
|
||||
logger
|
||||
);
|
||||
export function isScannedLanguage(language: Language, logger: Logger): boolean {
|
||||
return !isTracedLanguage(language, logger);
|
||||
}
|
||||
|
||||
+2
-13
@@ -375,11 +375,7 @@ program
|
||||
}
|
||||
languages = [language];
|
||||
} else {
|
||||
languages = await determineAutobuildLanguages(
|
||||
config,
|
||||
createFeatures([]),
|
||||
logger
|
||||
);
|
||||
languages = await determineAutobuildLanguages(config, logger);
|
||||
}
|
||||
if (languages !== undefined) {
|
||||
for (const language of languages) {
|
||||
@@ -502,14 +498,7 @@ program
|
||||
logger
|
||||
);
|
||||
const memory = getMemoryFlag(cmd.ram || initEnv["CODEQL_RAM"]);
|
||||
await runFinalize(
|
||||
outputDir,
|
||||
threads,
|
||||
memory,
|
||||
config,
|
||||
logger,
|
||||
createFeatures([])
|
||||
);
|
||||
await runFinalize(outputDir, threads, memory, config, logger);
|
||||
await runQueries(
|
||||
outputDir,
|
||||
memory,
|
||||
|
||||
@@ -331,12 +331,7 @@ test("getCombinedTracerConfig - return undefined when no languages are traced la
|
||||
});
|
||||
|
||||
t.deepEqual(
|
||||
await getCombinedTracerConfig(
|
||||
config,
|
||||
codeQL,
|
||||
false, // Disable Go extraction reconciliation
|
||||
getRunnerLogger(true)
|
||||
),
|
||||
await getCombinedTracerConfig(config, codeQL, getRunnerLogger(true)),
|
||||
undefined
|
||||
);
|
||||
});
|
||||
@@ -371,7 +366,6 @@ test("getCombinedTracerConfig - valid spec file", async (t) => {
|
||||
const result = await getCombinedTracerConfig(
|
||||
config,
|
||||
codeQL,
|
||||
false, // Disable Go extraction reconciliation
|
||||
getRunnerLogger(true)
|
||||
);
|
||||
t.notDeepEqual(result, undefined);
|
||||
|
||||
@@ -23,16 +23,10 @@ const CRITICAL_TRACER_VARS = new Set([
|
||||
|
||||
export async function endTracingForCluster(
|
||||
config: configUtils.Config,
|
||||
isGoExtractionReconciliationEnabled: boolean,
|
||||
logger: Logger
|
||||
): Promise<void> {
|
||||
// If there are no traced languages, we don't need to do anything.
|
||||
if (
|
||||
!config.languages.some((l) =>
|
||||
isTracedLanguage(l, isGoExtractionReconciliationEnabled, logger)
|
||||
)
|
||||
)
|
||||
return;
|
||||
if (!config.languages.some((l) => isTracedLanguage(l, logger))) return;
|
||||
|
||||
const envVariablesFile = path.resolve(
|
||||
config.dbLocation,
|
||||
@@ -232,12 +226,11 @@ export function concatTracerConfigs(
|
||||
export async function getCombinedTracerConfig(
|
||||
config: configUtils.Config,
|
||||
codeql: CodeQL,
|
||||
isGoExtractionReconciliationEnabled: boolean,
|
||||
logger: Logger
|
||||
): Promise<TracerConfig | undefined> {
|
||||
// Abort if there are no traced languages as there's nothing to do
|
||||
const tracedLanguages = config.languages.filter((l) =>
|
||||
isTracedLanguage(l, isGoExtractionReconciliationEnabled, logger)
|
||||
isTracedLanguage(l, logger)
|
||||
);
|
||||
if (tracedLanguages.length === 0) {
|
||||
return undefined;
|
||||
|
||||
@@ -830,14 +830,6 @@ export function listFolder(dir: string): string[] {
|
||||
return files;
|
||||
}
|
||||
|
||||
export async function isGoExtractionReconciliationEnabled(
|
||||
featureEnablement: FeatureEnablement
|
||||
): Promise<boolean> {
|
||||
return await featureEnablement.getValue(
|
||||
Feature.GolangExtractionReconciliationEnabled
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the size a folder in bytes. This will log any filesystem errors
|
||||
* as a warning and then return undefined.
|
||||
|
||||
Reference in New Issue
Block a user