Print specific error message for failed pre checks

This commit is contained in:
Franco Meloni 2019-12-16 10:43:58 +00:00
parent 4d06e02da5
commit 4590c8f642
4 changed files with 12 additions and 3 deletions

View File

@ -12,7 +12,7 @@
}, },
{ {
"package": "Logger", "package": "Logger",
"repositoryURL": "https://github.com/f-meloni/Logger", "repositoryURL": "https://github.com/shibapm/Logger",
"state": { "state": {
"branch": null, "branch": null,
"revision": "53c3ecca5abe8cf46697e33901ee774236d94cce", "revision": "53c3ecca5abe8cf46697e33901ee774236d94cce",

View File

@ -41,8 +41,10 @@ if let rocketYamlPath = RocketFileFinder.rocketFilePath() {
let checks = ChecksParser.parsePreReleaseChecks(fromDictionary: dictionary) let checks = ChecksParser.parsePreReleaseChecks(fromDictionary: dictionary)
let failedChecks = checks.filter { !$0.check() } let failedChecks = checks.filter { !$0.check() }
guard failedChecks.count == 0 else { guard failedChecks.isEmpty else {
logger.logError("Pre release checks failed") logger.logError("Pre release checks failed",
failedChecks.map { $0.errorMessage }.joined(separator: "\n"),
separator: "\n")
exit(1) exit(1)
} }

View File

@ -1,4 +1,7 @@
public protocol Check { public protocol Check {
init() init()
var errorMessage: String { get }
func check() -> Bool func check() -> Bool
} }

View File

@ -2,6 +2,10 @@ import Foundation
struct CleanGitStatusCheck: Check { struct CleanGitStatusCheck: Check {
let launcher: ScriptLaunching let launcher: ScriptLaunching
var errorMessage: String {
return "Your git status contains not committed code, please remove it or commit it"
}
init() { init() {
self.init(launcher: ScriptLauncher()) self.init(launcher: ScriptLauncher())