fix: do not create nested logging groups

This commit is contained in:
Amin Yahyaabadi 2022-02-13 16:00:50 -08:00
parent 936a9677f7
commit e6efc4aca9
7 changed files with 12 additions and 21 deletions

2
dist/setup_cpp.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,7 +1,7 @@
/* eslint-disable require-atomic-updates */ /* eslint-disable require-atomic-updates */
import { InstallationInfo } from "./setupBin" import { InstallationInfo } from "./setupBin"
import { execSudo } from "../exec/sudo" import { execSudo } from "../exec/sudo"
import { endGroup, startGroup } from "@actions/core" import { info } from "@actions/core"
let didUpdate: boolean = false let didUpdate: boolean = false
let didInit: boolean = false let didInit: boolean = false
@ -12,7 +12,7 @@ export async function setupAptPack(
version?: string, version?: string,
repositories: boolean | string[] = true repositories: boolean | string[] = true
): Promise<InstallationInfo> { ): Promise<InstallationInfo> {
startGroup(`Installing ${name} ${version ?? ""} via apt`) info(`Installing ${name} ${version ?? ""} via apt`)
const apt = "apt-get" const apt = "apt-get"
@ -58,6 +58,5 @@ export async function setupAptPack(
await execSudo(apt, ["install", "--fix-broken", "-y", name]) await execSudo(apt, ["install", "--fix-broken", "-y", name])
} }
endGroup()
return { binDir: "/usr/bin/" } return { binDir: "/usr/bin/" }
} }

View File

@ -1,5 +1,5 @@
import { find, downloadTool, cacheDir } from "@actions/tool-cache" import { find, downloadTool, cacheDir } from "@actions/tool-cache"
import { endGroup, info, startGroup } from "@actions/core" import { info } from "@actions/core"
import { addPath } from "../path/addPath" import { addPath } from "../path/addPath"
import { join } from "path" import { join } from "path"
import { existsSync } from "fs" import { existsSync } from "fs"
@ -45,7 +45,7 @@ export async function setupBin(
setupDir: string, setupDir: string,
arch: string arch: string
): Promise<InstallationInfo> { ): Promise<InstallationInfo> {
startGroup(`Installing ${name} ${version} ${arch} via direct downloading`) info(`Installing ${name} ${version} ${arch} via direct downloading`)
process.env.RUNNER_TEMP = process.env.RUNNER_TEMP ?? tmpdir() process.env.RUNNER_TEMP = process.env.RUNNER_TEMP ?? tmpdir()
process.env.RUNNER_TOOL_CACHE = process.env.RUNNER_TOOL_CACHE ?? join(tmpdir(), "setup-cpp", "hostedtoolcache") process.env.RUNNER_TOOL_CACHE = process.env.RUNNER_TOOL_CACHE ?? join(tmpdir(), "setup-cpp", "hostedtoolcache")
@ -67,7 +67,6 @@ export async function setupBin(
info(`${name} ${version} was found in the cache at ${binDir}.`) info(`${name} ${version} was found in the cache at ${binDir}.`)
addPath(binDir) addPath(binDir)
endGroup()
return { installDir, binDir } return { installDir, binDir }
} }
} }
@ -95,7 +94,6 @@ export async function setupBin(
const downloaded = await downloadTool(url) const downloaded = await downloadTool(url)
await extractFunction?.(downloaded, setupDir) await extractFunction?.(downloaded, setupDir)
} catch (err) { } catch (err) {
endGroup()
throw new Error(`Failed to download ${name} ${version} ${arch}: ${err}`) throw new Error(`Failed to download ${name} ${version} ${arch}: ${err}`)
} }
} }
@ -110,6 +108,5 @@ export async function setupBin(
await cacheDir(setupDir, name, version) await cacheDir(setupDir, name, version)
} }
endGroup()
return { installDir, binDir } return { installDir, binDir }
} }

View File

@ -1,5 +1,5 @@
/* eslint-disable require-atomic-updates */ /* eslint-disable require-atomic-updates */
import { endGroup, startGroup } from "@actions/core" import { info } from "@actions/core"
import execa from "execa" import execa from "execa"
import which from "which" import which from "which"
import { setupBrew } from "../../brew/brew" import { setupBrew } from "../../brew/brew"
@ -9,7 +9,7 @@ let hasBrew = false
/** A function that installs a package using brew */ /** A function that installs a package using brew */
export function setupBrewPack(name: string, version?: string): InstallationInfo { export function setupBrewPack(name: string, version?: string): InstallationInfo {
startGroup(`Installing ${name} ${version ?? ""} via brew`) info(`Installing ${name} ${version ?? ""} via brew`)
if (!hasBrew || which.sync("brew", { nothrow: true }) === null) { if (!hasBrew || which.sync("brew", { nothrow: true }) === null) {
setupBrew("", "", process.arch) setupBrew("", "", process.arch)
@ -21,6 +21,5 @@ export function setupBrewPack(name: string, version?: string): InstallationInfo
stdio: "inherit", stdio: "inherit",
}) })
endGroup()
return { binDir: "/usr/local/bin/" } return { binDir: "/usr/local/bin/" }
} }

View File

@ -4,13 +4,13 @@ import which from "which"
import { setupChocolatey } from "../../chocolatey/chocolatey" import { setupChocolatey } from "../../chocolatey/chocolatey"
import { InstallationInfo } from "./setupBin" import { InstallationInfo } from "./setupBin"
import execa from "execa" import execa from "execa"
import { endGroup, startGroup } from "@actions/core" import { info } from "@actions/core"
let hasChoco = false let hasChoco = false
/** A function that installs a package using choco */ /** A function that installs a package using choco */
export function setupChocoPack(name: string, version?: string, args: string[] = []): InstallationInfo { export function setupChocoPack(name: string, version?: string, args: string[] = []): InstallationInfo {
startGroup(`Installing ${name} ${version ?? ""} via chocolatey`) info(`Installing ${name} ${version ?? ""} via chocolatey`)
if (!hasChoco || which.sync("choco", { nothrow: true }) === null) { if (!hasChoco || which.sync("choco", { nothrow: true }) === null) {
setupChocolatey("", "", process.arch) setupChocolatey("", "", process.arch)
@ -38,6 +38,5 @@ export function setupChocoPack(name: string, version?: string, args: string[] =
const binDir = `${process.env.ChocolateyInstall ?? "C:/ProgramData/chocolatey"}/bin` const binDir = `${process.env.ChocolateyInstall ?? "C:/ProgramData/chocolatey"}/bin`
addPath(binDir) addPath(binDir)
endGroup()
return { binDir } return { binDir }
} }

View File

@ -2,7 +2,7 @@
import { getExecOutput } from "@actions/exec" import { getExecOutput } from "@actions/exec"
import execa from "execa" import execa from "execa"
import which from "which" import which from "which"
import { endGroup, info, startGroup } from "@actions/core" import { info } from "@actions/core"
import { addPath } from "../path/addPath" import { addPath } from "../path/addPath"
import { setupPython } from "../../python/python" import { setupPython } from "../../python/python"
import { isBinUptoDate } from "./version" import { isBinUptoDate } from "./version"
@ -17,7 +17,7 @@ let tried = false
/** A function that installs a package using pip */ /** A function that installs a package using pip */
export async function setupPipPack(name: string, version?: string): Promise<InstallationInfo> { export async function setupPipPack(name: string, version?: string): Promise<InstallationInfo> {
startGroup(`Installing ${name} ${version ?? ""} via pip`) info(`Installing ${name} ${version ?? ""} via pip`)
// setup python and pip if needed // setup python and pip if needed
if (python === undefined) { if (python === undefined) {
@ -30,11 +30,9 @@ export async function setupPipPack(name: string, version?: string): Promise<Inst
await setupPython(getVersion("python", undefined), "", process.arch) await setupPython(getVersion("python", undefined), "", process.arch)
// try again // try again
if (tried) { if (tried) {
endGroup()
throw new Error("Failed to install python") throw new Error("Failed to install python")
} }
tried = true tried = true
endGroup()
return setupPipPack(name, version) return setupPipPack(name, version)
} }
} }
@ -70,6 +68,5 @@ export async function setupPipPack(name: string, version?: string): Promise<Inst
addPath(binDir) addPath(binDir)
} }
endGroup()
return { binDir } return { binDir }
} }