Introduce withGroupAsync()
This commit is contained in:
parent
89757925c7
commit
70aac4e018
2 changed files with 24 additions and 9 deletions
|
|
@ -18,7 +18,7 @@ import { addDiagnostic, makeDiagnostic } from "./diagnostics";
|
|||
import { EnvVar } from "./environment";
|
||||
import { FeatureEnablement, Feature } from "./feature-flags";
|
||||
import { isScannedLanguage, Language } from "./languages";
|
||||
import { Logger, withGroup } from "./logging";
|
||||
import { Logger, withGroupAsync } from "./logging";
|
||||
import { DatabaseCreationTimings, EventReport } from "./status-report";
|
||||
import { ToolsFeature } from "./tools-features";
|
||||
import { endTracingForCluster } from "./tracer-config";
|
||||
|
|
@ -256,14 +256,17 @@ export async function setupDiffInformedQueryRun(
|
|||
if (!(await features.getValue(Feature.DiffInformedQueries, codeql))) {
|
||||
return undefined;
|
||||
}
|
||||
return await withGroup("Generating diff range extension pack", async () => {
|
||||
const diffRanges = await getPullRequestEditedDiffRanges(
|
||||
baseRef,
|
||||
headRef,
|
||||
logger,
|
||||
);
|
||||
return writeDiffRangeDataExtensionPack(logger, diffRanges);
|
||||
});
|
||||
return await withGroupAsync(
|
||||
"Generating diff range extension pack",
|
||||
async () => {
|
||||
const diffRanges = await getPullRequestEditedDiffRanges(
|
||||
baseRef,
|
||||
headRef,
|
||||
logger,
|
||||
);
|
||||
return writeDiffRangeDataExtensionPack(logger, diffRanges);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
interface DiffThunkRange {
|
||||
|
|
|
|||
|
|
@ -41,6 +41,18 @@ export function withGroup<T>(groupName: string, f: () => T): T {
|
|||
}
|
||||
}
|
||||
|
||||
export async function withGroupAsync<T>(
|
||||
groupName: string,
|
||||
f: () => Promise<T>,
|
||||
): Promise<T> {
|
||||
core.startGroup(groupName);
|
||||
try {
|
||||
return await f();
|
||||
} finally {
|
||||
core.endGroup();
|
||||
}
|
||||
}
|
||||
|
||||
/** Format a duration for use in logs. */
|
||||
export function formatDuration(durationMs: number) {
|
||||
if (durationMs < 1000) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue