tkf / BenchmarkCI.jl
Showing 1 of 1 files from the diff.

@@ -62,6 +62,17 @@
Loading
62 62
    return d
63 63
end
64 64
65 +
function setnested!(d0, v, keys...)
66 +
    d = d0
67 +
    for k in keys[1:end-1]
68 +
        d = get!(d, k, empty(d0))
69 +
    end
70 +
    d[keys[end]] = v
71 +
    return d
72 +
end
73 +
74 +
mirrornested!(dest, src, keys...) = setnested!(dest, getnested(src, keys...), keys...)
75 +
65 76
is_in_ci(ENV = ENV) =
66 77
    lowercase(get(ENV, "CI", "false")) == "true" || haskey(ENV, "GITHUB_EVENT_PATH")
67 78
@@ -508,13 +519,10 @@
Loading
508 519
509 520
struct GitHubCommitInfo
510 521
    repo_url::Union{Nothing,String}
511 -
    pull_request_commit_sha::Union{Nothing,String}
512 -
    pull_request_url::Union{Nothing,String}
513 -
    pull_request_title::Union{Nothing,String}
522 +
    pull_request::Dict{String,Any}
514 523
end
515 524
516 -
GitHubCommitInfo() =
517 -
    GitHubCommitInfo(nothing, nothing, nothing, nothing)
525 +
GitHubCommitInfo() = GitHubCommitInfo(nothing, Dict{String,Any})
518 526
519 527
function github_commit_info()
520 528
    commit_info::GitHubCommitInfo = GitHubCommitInfo()
@@ -523,11 +531,22 @@
Loading
523 531
    event_path === nothing && return commit_info
524 532
    event = JSON.parsefile(event_path)
525 533
534 +
    # https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads#pull_request
526 535
    if get(ENV, "GITHUB_EVENT_NAME", nothing) == "pull_request"
527 -
        @set! commit_info.pull_request_url = getnested(event, "pull_request", "html_url")
528 -
        @set! commit_info.pull_request_title = getnested(event, "pull_request", "title")
529 -
        @set! commit_info.pull_request_commit_sha =
530 -
            getnested(event, "pull_request", "head", "sha")
536 +
        if (pull_request = get(event, "pull_request", nothing)) !== nothing
537 +
            for keys in Tuple[
538 +
                ("html_url",),
539 +
                ("title",),
540 +
                ("user", "login"),
541 +
                ("head", "sha"),
542 +
                ("head", "ref"),
543 +
                ("head", "repo", "html_url"),
544 +
                ("base", "sha"),
545 +
                ("base", "ref"),
546 +
            ]
547 +
                mirrornested!(commit_info.pull_request, pull_request, keys...)
548 +
            end
549 +
        end
531 550
    end
532 551
533 552
    @set! commit_info.repo_url = getnested(event, "repository", "html_url")
@@ -536,11 +555,16 @@
Loading
536 555
end
537 556
538 557
function printinfomd(io, commit_info::GitHubCommitInfo)
539 -
    @unpack repo_url, pull_request_commit_sha, pull_request_url, pull_request_title =
540 -
        commit_info
558 +
    @unpack repo_url, pull_request = commit_info
559 +
    pull_request_url = getnested(pull_request, "html_url")
560 +
    pull_request_title = getnested(pull_request, "title")
561 +
    pull_request_commit_sha = getnested(pull_request, "head", "ref")
562 +
    target_commit_url = nothing
563 +
541 564
    if repo_url !== nothing && pull_request_commit_sha !== nothing
542 565
        target_commit_url = "$repo_url/commit/$pull_request_commit_sha"
543 566
    end
567 +
544 568
    if target_commit_url !== nothing
545 569
        println(
546 570
            io,
Files Coverage
src 60.63%
Project Totals (3 files) 60.63%
Untitled

No yaml found.

Create your codecov.yml to customize your Codecov experience

Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading