Merge branch 'main' into henrymercer/on-demand-ffs
This commit is contained in:
commit
67f8a36bdb
21 changed files with 78 additions and 73 deletions
|
|
@ -402,13 +402,10 @@ export async function runFinalize(
|
|||
logger,
|
||||
);
|
||||
|
||||
// WARNING: This does not _really_ end tracing, as the tracer will restore its
|
||||
// critical environment variables and it'll still be active for all processes
|
||||
// launched from this build step.
|
||||
// However, it will stop tracing for all steps past the codeql-action/analyze
|
||||
// step.
|
||||
// Delete variables as specified by the end-tracing script
|
||||
await endTracingForCluster(codeql, config, features);
|
||||
// If we didn't already end tracing in the autobuild Action, end it now.
|
||||
if (process.env[EnvVar.AUTOBUILD_DID_COMPLETE_SUCCESSFULLY] !== "true") {
|
||||
await endTracingForCluster(codeql, config, logger, features);
|
||||
}
|
||||
return timings;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ import {
|
|||
sendStatusReport,
|
||||
ActionName,
|
||||
} from "./status-report";
|
||||
import { endTracingForCluster } from "./tracer-config";
|
||||
import {
|
||||
checkActionVersion,
|
||||
checkDiskUsage,
|
||||
|
|
@ -125,6 +126,10 @@ async function run() {
|
|||
await runAutobuild(config, language, features, logger);
|
||||
}
|
||||
}
|
||||
|
||||
// End tracing early to avoid tracing analyze. This improves the performance and reliability of
|
||||
// the analyze step.
|
||||
await endTracingForCluster(codeql, config, logger, features);
|
||||
} catch (unwrappedError) {
|
||||
const error = wrapError(unwrappedError);
|
||||
core.setFailed(
|
||||
|
|
|
|||
|
|
@ -173,7 +173,7 @@ export async function runAutobuild(
|
|||
) {
|
||||
await codeQL.extractUsingBuildMode(config, language);
|
||||
} else {
|
||||
await codeQL.runAutobuild(config, language, features);
|
||||
await codeQL.runAutobuild(config, language);
|
||||
}
|
||||
if (language === Language.go) {
|
||||
core.exportVariable(EnvVar.DID_AUTOBUILD_GOLANG, "true");
|
||||
|
|
|
|||
|
|
@ -910,12 +910,7 @@ test("runTool summarizes autobuilder errors", async (t) => {
|
|||
sinon.stub(safeWhich, "safeWhich").resolves("");
|
||||
|
||||
await t.throwsAsync(
|
||||
async () =>
|
||||
await codeqlObject.runAutobuild(
|
||||
stubConfig,
|
||||
Language.java,
|
||||
createFeatures([]),
|
||||
),
|
||||
async () => await codeqlObject.runAutobuild(stubConfig, Language.java),
|
||||
{
|
||||
instanceOf: CommandInvocationError,
|
||||
message:
|
||||
|
|
@ -943,12 +938,7 @@ test("runTool truncates long autobuilder errors", async (t) => {
|
|||
sinon.stub(safeWhich, "safeWhich").resolves("");
|
||||
|
||||
await t.throwsAsync(
|
||||
async () =>
|
||||
await codeqlObject.runAutobuild(
|
||||
stubConfig,
|
||||
Language.java,
|
||||
createFeatures([]),
|
||||
),
|
||||
async () => await codeqlObject.runAutobuild(stubConfig, Language.java),
|
||||
{
|
||||
instanceOf: CommandInvocationError,
|
||||
message:
|
||||
|
|
|
|||
|
|
@ -88,11 +88,7 @@ export interface CodeQL {
|
|||
/**
|
||||
* Runs the autobuilder for the given language.
|
||||
*/
|
||||
runAutobuild(
|
||||
config: Config,
|
||||
language: Language,
|
||||
features: FeatureEnablement,
|
||||
): Promise<void>;
|
||||
runAutobuild(config: Config, language: Language): Promise<void>;
|
||||
/**
|
||||
* Extract code for a scanned language using 'codeql database trace-command'
|
||||
* and running the language extractor.
|
||||
|
|
@ -634,25 +630,9 @@ export async function getCodeQLForCmd(
|
|||
{ stdin: externalRepositoryToken },
|
||||
);
|
||||
},
|
||||
async runAutobuild(
|
||||
config: Config,
|
||||
language: Language,
|
||||
features: FeatureEnablement,
|
||||
) {
|
||||
async runAutobuild(config: Config, language: Language) {
|
||||
applyAutobuildAzurePipelinesTimeoutFix();
|
||||
|
||||
if (await features.getValue(Feature.AutobuildDirectTracing, this)) {
|
||||
await runTool(cmd, [
|
||||
"database",
|
||||
"trace-command",
|
||||
...(await getTrapCachingExtractorConfigArgsForLang(config, language)),
|
||||
...getExtractionVerbosityArguments(config.debugMode),
|
||||
...getExtraOptionsFromEnv(["database", "trace-command"]),
|
||||
util.getCodeQLDatabasePath(config, language),
|
||||
]);
|
||||
return;
|
||||
}
|
||||
|
||||
const autobuildCmd = path.join(
|
||||
await this.resolveExtractor(language),
|
||||
"tools",
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import { type CodeQL } from "./codeql";
|
|||
import { type Config } from "./config-utils";
|
||||
import { Feature, FeatureEnablement } from "./feature-flags";
|
||||
import { isTracedLanguage } from "./languages";
|
||||
import { Logger } from "./logging";
|
||||
import { ToolsFeature } from "./tools-features";
|
||||
import { BuildMode } from "./util";
|
||||
|
||||
|
|
@ -25,13 +26,27 @@ export async function shouldEnableIndirectTracing(
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete variables as specified by the end-tracing script
|
||||
*
|
||||
* WARNING: This does not _really_ end tracing, as the tracer will restore its
|
||||
* critical environment variables and it'll still be active for all processes
|
||||
* launched from this build step.
|
||||
*
|
||||
* However, it will stop tracing for all steps past the current build step.
|
||||
*/
|
||||
export async function endTracingForCluster(
|
||||
codeql: CodeQL,
|
||||
config: Config,
|
||||
logger: Logger,
|
||||
features: FeatureEnablement,
|
||||
): Promise<void> {
|
||||
if (!(await shouldEnableIndirectTracing(codeql, config, features))) 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",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue