Skip to content

Commit d7596dd

Browse files
committed
feat: fail fast inside CI when an error happens
1 parent d93dc2b commit d7596dd

File tree

7 files changed

+30
-18
lines changed

7 files changed

+30
-18
lines changed

dist/actions/setup-cpp.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/actions/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.

dist/legacy/setup-cpp.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/legacy/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.

dist/modern/setup-cpp.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/modern/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/main.ts

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env node
22
/* eslint-disable node/shebang */
33

4-
import { GITHUB_ACTIONS } from "ci-info"
4+
import { GITHUB_ACTIONS, isCI } from "ci-info"
55
import { error, info, success, warning } from "ci-log"
66
import * as numerous from "numerous"
77
import numerousLocale from "numerous/locales/en.js"
@@ -69,7 +69,17 @@ async function main(args: string[]): Promise<number> {
6969
let hasLLVM = false
7070

7171
// loop over the tools and run their setup function
72+
73+
let failedFast = false
7274
for (const tool of tools) {
75+
// fail fast inside CI when any tool fails
76+
if (isCI) {
77+
if (errorMessages.length !== 0) {
78+
failedFast = true
79+
break
80+
}
81+
}
82+
7383
// get the version or "true" or undefined for this tool from the options
7484
const version = opts[tool]
7585

@@ -86,20 +96,22 @@ async function main(args: string[]): Promise<number> {
8696
setupCppDir,
8797
successMessages,
8898
errorMessages,
89-
parseFloat(opts.timeout ?? "0.1"),
99+
parseFloat(opts.timeout ?? "10"),
90100
)
91101
time2 = Date.now()
92102
info(`took ${timeFormatter.format(time1, time2) || "0 seconds"}`)
93103
}
94104
}
95105

96-
// installing the specified compiler
97-
const maybeCompiler = opts.compiler
98-
if (maybeCompiler !== undefined) {
99-
const time1Compiler = Date.now()
100-
await installCompiler(maybeCompiler, osVersion, setupCppDir, arch, successMessages, hasLLVM, errorMessages)
101-
const time2Compiler = Date.now()
102-
info(`took ${timeFormatter.format(time1Compiler, time2Compiler) || "0 seconds"}`)
106+
if (!failedFast) {
107+
// installing the specified compiler
108+
const maybeCompiler = opts.compiler
109+
if (maybeCompiler !== undefined) {
110+
const time1Compiler = Date.now()
111+
await installCompiler(maybeCompiler, osVersion, setupCppDir, arch, successMessages, hasLLVM, errorMessages)
112+
const time2Compiler = Date.now()
113+
info(`took ${timeFormatter.format(time1Compiler, time2Compiler) || "0 seconds"}`)
114+
}
103115
}
104116

105117
await finalizeCpprc()

0 commit comments

Comments
 (0)