feat: fail fast inside CI when an error happens

This commit is contained in:
Amin Yahyaabadi 2023-08-21 20:16:33 -07:00
parent d93dc2b536
commit d7596dd449
7 changed files with 30 additions and 18 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

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 @@
#!/usr/bin/env node #!/usr/bin/env node
/* eslint-disable node/shebang */ /* eslint-disable node/shebang */
import { GITHUB_ACTIONS } from "ci-info" import { GITHUB_ACTIONS, isCI } from "ci-info"
import { error, info, success, warning } from "ci-log" import { error, info, success, warning } from "ci-log"
import * as numerous from "numerous" import * as numerous from "numerous"
import numerousLocale from "numerous/locales/en.js" import numerousLocale from "numerous/locales/en.js"
@ -69,7 +69,17 @@ async function main(args: string[]): Promise<number> {
let hasLLVM = false let hasLLVM = false
// loop over the tools and run their setup function // loop over the tools and run their setup function
let failedFast = false
for (const tool of tools) { for (const tool of tools) {
// fail fast inside CI when any tool fails
if (isCI) {
if (errorMessages.length !== 0) {
failedFast = true
break
}
}
// 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 version = opts[tool] const version = opts[tool]
@ -86,20 +96,22 @@ async function main(args: string[]): Promise<number> {
setupCppDir, setupCppDir,
successMessages, successMessages,
errorMessages, errorMessages,
parseFloat(opts.timeout ?? "0.1"), parseFloat(opts.timeout ?? "10"),
) )
time2 = Date.now() time2 = Date.now()
info(`took ${timeFormatter.format(time1, time2) || "0 seconds"}`) info(`took ${timeFormatter.format(time1, time2) || "0 seconds"}`)
} }
} }
// installing the specified compiler if (!failedFast) {
const maybeCompiler = opts.compiler // installing the specified compiler
if (maybeCompiler !== undefined) { const maybeCompiler = opts.compiler
const time1Compiler = Date.now() if (maybeCompiler !== undefined) {
await installCompiler(maybeCompiler, osVersion, setupCppDir, arch, successMessages, hasLLVM, errorMessages) const time1Compiler = Date.now()
const time2Compiler = Date.now() await installCompiler(maybeCompiler, osVersion, setupCppDir, arch, successMessages, hasLLVM, errorMessages)
info(`took ${timeFormatter.format(time1Compiler, time2Compiler) || "0 seconds"}`) const time2Compiler = Date.now()
info(`took ${timeFormatter.format(time1Compiler, time2Compiler) || "0 seconds"}`)
}
} }
await finalizeCpprc() await finalizeCpprc()