Skip to content

Commit

Permalink
CI (Buildkite, code coverage): Fail the code coverage job is the cove…
Browse files Browse the repository at this point in the history
…rage is suspiciously low
  • Loading branch information
DilumAluthge committed Sep 11, 2021
1 parent d7028da commit 92a3a07
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions .buildkite/pipelines/scheduled/coverage/upload_coverage.jl
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ function print_coverage_summary(
cov_pct = floor(Int, cov_lines/tot_lines * 100)
end
@info "$(description): $(cov_pct)% ($(cov_lines)/$(tot_lines))"
return nothing
return (; cov_pct)
end

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

print_coverage_summary.(fcs);
print_coverage_summary(fcs, "Total")
const total_cov_pct = print_coverage_summary(fcs, "Total").cov_pct

let
git_info = coveralls_buildkite_query_git_info()
Expand All @@ -217,3 +217,12 @@ let
# In order to upload to Codecov, you need to have the `CODECOV_TOKEN` environment variable defined.
Coverage.Codecov.submit_generic(fcs, kwargs)
end

if total_cov_pct < 50
msg = string(
"The total coverage is less than 50%. This should never happen, ",
"so it means that something has probably gone wrong with the code coverage job.",
)
@error msg total_cov_pct
throw(ErrorException(msg))
end

0 comments on commit 92a3a07

Please sign in to comment.