Skip to content

Commit

Permalink
Code coverage: fix the code coverage pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
DilumAluthge committed Jun 26, 2021
1 parent fe7e1fe commit 856f194
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 5 deletions.
3 changes: 2 additions & 1 deletion .buildkite/coverage-linux64/run_tests_base.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ const ncores = min(Sys.CPU_THREADS, Threads.nthreads())
@info "" ncores Sys.CPU_THREADS Threads.nthreads()

try
Base.runtests(tests; ncores)
# Base.runtests(tests; ncores) # TODO: uncomment this line
Base.runtests(["compiler"]; ncores) # TODO: delete this line
catch ex
@error "" exception=(ex, catch_backtrace())
end
93 changes: 89 additions & 4 deletions .buildkite/coverage-linux64/upload_coverage.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ empty!(Base.DEPOT_PATH)
push!(Base.DEPOT_PATH, mktempdir(; cleanup = true))

import Pkg
import LibGit2
import Logging
import TOML

Expand Down Expand Up @@ -108,8 +109,92 @@ sort!(fcs; by = fc -> fc.filename)
print_coverage_summary.(fcs);
print_coverage_summary(fcs, "Total")

# In order to upload to Codecov, you need to have the `CODECOV_TOKEN` environment variable defined.
Coverage.Codecov.submit_local(fcs)
function julia_query_git_info()
dir = pwd()
@info "" dir typeof(dir)

# In order to upload to Coveralls, you need to have the `COVERALLS_TOKEN` environment variable defined.
Coverage.Coveralls.submit_local(fcs)
repo = LibGit2.GitRepoExt(dir)
@info "" repo typeof(repo)

head = LibGit2.head(repo)
@info "" head typeof(head)

branch = LibGit2.shortname(head)
@info "" branch typeof(branch)

if strip(branch) == "HEAD"
branch = String(strip(read(`git rev-parse --abbrev-ref HEAD`, String)))
head = LibGit2.lookup_branch(repo, branch)
end

head_cmt = LibGit2.peel(head)
@info "" head_cmt typeof(head_cmt)

head_oid = LibGit2.GitHash(head_cmt)
@info "" head_oid typeof(head_oid)

commit_sha = string(head_oid)

author_name = string(LibGit2.author(head_cmt).name)

author_email = string(LibGit2.author(head_cmt).email)

committer_name = string(LibGit2.committer(head_cmt).name)

committer_email = string(LibGit2.committer(head_cmt).email)

message = LibGit2.message(head_cmt)

remote_name = "origin"

# determine remote url, but only if repo is not in detached state
remote = ""
if branch != "HEAD"
LibGit2.with(LibGit2.get(LibGit2.GitRemote, repo, remote_name)) do rmt
remote = LibGit2.url(rmt)
end
end
LibGit2.close(repo)

@info "" branch
if strip(branch) == "HEAD"
branch = String(strip(read(`git rev-parse --abbrev-ref HEAD`, String)))
end
@info "" branch

return Dict(
"branch" => branch,
"remotes" => [
Dict(
"name" => remote_name,
"url" => remote
)
],
"head" => Dict(
"id" => commit_sha,
"author_name" => author_name,
"author_email" => author_email,
"committer_name" => committer_name,
"committer_email" => committer_email,
"message" => message
)
)
end

let
git_info = julia_query_git_info()
@info "" git_info
@info "" git_info["branch"]

# In order to upload to Codecov, you need to have the `CODECOV_TOKEN` environment variable defined.
Coverage.Codecov.submit_local(fcs)
end

let
git_info = julia_query_git_info()
@info "" git_info
@info "" git_info["branch"]

# In order to upload to Coveralls, you need to have the `COVERALLS_TOKEN` environment variable defined.
Coverage.Coveralls.submit_local(fcs, git_info)
end

0 comments on commit 856f194

Please sign in to comment.