Introduce withGroupAsync()

This commit is contained in:
Chuan-kai Lin
2024-12-09 08:48:15 -08:00
parent 89757925c7
commit 70aac4e018
2 changed files with 24 additions and 9 deletions

View File

@@ -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) {