Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bors: require that Buildkite passes on Julia nightly #181

Closed

Conversation

DilumAluthge
Copy link
Collaborator

No description provided.

@DilumAluthge
Copy link
Collaborator Author

DilumAluthge commented Jan 8, 2021

For posterity, here is how I generated this list: (click to expand)

Step 1: Save the following code in a file named get-github-status-list.jl:

import GitHub

const BRANCH_OR_COMMIT = Union{GitHub.Branch, GitHub.Commit}

struct AlwaysAssertionError
    msg::String
end

function always_assert(condition::Bool, msg::String)
    if !condition
        throw(AlwaysAssertionError(msg))
    end
    return nothing
end

function _get_branch(repo;
                     api::GitHub.GitHubAPI,
                     auth::GitHub.Authorization,
                     branch)
    return GitHub.branch(api, repo, branch; auth = auth)
end

function _get_commit(repo;
                     api::GitHub.GitHubAPI,
                     auth::GitHub.Authorization,
                     commit)
    return GitHub.commit(api, repo, commit; auth = auth)
end

function _get_commit_or_branch(repo;
                               api::GitHub.GitHubAPI,
                               auth::GitHub.Authorization,
                               branch = nothing,
                               commit = nothing)
    if (branch isa Nothing) && (commit isa Nothing)
        msg = string(
            "You must provide either ",
            "the branch or the commit",
        )
        throw(ArgumentError(msg))
    elseif (!(branch isa Nothing)) && (!(commit isa Nothing))
        msg = string(
            "You cannot provide both ",
            "a branch and a commit. ",
            "You must provide exactly one.",
        )
        throw(ArgumentError(msg))
    elseif (!(branch isa Nothing))
        return _get_branch(repo; api=api, auth=auth, branch=branch)
    else
        always_assert(!(commit isa Nothing), "!(commit isa Nothing)")
        return _get_commit(repo; api = api, auth = auth, commit = commit)
    end
end

function get_statuses(repo;
                      api::GitHub.GitHubAPI,
                      auth::GitHub.Authorization,
                      branch,
                      commit)
    branch_or_commit = _get_commit_or_branch(
        repo;
        api = api,
        auth = auth,
        branch = branch,
        commit = commit,
    )
    return get_statuses(repo, branch_or_commit; api, auth)
end

function get_statuses(repo,
                      branch_or_commit::BRANCH_OR_COMMIT;
                      api::GitHub.GitHubAPI,
                      auth::GitHub.Authorization)
    combined_status = GitHub.status(
        api,
        repo,
        branch_or_commit;
        auth = auth,
    )
    combined_status_statuses = combined_status.statuses
    statuses, _ = GitHub.statuses(
        api,
        repo,
        branch_or_commit;
        auth = auth,
    )
    status_contexts = vcat(
        [x.context for x in combined_status_statuses],
        [x.context for x in statuses],
    )
    unique!(status_contexts)
    sort!(status_contexts)
    return status_contexts
end

function _convert_to_commit(repo,
                            branch::GitHub.Branch;
                            api::GitHub.GitHubAPI,
                            auth::GitHub.Authorization)
    commit = GitHub.commit(api, repo, branch; auth = auth)
    return commit
end

function _convert_to_commit(repo,
                            commit::GitHub.Commit;
                            api::GitHub.GitHubAPI,
                            auth::GitHub.Authorization)
    return commit
end

function _get_commit_sha_from_commit(commit::GitHub.Commit)
    return commit.sha
end

function get_check_runs(repo;
                        api::GitHub.GitHubAPI,
                        auth::GitHub.Authorization,
                        branch,
                        commit)
    return nothing
end

function get_check_runs(repo,
                        branch_or_commit::BRANCH_OR_COMMIT;
                        api::GitHub.GitHubAPI,
                        auth::GitHub.Authorization)
    commit = _convert_to_commit(
        repo,
        branch_or_commit;
        api = api,
        auth = auth,
    )
    commit_sha = _get_commit_sha_from_commit(commit)
    endpoint = "/repos/$(repo.full_name)/commits/$(commit_sha)/check-runs"
    check_runs = GitHub.gh_get_json(
        api,
        endpoint;
        auth = auth,
    )
    check_run_names = [x["name"] for x in check_runs["check_runs"]]
    unique!(check_run_names)
    sort!(check_run_names)
    return check_run_names
end

function get_statuses_and_check_runs(repo;
                                     api::GitHub.GitHubAPI,
                                     auth::GitHub.Authorization,
                                     branch,
                                     commit)
    status_contexts_and_check_run_names = get_statuses_and_check_runs(
        repo,
        branch_or_commit;
        api = api,
        auth = auth)
    unique!(status_contexts_and_check_run_names)
    sort!(status_contexts_and_check_run_names)
    return status_contexts_and_check_run_names
end

function get_statuses_and_check_runs(repo,
                                     branch_or_commit::BRANCH_OR_COMMIT;
                                     api::GitHub.GitHubAPI,
                                     auth::GitHub.Authorization)

    status_contexts = get_statuses(
        repo,
        branch_or_commit;
        api = api,
        auth = auth,
    )
    check_run_names = get_check_runs(
        repo,
        branch_or_commit;
        api = api,
        auth = auth,
    )
    status_contexts_and_check_run_names = vcat(
        status_contexts,
        check_run_names,
    )
    unique!(status_contexts_and_check_run_names)
    sort!(status_contexts_and_check_run_names)
    return status_contexts_and_check_run_names
end

Step 2: Open a Julia REPL and run the following: (change branch_name to whichever branch you want to reference)

include("get-github-status-list.jl")
import GitHub
api = GitHub.DEFAULT_API
auth = GitHub.AnonymousAuth()
repo = GitHub.repo(api, "JuliaGPU/KernelAbstractions.jl"; auth = auth);
branch_name = "master"
branch = _get_commit_or_branch(repo; api = api, auth = auth, branch = branch_name);
@show get_statuses_and_check_runs(repo, branch; api = api, auth = auth)

Here is the output that I receive: (change branch_name to whichever branch you want to reference)

julia> include("get-github-status-list.jl")
get_statuses_and_check_runs (generic function with 2 methods)

julia> import GitHub

julia> api = GitHub.DEFAULT_API
GitHub.GitHubWebAPI(URI("https://api.github.com"))

julia> auth = GitHub.AnonymousAuth()
GitHub.AnonymousAuth()

julia> auth = GitHub.authenticate(ENV["GITHUB_TOKEN"])
GitHub.OAuth2(475be0**********************************)

julia> repo = GitHub.repo(api, "JuliaGPU/KernelAbstractions.jl"; auth = auth);

julia> branch_name = "master"
"master"

julia> branch = _get_commit_or_branch(repo; api = api, auth = auth, branch = branch_name);


julia> @show get_statuses_and_check_runs(repo, branch; api = api, auth = auth)
get_statuses_and_check_runs(repo, branch; api = api, auth = auth) = ["CI (1, macOS-latest, x64)", "CI (1, ubuntu-latest, x64)", "CI (1, windows-latest, x64)", "CI (1.3, macOS-latest, x64)", "CI (1.3, ubuntu-latest, x64)", "CI (1.3, windows-latest, x64)", "CI (1.4, macOS-latest, x64)", "CI (1.4, ubuntu-latest, x64)", "CI (1.4, windows-latest, x64)", "CI (1.5, macOS-latest, x64)", "CI (1.5, ubuntu-latest, x64)", "CI (1.5, windows-latest, x64)", "CI-julia-nightly (nightly, macOS-latest, x64)", "CI-julia-nightly (nightly, ubuntu-latest, x64)", "CI-julia-nightly (nightly, windows-latest, x64)", "Doctests", "Documentation", "buildkite/kernelabstractions-dot-jl", "buildkite/kernelabstractions-dot-jl/julia-1-dot-5", "buildkite/kernelabstractions-dot-jl/julia-nightly", "buildkite/kernelabstractions-dot-jl/pipeline", "documenter/deploy"]
22-element Vector{String}:
 "CI (1, macOS-latest, x64)"
 "CI (1, ubuntu-latest, x64)"
 "CI (1, windows-latest, x64)"
 "CI (1.3, macOS-latest, x64)"
 "CI (1.3, ubuntu-latest, x64)"
 "CI (1.3, windows-latest, x64)"
 "CI (1.4, macOS-latest, x64)"
 "CI (1.4, ubuntu-latest, x64)"
 "CI (1.4, windows-latest, x64)"
 "CI (1.5, macOS-latest, x64)"
 "CI (1.5, ubuntu-latest, x64)"
 "CI (1.5, windows-latest, x64)"
 "CI-julia-nightly (nightly, macOS-latest, x64)"
 "CI-julia-nightly (nightly, ubuntu-latest, x64)"
 "CI-julia-nightly (nightly, windows-latest, x64)"
 "Doctests"
 "Documentation"
 "buildkite/kernelabstractions-dot-jl"
 "buildkite/kernelabstractions-dot-jl/julia-1-dot-5"
 "buildkite/kernelabstractions-dot-jl/julia-nightly"
 "buildkite/kernelabstractions-dot-jl/pipeline"
 "documenter/deploy"

@JuliaGPU JuliaGPU deleted a comment from bors bot Jan 8, 2021
@DilumAluthge DilumAluthge force-pushed the dpa/bors-statuses-buildkite-github-actions branch from a257100 to 8a22b41 Compare January 8, 2021 05:46
bors bot added a commit that referenced this pull request Jan 8, 2021
@DilumAluthge
Copy link
Collaborator Author

@vchuravy @simeonschaub

@DilumAluthge DilumAluthge force-pushed the dpa/bors-statuses-buildkite-github-actions branch 2 times, most recently from f16fa22 to 9515e22 Compare January 8, 2021 08:44
@DilumAluthge DilumAluthge changed the title Bors: require that GHA and Buildkite pass on Julia nightly Bors: require that Buildkite passes on Julia nightly Jan 8, 2021
@DilumAluthge DilumAluthge force-pushed the dpa/bors-statuses-buildkite-github-actions branch from 9515e22 to 35e44c1 Compare January 8, 2021 09:31
@DilumAluthge
Copy link
Collaborator Author

bors try

bors bot added a commit that referenced this pull request Jan 8, 2021
@JuliaGPU JuliaGPU deleted a comment from bors bot Jan 8, 2021
@bors
Copy link
Contributor

bors bot commented Jan 8, 2021

try

Build failed:

@DilumAluthge DilumAluthge added bors and removed bors labels Jan 8, 2021
@DilumAluthge DilumAluthge deleted the dpa/bors-statuses-buildkite-github-actions branch January 8, 2021 19:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant