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

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