Skip to content

Commit d206a07

Browse files
committed
fix: ensure process exits with error code if results contain errors in reporting functions
1 parent 3099729 commit d206a07

1 file changed

Lines changed: 20 additions & 4 deletions

File tree

internal/verifier/reporter.go

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,6 @@ func DoCheckReport(result *Check, reportingFormat string) error {
3030
return doJUnitReport(result)
3131
}
3232

33-
if result.HasErrors() {
34-
os.Exit(1)
35-
}
36-
3733
return nil
3834
}
3935

@@ -72,6 +68,10 @@ func doSummaryReport(result *Check) error {
7268
//nolint:forbidigo
7369
fmt.Printf("\n✖ %d problems (%d errors, %d warnings)\n", totalProblems, errorCount, warningCount)
7470

71+
if result.HasErrors() {
72+
os.Exit(1)
73+
}
74+
7575
return nil
7676
}
7777

@@ -85,6 +85,10 @@ func doJSONReport(result *Check) error {
8585
return fmt.Errorf("failed to write JSON output: %w", err)
8686
}
8787

88+
if result.HasErrors() {
89+
os.Exit(1)
90+
}
91+
8892
return nil
8993
}
9094

@@ -107,6 +111,10 @@ func doGitHubReport(result *Check) error {
107111
}
108112
}
109113

114+
if result.HasErrors() {
115+
os.Exit(1)
116+
}
117+
110118
return nil
111119
}
112120

@@ -196,6 +204,10 @@ func doJUnitReport(result *Check) error {
196204
return fmt.Errorf("failed to write JUnit XML: %w", err)
197205
}
198206

207+
if result.HasErrors() {
208+
os.Exit(1)
209+
}
210+
199211
return nil
200212
}
201213

@@ -204,6 +216,10 @@ func doMarkdownReport(result *Check) error {
204216
return fmt.Errorf("failed to write markdown output: %w", err)
205217
}
206218

219+
if result.HasErrors() {
220+
os.Exit(1)
221+
}
222+
207223
return nil
208224
}
209225

0 commit comments

Comments
 (0)