Skip to content

Commit 969a124

Browse files
committed
fix: create logging groups around the setup functions
1 parent 630f785 commit 969a124

File tree

7 files changed

+28
-4
lines changed

7 files changed

+28
-4
lines changed

dist/setup_cpp.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/setup_cpp.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/utils/setup/setupAptPack.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/* eslint-disable require-atomic-updates */
22
import { InstallationInfo } from "./setupBin"
33
import { execSudo } from "../exec/sudo"
4+
import { endGroup, startGroup } from "@actions/core"
45

56
let didUpdate: boolean = false
67
let didInit: boolean = false
@@ -11,6 +12,8 @@ export async function setupAptPack(
1112
version?: string,
1213
repositories: boolean | string[] = true
1314
): Promise<InstallationInfo> {
15+
startGroup(`Installing ${name} ${version ?? ""} via apt`)
16+
1417
const apt = "apt-get"
1518

1619
process.env.DEBIAN_FRONTEND = "noninteractive"
@@ -55,5 +58,6 @@ export async function setupAptPack(
5558
await execSudo(apt, ["install", "--fix-broken", "-y", name])
5659
}
5760

61+
endGroup()
5862
return { binDir: "/usr/bin/" }
5963
}

src/utils/setup/setupBin.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { find, downloadTool, cacheDir } from "@actions/tool-cache"
2-
import { info } from "@actions/core"
2+
import { endGroup, info, startGroup } from "@actions/core"
33
import { addPath } from "../path/addPath"
44
import { join } from "path"
55
import { existsSync } from "fs"
@@ -45,6 +45,8 @@ export async function setupBin(
4545
setupDir: string,
4646
arch: string
4747
): Promise<InstallationInfo> {
48+
startGroup(`Installing ${name} ${version} ${arch} via direct downloading`)
49+
4850
process.env.RUNNER_TEMP = process.env.RUNNER_TEMP ?? tmpdir()
4951
process.env.RUNNER_TOOL_CACHE = process.env.RUNNER_TOOL_CACHE ?? join(tmpdir(), "setup-cpp", "hostedtoolcache")
5052

@@ -64,6 +66,8 @@ export async function setupBin(
6466
if (existsSync(binDir) && existsSync(join(binDir, binFileName))) {
6567
info(`${name} ${version} was found in the cache at ${binDir}.`)
6668
addPath(binDir)
69+
70+
endGroup()
6771
return { installDir, binDir }
6872
}
6973
}
@@ -91,6 +95,7 @@ export async function setupBin(
9195
const downloaded = await downloadTool(url)
9296
await extractFunction?.(downloaded, setupDir)
9397
} catch (err) {
98+
endGroup()
9499
throw new Error(`Failed to download ${name} ${version} ${arch}: ${err}`)
95100
}
96101
}
@@ -105,5 +110,6 @@ export async function setupBin(
105110
await cacheDir(setupDir, name, version)
106111
}
107112

113+
endGroup()
108114
return { installDir, binDir }
109115
}

src/utils/setup/setupBrewPack.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/* eslint-disable require-atomic-updates */
2+
import { endGroup, startGroup } from "@actions/core"
23
import execa from "execa"
34
import which from "which"
45
import { setupBrew } from "../../brew/brew"
@@ -8,6 +9,8 @@ let hasBrew = false
89

910
/** A function that installs a package using brew */
1011
export function setupBrewPack(name: string, version?: string): InstallationInfo {
12+
startGroup(`Installing ${name} ${version ?? ""} via brew`)
13+
1114
if (!hasBrew || which.sync("brew", { nothrow: true }) === null) {
1215
setupBrew("", "", process.arch)
1316
hasBrew = true
@@ -18,5 +21,6 @@ export function setupBrewPack(name: string, version?: string): InstallationInfo
1821
stdio: "inherit",
1922
})
2023

24+
endGroup()
2125
return { binDir: "/usr/local/bin/" }
2226
}

src/utils/setup/setupChocoPack.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@ import which from "which"
44
import { setupChocolatey } from "../../chocolatey/chocolatey"
55
import { InstallationInfo } from "./setupBin"
66
import execa from "execa"
7+
import { endGroup, startGroup } from "@actions/core"
78

89
let hasChoco = false
910

1011
/** A function that installs a package using choco */
1112
export function setupChocoPack(name: string, version?: string, args: string[] = []): InstallationInfo {
13+
startGroup(`Installing ${name} ${version ?? ""} via chocolatey`)
14+
1215
if (!hasChoco || which.sync("choco", { nothrow: true }) === null) {
1316
setupChocolatey("", "", process.arch)
1417
hasChoco = true
@@ -34,5 +37,7 @@ export function setupChocoPack(name: string, version?: string, args: string[] =
3437

3538
const binDir = `${process.env.ChocolateyInstall ?? "C:/ProgramData/chocolatey"}/bin`
3639
addPath(binDir)
40+
41+
endGroup()
3742
return { binDir }
3843
}

src/utils/setup/setupPipPack.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import { getExecOutput } from "@actions/exec"
33
import execa from "execa"
44
import which from "which"
5-
import { info } from "@actions/core"
5+
import { endGroup, info, startGroup } from "@actions/core"
66
import { addPath } from "../path/addPath"
77
import { setupPython } from "../../python/python"
88
import { isBinUptoDate } from "./version"
@@ -17,6 +17,8 @@ let tried = false
1717

1818
/** A function that installs a package using pip */
1919
export async function setupPipPack(name: string, version?: string): Promise<InstallationInfo> {
20+
startGroup(`Installing ${name} ${version ?? ""} via pip`)
21+
2022
// setup python and pip if needed
2123
if (python === undefined) {
2224
if (which.sync("python3", { nothrow: true }) !== null) {
@@ -28,9 +30,11 @@ export async function setupPipPack(name: string, version?: string): Promise<Inst
2830
await setupPython(getVersion("python", undefined), "", process.arch)
2931
// try again
3032
if (tried) {
33+
endGroup()
3134
throw new Error("Failed to install python")
3235
}
3336
tried = true
37+
endGroup()
3438
return setupPipPack(name, version)
3539
}
3640
}
@@ -66,5 +70,6 @@ export async function setupPipPack(name: string, version?: string): Promise<Inst
6670
addPath(binDir)
6771
}
6872

73+
endGroup()
6974
return { binDir }
7075
}

0 commit comments

Comments
 (0)