fix: create logging groups around the tools

This commit is contained in:
Amin Yahyaabadi 2022-02-13 15:50:15 -08:00
parent 969a124c7d
commit 936a9677f7
3 changed files with 12 additions and 6 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

@ -30,6 +30,7 @@ import { setupVCVarsall } from "./vcvarsall/vcvarsall"
import { setupKcov } from "./kcov/kcov" import { setupKcov } from "./kcov/kcov"
import { addEnv } from "./utils/env/addEnv" import { addEnv } from "./utils/env/addEnv"
import { setupSevenZip } from "./sevenzip/sevenzip" import { setupSevenZip } from "./sevenzip/sevenzip"
import { endGroup, startGroup } from "@actions/core"
/** The setup functions */ /** The setup functions */
const setups = { const setups = {
@ -125,22 +126,23 @@ export async function main(args: string[]): Promise<number> {
// loop over the tools and run their setup function // loop over the tools and run their setup function
for (const tool of tools) { for (const tool of tools) {
// get the version or "true" or undefined for this tool from the options // get the version or "true" or undefined for this tool from the options
const value = opts[tool] const version = opts[tool]
// skip if undefined // skip if undefined
if (value !== undefined) { if (version !== undefined) {
// running the setup function for this tool // running the setup function for this tool
startGroup(`Installing ${tool} ${version}`)
try { try {
let installationInfo: InstallationInfo | undefined | void let installationInfo: InstallationInfo | undefined | void
if (tool === "vcvarsall") { if (tool === "vcvarsall") {
// eslint-disable-next-line no-await-in-loop // eslint-disable-next-line no-await-in-loop
setupVCVarsall(getVersion(tool, value), undefined, arch, undefined, undefined, false, false) setupVCVarsall(getVersion(tool, version), undefined, arch, undefined, undefined, false, false)
} else { } else {
// get the setup function // get the setup function
const setupFunction = setups[tool] const setupFunction = setups[tool]
// eslint-disable-next-line no-await-in-loop // eslint-disable-next-line no-await-in-loop
installationInfo = await setupFunction(getVersion(tool, value), join(setupCppDir, tool), arch) installationInfo = await setupFunction(getVersion(tool, version), join(setupCppDir, tool), arch)
} }
// preparing a report string // preparing a report string
successMessages.push(getSuccessMessage(tool, installationInfo)) successMessages.push(getSuccessMessage(tool, installationInfo))
@ -149,6 +151,7 @@ export async function main(args: string[]): Promise<number> {
error(e as string | Error) error(e as string | Error)
errorMessages.push(`${tool} failed to install`) errorMessages.push(`${tool} failed to install`)
} }
endGroup()
} }
} }
@ -159,6 +162,7 @@ export async function main(args: string[]): Promise<number> {
const { compiler, version } = getCompilerInfo(maybeCompiler) const { compiler, version } = getCompilerInfo(maybeCompiler)
// install the compiler. We allow some aliases for the compiler name // install the compiler. We allow some aliases for the compiler name
startGroup(`Installing ${compiler} ${version ?? ""}`)
switch (compiler) { switch (compiler) {
case "llvm": case "llvm":
case "clang": case "clang":
@ -198,10 +202,12 @@ export async function main(args: string[]): Promise<number> {
errorMessages.push(`Unsupported compiler ${compiler}`) errorMessages.push(`Unsupported compiler ${compiler}`)
} }
} }
endGroup()
} }
} catch (e) { } catch (e) {
error(e as string | Error) error(e as string | Error)
errorMessages.push(`Failed to install the ${maybeCompiler}`) errorMessages.push(`Failed to install the ${maybeCompiler}`)
endGroup()
} }
if (successMessages.length === 0 && errorMessages.length === 0) { if (successMessages.length === 0 && errorMessages.length === 0) {