Skip to content

Commit da4803b

Browse files
DilumAluthgeKristofferC
authored andcommitted
CI (Buildkite, code coverage): Fail the code coverage job is the coverage is suspiciously low (#42213)
(cherry picked from commit e65296f)
1 parent 2d7623d commit da4803b

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

.buildkite/pipelines/scheduled/coverage/upload_coverage.jl

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ function print_coverage_summary(
9191
cov_pct = floor(Int, cov_lines/tot_lines * 100)
9292
end
9393
@info "$(description): $(cov_pct)% ($(cov_lines)/$(tot_lines))"
94-
return nothing
94+
return (; cov_pct)
9595
end
9696

9797
function buildkite_env(name::String)
@@ -198,7 +198,7 @@ end;
198198
sort!(fcs; by = fc -> fc.filename);
199199

200200
print_coverage_summary.(fcs);
201-
print_coverage_summary(fcs, "Total")
201+
const total_cov_pct = print_coverage_summary(fcs, "Total").cov_pct
202202

203203
let
204204
git_info = coveralls_buildkite_query_git_info()
@@ -217,3 +217,12 @@ let
217217
# In order to upload to Codecov, you need to have the `CODECOV_TOKEN` environment variable defined.
218218
Coverage.Codecov.submit_generic(fcs, kwargs)
219219
end
220+
221+
if total_cov_pct < 50
222+
msg = string(
223+
"The total coverage is less than 50%. This should never happen, ",
224+
"so it means that something has probably gone wrong with the code coverage job.",
225+
)
226+
@error msg total_cov_pct
227+
throw(ErrorException(msg))
228+
end

0 commit comments

Comments
 (0)