mirror of https://github.com/aminya/setup-cpp
fix: create logging groups around the setup functions
This commit is contained in:
parent
630f785194
commit
969a124c7d
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1,6 +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"
|
||||||
|
|
||||||
let didUpdate: boolean = false
|
let didUpdate: boolean = false
|
||||||
let didInit: boolean = false
|
let didInit: boolean = false
|
||||||
|
@ -11,6 +12,8 @@ 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`)
|
||||||
|
|
||||||
const apt = "apt-get"
|
const apt = "apt-get"
|
||||||
|
|
||||||
process.env.DEBIAN_FRONTEND = "noninteractive"
|
process.env.DEBIAN_FRONTEND = "noninteractive"
|
||||||
|
@ -55,5 +58,6 @@ 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/" }
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { find, downloadTool, cacheDir } from "@actions/tool-cache"
|
import { find, downloadTool, cacheDir } from "@actions/tool-cache"
|
||||||
import { info } from "@actions/core"
|
import { endGroup, info, startGroup } 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,6 +45,8 @@ export async function setupBin(
|
||||||
setupDir: string,
|
setupDir: string,
|
||||||
arch: string
|
arch: string
|
||||||
): Promise<InstallationInfo> {
|
): Promise<InstallationInfo> {
|
||||||
|
startGroup(`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")
|
||||||
|
|
||||||
|
@ -64,6 +66,8 @@ export async function setupBin(
|
||||||
if (existsSync(binDir) && existsSync(join(binDir, binFileName))) {
|
if (existsSync(binDir) && existsSync(join(binDir, binFileName))) {
|
||||||
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 }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -91,6 +95,7 @@ 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}`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -105,5 +110,6 @@ export async function setupBin(
|
||||||
await cacheDir(setupDir, name, version)
|
await cacheDir(setupDir, name, version)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
endGroup()
|
||||||
return { installDir, binDir }
|
return { installDir, binDir }
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
/* eslint-disable require-atomic-updates */
|
/* eslint-disable require-atomic-updates */
|
||||||
|
import { endGroup, startGroup } 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"
|
||||||
|
@ -8,6 +9,8 @@ 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`)
|
||||||
|
|
||||||
if (!hasBrew || which.sync("brew", { nothrow: true }) === null) {
|
if (!hasBrew || which.sync("brew", { nothrow: true }) === null) {
|
||||||
setupBrew("", "", process.arch)
|
setupBrew("", "", process.arch)
|
||||||
hasBrew = true
|
hasBrew = true
|
||||||
|
@ -18,5 +21,6 @@ export function setupBrewPack(name: string, version?: string): InstallationInfo
|
||||||
stdio: "inherit",
|
stdio: "inherit",
|
||||||
})
|
})
|
||||||
|
|
||||||
|
endGroup()
|
||||||
return { binDir: "/usr/local/bin/" }
|
return { binDir: "/usr/local/bin/" }
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,11 +4,14 @@ 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"
|
||||||
|
|
||||||
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`)
|
||||||
|
|
||||||
if (!hasChoco || which.sync("choco", { nothrow: true }) === null) {
|
if (!hasChoco || which.sync("choco", { nothrow: true }) === null) {
|
||||||
setupChocolatey("", "", process.arch)
|
setupChocolatey("", "", process.arch)
|
||||||
hasChoco = true
|
hasChoco = true
|
||||||
|
@ -34,5 +37,7 @@ 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 }
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 { info } from "@actions/core"
|
import { endGroup, info, startGroup } 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,6 +17,8 @@ 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`)
|
||||||
|
|
||||||
// setup python and pip if needed
|
// setup python and pip if needed
|
||||||
if (python === undefined) {
|
if (python === undefined) {
|
||||||
if (which.sync("python3", { nothrow: true }) !== null) {
|
if (which.sync("python3", { nothrow: true }) !== null) {
|
||||||
|
@ -28,9 +30,11 @@ 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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -66,5 +70,6 @@ export async function setupPipPack(name: string, version?: string): Promise<Inst
|
||||||
addPath(binDir)
|
addPath(binDir)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
endGroup()
|
||||||
return { binDir }
|
return { binDir }
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue