diff --git a/run/config.commentbot.toml b/run/config.commentbot.toml index 896746018b..0c578a05be 100644 --- a/run/config.commentbot.toml +++ b/run/config.commentbot.toml @@ -66,6 +66,9 @@ app_id = 12345 # The app ID for your GitHub app. This can be found in priv_pem = "private-key.pem" # The private key file of your GitHub app +api_url = "https://api.github.com" # This is the base url of the GitHub API. + # Needs to be changed in case of on-premise instances. + [commentbot.targets.qux] # You can define additional targets as [targets.baz], [targets.foo] etc. repo = "https://github.com/your_github_id/QuxRegistry" base_branch = "master" diff --git a/src/commentbot/CommentBot.jl b/src/commentbot/CommentBot.jl index 6150d7d5f4..93ac2df221 100644 --- a/src/commentbot/CommentBot.jl +++ b/src/commentbot/CommentBot.jl @@ -47,7 +47,7 @@ get_trigger_id(rp::RequestParams{CommitCommentTrigger}) = get_comment_commit_id( tag_name(version, subdir) = subdir == "" ? "v$version" : splitdir(subdir)[end] * "-v$version" -function make_pull_request(pp::ProcessedParams, rp::RequestParams, rbrn::RegBranch, target_registry::Dict{String,Any}) +function make_pull_request(api::GitHub.GitHubAPI, pp::ProcessedParams, rp::RequestParams, rbrn::RegBranch, target_registry::Dict{String,Any}) name = rbrn.name ver = rbrn.version brn = rbrn.branch @@ -92,7 +92,7 @@ function make_pull_request(pp::ProcessedParams, rp::RequestParams, rbrn::RegBran ) repo = join(split(target_registry["repo"], "/")[end-1:end], "/") - pr, msg = create_or_find_pull_request(repo, params, rbrn) + pr, msg = create_or_find_pull_request(api, repo, params, rbrn) tag = tag_name(ver, subdir) cbody = """ @@ -115,7 +115,7 @@ function make_pull_request(pp::ProcessedParams, rp::RequestParams, rbrn::RegBran end @debug(cbody) - make_comment(rp.evt, cbody) + make_comment(api, rp.evt, cbody) return pr end @@ -123,7 +123,7 @@ string(::RequestParams{PullRequestTrigger}) = "pull_request" string(::RequestParams{CommitCommentTrigger}) = "commit_comment" string(::RequestParams{IssueTrigger}) = "issue" -function action(rp::RequestParams{T}, zsock::RequestSocket) where T <: RegisterTrigger +function action(api::GitHub.GitHubAPI, rp::RequestParams{T}, zsock::RequestSocket) where T <: RegisterTrigger if rp.target === nothing target_registry_name, target_registry = first(CONFIG["targets"]) else @@ -131,15 +131,15 @@ function action(rp::RequestParams{T}, zsock::RequestSocket) where T <: RegisterT if length(filteredtargets) == 0 msg = "Error: target $(rp.target) not found" @debug(msg) - make_comment(rp.evt, msg) - set_error_status(rp) + make_comment(api, rp.evt, msg) + set_error_status(api, rp) return else target_registry_name, target_registry = filteredtargets[1] end end - pp = ProcessedParams(rp) + pp = ProcessedParams(api, rp) @info("Processing register event", reponame=rp.reponame, target_registry_name) try if pp.cparams.isvalid @@ -161,53 +161,53 @@ function action(rp::RequestParams{T}, zsock::RequestSocket) where T <: RegisterT msg = "Error while trying to register: $(rbrn.metadata["error"])" end @debug(msg) - make_comment(rp.evt, msg) - set_error_status(rp) + make_comment(api, rp.evt, msg) + set_error_status(api, rp) else - make_pull_request(pp, rp, rbrn, target_registry) - set_success_status(rp) + make_pull_request(api, pp, rp, rbrn, target_registry) + set_success_status(api, rp) end else @info("Error while processing event: $(repr(pp.cparams.error))") if pp.cparams.report_error msg = "Error while trying to register: $(repr(pp.cparams.error))" @debug(msg) - make_comment(rp.evt, msg) + make_comment(api, rp.evt, msg) end - set_error_status(rp) + set_error_status(api, rp) end catch ex bt = get_backtrace(ex) @info("Unexpected error: $bt") - raise_issue(rp.evt, rp.phrase, bt) + raise_issue(api, rp.evt, rp.phrase, bt) end @info("Done processing register event", reponame=rp.reponame, target_registry_name) nothing end -function comment_handler(event::WebhookEvent, phrase::RegexMatch) +function comment_handler(api::GitHub.GitHubAPI, event::WebhookEvent, phrase::RegexMatch) @debug("Received event for $(event.repository.full_name), phrase: $phrase") try - rp = RequestParams(event, phrase) + rp = RequestParams(api, event, phrase) isa(rp.trigger_src, EmptyTrigger) && rp.cparams.error === nothing && return if rp.cparams.isvalid && rp.cparams.error === nothing print_entry_log(rp) put!(event_queue, rp) - set_pending_status(rp) + set_pending_status(api, rp) elseif rp.cparams.error !== nothing @info("Error while processing event: $(rp.cparams.error)") if rp.cparams.report_error msg = "Error while trying to register: $(rp.cparams.error)" @debug(msg) - make_comment(event, msg) + make_comment(api, event, msg) end - set_error_status(rp) + set_error_status(api, rp) end catch ex bt = get_backtrace(ex) @info("Unexpected error: $bt") - raise_issue(event, phrase, bt) + raise_issue(api, event, phrase, bt) end return HTTP.Messages.Response(200) @@ -229,14 +229,15 @@ function github_webhook(http_ip=CONFIG["http_ip"], recover("github_webhook", keep_running, do_action, handle_exception) end -function request_processor(zsock::RequestSocket) - do_action() = action(take!(event_queue), zsock) +function request_processor(api::GitHub.GitHubAPI, zsock::RequestSocket) + do_action() = action(api, take!(event_queue), zsock) handle_exception(ex) = (isa(ex, InvalidStateException) && (ex.state == :closed)) ? :exit : :continue keep_running() = isopen(httpsock[]) recover("request_processor", keep_running, do_action, handle_exception) end function main(config::AbstractString=isempty(ARGS) ? "config.toml" : first(ARGS); kwargs...) + # todo: here make api merge!(CONFIG, Pkg.TOML.parsefile(config)["commentbot"]) if get(CONFIG, "enable_logging", true) global_logger(SimpleLogger(stdout, get_log_level(CONFIG["log_level"]))) @@ -244,7 +245,8 @@ function main(config::AbstractString=isempty(ARGS) ? "config.toml" : first(ARGS) zsock = RequestSocket(get(CONFIG, "backend_port", 5555)) @info("Starting server...") - t1 = @async request_processor(zsock) + api = GitHubWebAPI(HTTP.URI(get(CONFIG, "api_url", "https://api.github.com"))) + t1 = @async request_processor(api, zsock) t2 = @async status_monitor(CONFIG["stop_file"], event_queue, httpsock) github_webhook(; kwargs...) wait(t1) diff --git a/src/commentbot/approval.jl b/src/commentbot/approval.jl index b05b63dc34..6e4783e14e 100644 --- a/src/commentbot/approval.jl +++ b/src/commentbot/approval.jl @@ -1,8 +1,8 @@ -function tag_package(rname, ver::VersionNumber, mcs, auth; tag_name = "v$ver") +function tag_package(api::GitHub.GitHubAPI, rname, ver::VersionNumber, mcs, auth; tag_name = "v$ver") tagger = Dict("name" => CONFIG["github"]["user"], "email" => CONFIG["github"]["email"], "date" => Dates.format(now(), dateformat"YYYY-mm-ddTHH:MM:SSZ")) - create_tag(rname; auth=auth, + create_tag(api, rname; auth=auth, params=Dict("tag" => tag_name, "message" => "Release: $tag_name", "object" => mcs, @@ -10,11 +10,11 @@ function tag_package(rname, ver::VersionNumber, mcs, auth; tag_name = "v$ver") "tagger" => tagger)) end -function get_metadata_from_pr_body(rp::RequestParams, auth) +function get_metadata_from_pr_body(api::GitHub.GitHubAPI, rp::RequestParams, auth) reg_name = rp.reponame reg_prid = rp.trigger_src.prid - pr = pull_request(reg_name, reg_prid; auth=auth) + pr = pull_request(api, reg_name, reg_prid; auth=auth) mstart = match(r"", pr.body) @@ -31,9 +31,9 @@ function get_metadata_from_pr_body(rp::RequestParams, auth) nothing end -function handle_approval(rp::RequestParams{ApprovalTrigger}) - auth = get_access_token(rp.evt) - d = get_metadata_from_pr_body(rp, auth) +function handle_approval(api::GitHub.GitHubAPI, rp::RequestParams{ApprovalTrigger}) + auth = get_access_token(api, rp.evt) + d = get_metadata_from_pr_body(api, rp, auth) if d === nothing return "Unable to get registration metdata for this PR" @@ -49,11 +49,11 @@ function handle_approval(rp::RequestParams{ApprovalTrigger}) subdir = d["subdir"] if request_type == "pull_request" - pr = pull_request(reponame, trigger_id; auth=auth) + pr = pull_request(api, reponame, trigger_id; auth=auth) tree_sha = pr.merge_commit_sha if pr.state == "open" @debug("Merging pull request on package repo", reponame, trigger_id) - merge_pull_request(reponame, trigger_id; auth=auth, + merge_pull_request(api, reponame, trigger_id; auth=auth, params=Dict("merge_method" => "squash")) else @debug("Pull request already merged", reponame, trigger_id) @@ -85,7 +85,7 @@ function handle_approval(rp::RequestParams{ApprovalTrigger}) if !tag_exists @debug("Creating new tag", reponame, ver, tree_sha) - tag_package(reponame, ver, tree_sha, auth; tag_name = tag) + tag_package(api, reponame, ver, tree_sha, auth; tag_name = tag) end release_exists = false @@ -117,10 +117,10 @@ function handle_approval(rp::RequestParams{ApprovalTrigger}) end end - reg_pr = pull_request(reg_name, reg_prid; auth=auth) + reg_pr = pull_request(api, reg_name, reg_prid; auth=auth) if reg_pr.state == "open" @debug("Merging pull request on registry", reg_name, reg_prid) - merge_pull_request(reg_name, reg_prid; auth=auth) + merge_pull_request(api, reg_name, reg_prid; auth=auth) else @debug("Pull request on registry already merged", reg_name, reg_prid) end @@ -131,18 +131,18 @@ function print_entry_log(rp::RequestParams{ApprovalTrigger}) @info "Approving Pull request" reponame=rp.reponame prid=rp.trigger_src.prid end -function action(rp::RequestParams{ApprovalTrigger}, zsock) +function action(api::GitHub.GitHubAPI, rp::RequestParams{ApprovalTrigger}, zsock) @info("Processing approval event", reponame=rp.reponame, rp.trigger_src.prid) try - err = handle_approval(rp) + err = handle_approval(api, rp) if err !== nothing @debug(err) - make_comment(rp.evt, "Error in approval process: $err") + make_comment(api, rp.evt, "Error in approval process: $err") end catch ex bt = get_backtrace(ex) @info("Unexpected error: $bt") - raise_issue(rp.evt, rp.phrase, bt) + raise_issue(api, rp.evt, rp.phrase, bt) end @info("Done processing approval event", reponame=rp.reponame, rp.trigger_src.prid) end diff --git a/src/commentbot/github_utils.jl b/src/commentbot/github_utils.jl index 22fb2a6d4d..fba2344638 100644 --- a/src/commentbot/github_utils.jl +++ b/src/commentbot/github_utils.jl @@ -7,13 +7,13 @@ function register_rights_error(evt, user) end end -get_access_token(event) = create_access_token(Installation(event.payload["installation"]), get_jwt_auth()) -get_user_auth() = GitHub.authenticate(CONFIG["github"]["token"]) +get_access_token(api::GitHub.GitHubAPI, event) = create_access_token(api, Installation(event.payload["installation"]), get_jwt_auth()) +get_user_auth(api::GitHub.GitHubAPI) = GitHub.authenticate(api, CONFIG["github"]["token"]) get_jwt_auth() = GitHub.JWTAuth(CONFIG["github"]["app_id"], CONFIG["github"]["priv_pem"]) -function get_sha_from_branch(reponame, brn; auth = GitHub.AnonymousAuth()) +function get_sha_from_branch(api::GitHub.GitHubAPI, reponame, brn; auth = GitHub.AnonymousAuth()) try - b = branch(reponame, Branch(brn); auth=auth) + b = branch(api, reponame, Branch(brn); auth=auth) sha = b.sha !== nothing ? b.sha : b.commit.sha return sha, nothing catch ex @@ -30,26 +30,26 @@ end is_owned_by_organization(event) = event.repository.owner.typ == "Organization" -function is_comment_by_collaborator(event) +function is_comment_by_collaborator(api::GitHub.GitHubAPI, event) @debug("Checking if comment is by collaborator") user = get_user_login(event.payload) user == "github-actions[bot]" && return true - return iscollaborator(event.repository, user; auth=get_access_token(event)) + return iscollaborator(api, event.repository, user; auth=get_access_token(api, event)) end -function is_comment_by_org_owner_or_member(event) +function is_comment_by_org_owner_or_member(api::GitHub.GitHubAPI, event) @debug("Checking if comment is by repository parent organization owner or member") org = event.repository.owner.login user = get_user_login(event.payload) user == "github-actions[bot]" && return true if get(CONFIG, "check_private_membership", false) - return GitHub.check_membership(org, user; auth=get_user_auth()) + return GitHub.check_membership(org, user; auth=get_user_auth(api)) else return GitHub.check_membership(org, user; public_only=true) end end -has_register_rights(event) = is_comment_by_collaborator(event) || is_owned_by_organization(event) && is_comment_by_org_owner_or_member(event) +has_register_rights(api::GitHub.GitHubAPI, event) = is_comment_by_collaborator(api, event) || is_owned_by_organization(event) && is_comment_by_org_owner_or_member(api, event) is_pull_request(payload::Dict{<:AbstractString}) = haskey(payload, "pull_request") || haskey(payload, "issue") && haskey(payload["issue"], "pull_request") is_commit_comment(payload::Dict{<:AbstractString}) = haskey(payload, "comment") && !haskey(payload, "issue") @@ -67,13 +67,13 @@ end get_comment_commit_id(event) = event.payload["comment"]["commit_id"] get_clone_url(event) = event.payload["repository"]["clone_url"] -function make_comment(evt::WebhookEvent, body::AbstractString) +function make_comment(api::GitHub.GitHubAPI, evt::WebhookEvent, body::AbstractString) CONFIG["reply_comment"] || return @debug("Posting comment to PR/issue") headers = Dict("private_token" => CONFIG["github"]["token"]) params = Dict("body" => body) repo = evt.repository - auth = get_user_auth() + auth = get_user_auth(api) if is_commit_comment(evt.payload) GitHub.create_comment(repo, get_comment_commit_id(evt), :commit; headers=headers, @@ -102,7 +102,7 @@ function get_html_url(payload::Dict{<:AbstractString}) end """ - raise_issue(event::WebhookEvent, phrase::RegexMatch, bt::String) + raise_issue(api::GitHub.GitHubAPI, event::WebhookEvent, phrase::RegexMatch, bt::String) Open an issue in the configured Registrator repository. The issue body will contain the trigger comment `phrase` and the backtrace in `bt`. A link to the opened issue will be posted on the source @@ -111,7 +111,7 @@ issue, PR or commit from which the `event` comes from. This will also post the backtrace on the slack channel if configured. """ -function raise_issue(event::WebhookEvent, phrase::RegexMatch, bt::String) +function raise_issue(api::GitHub.GitHubAPI, event::WebhookEvent, phrase::RegexMatch, bt::String) repo = event.repository.full_name lab = is_commit_comment(event.payload) ? get_comment_commit_id(event) : get_prid(event.payload) title = "Error registering $repo#$lab" @@ -134,18 +134,18 @@ function raise_issue(event::WebhookEvent, phrase::RegexMatch, bt::String) if CONFIG["report_issue"] params = Dict("title"=>title, "body"=>body) regrepo = CONFIG["issue_repo"] - iss = create_issue(regrepo; params=params, auth=get_user_auth()) + iss = create_issue(regrepo; params=params, auth=get_user_auth(api)) msg = "Unexpected error occurred during registration, see issue: [$(regrepo)#$(iss.number)]($(iss.html_url))" @debug(msg) - make_comment(event, msg) + make_comment(api, event, msg) else msg = "An unexpected error occurred during registration." @debug(msg) - make_comment(event, msg) + make_comment(api, event, msg) end end -function set_status(rp, state, desc) +function set_status(api::GitHub.GitHubAPI, rp, state, desc) CONFIG["set_status"] || return repo = rp.reponame kind = rp.evt.kind @@ -156,14 +156,14 @@ function set_status(rp, state, desc) "context" => CONFIG["github"]["user"], "description" => desc) GitHub.create_status(repo, commit; - auth=get_access_token(rp.evt), + auth=get_access_token(api, rp.evt), params=params) end end -set_pending_status(rp) = set_status(rp, "pending", "Processing request...") -set_error_status(rp) = set_status(rp, "error", "Failed to register") -set_success_status(rp) = set_status(rp, "success", "Done") +set_pending_status(api::GitHub.GitHubAPI, rp) = set_status(api, rp, "pending", "Processing request...") +set_error_status(api::GitHub.GitHubAPI, rp) = set_status(api, rp, "error", "Failed to register") +set_success_status(api::GitHub.GitHubAPI, rp) = set_status(api, rp, "success", "Done") function parse_github_exception(ex::ErrorException) msgs = map(strip, split(ex.msg, '\n')) @@ -214,19 +214,20 @@ end const REGISTRATOR_CONTROLLED_LABELS = ["new package", "major release", "minor release", "patch release", "BREAKING"] -function create_or_find_pull_request(repo::AbstractString, +function create_or_find_pull_request(api::GitHub.GitHubAPI, + repo::AbstractString, params::Dict{<:AbstractString, Any}, rbrn::RegBranch) pr = nothing msg = "" - auth = get_user_auth() + auth = get_user_auth(api) try - pr = create_pull_request(repo; auth=auth, params=params) + pr = create_pull_request(api, repo; auth=auth, params=params) msg = "created" @debug("Pull request created") try # add labels if get(rbrn.metadata, "labels", nothing) !== nothing - add_labels(repo, pr, rbrn.metadata["labels"]; auth=auth) + add_labels(api, repo, pr, rbrn.metadata["labels"]; auth=auth) end catch @debug "Failed to add labels, ignoring." @@ -241,7 +242,7 @@ function create_or_find_pull_request(repo::AbstractString, end if pr === nothing - prs, _ = pull_requests(repo; auth=auth, params=Dict( + prs, _ = pull_requests(api, repo; auth=auth, params=Dict( "state" => "open", "base" => params["base"], "head" => string(split(repo, "/")[1], ":", params["head"]), @@ -255,12 +256,12 @@ function create_or_find_pull_request(repo::AbstractString, if pr === nothing error("Registration PR already exists but unable to find it") else - update_pull_request(repo, pr.number; auth=auth, params=Dict("body" => params["body"], "title" => params["title"])) + update_pull_request(api, repo, pr.number; auth=auth, params=Dict("body" => params["body"], "title" => params["title"])) try # update labels if get(rbrn.metadata, "labels", nothing) !== nothing # Remove existing labels we control if they are not # in `rbrn.metadata["labels"]` - existing_labels = [l.name for l in labels(repo, pr; auth=auth)] + existing_labels = [l.name for l in labels(api, repo, pr; auth=auth)] for label in existing_labels label in REGISTRATOR_CONTROLLED_LABELS || continue label in rbrn.metadata["labels"] && continue @@ -269,7 +270,7 @@ function create_or_find_pull_request(repo::AbstractString, # Add any labels in `rbrn.metadata["labels"]` that don't # already exist in the PR. labels_to_add = setdiff(rbrn.metadata["labels"], existing_labels) - add_labels(repo, pr, labels_to_add; auth=auth) + add_labels(api, repo, pr, labels_to_add; auth=auth) end catch @debug "Failed to update labels, ignoring." diff --git a/src/commentbot/param_types.jl b/src/commentbot/param_types.jl index fdb4a57dd5..f85b9b4b2b 100644 --- a/src/commentbot/param_types.jl +++ b/src/commentbot/param_types.jl @@ -15,7 +15,7 @@ struct RequestParams{T<:RequestTrigger} subdir::String cparams::CommonParams - function RequestParams(evt::WebhookEvent, phrase::RegexMatch) + function RequestParams(api::GitHub.GitHubAPI, evt::WebhookEvent, phrase::RegexMatch) reponame = evt.repository.full_name user = get_user_login(evt.payload) trigger_src = EmptyTrigger() @@ -43,14 +43,14 @@ struct RequestParams{T<:RequestTrigger} err = "Private package registration request received, ignoring" @debug(err) elseif action_name == "register" - commenter_can_register = has_register_rights(evt) + commenter_can_register = has_register_rights(api, evt) if commenter_can_register @debug("Commenter has registration rights") notes_match = match(r"(?:patch|release) notes:(.*)"si, get_body(evt.payload)) notes = notes_match === nothing ? "" : strip(notes_match[1]) if is_pull_request(evt.payload) if CONFIG["disable_pull_request_trigger"] - make_comment(evt, "Comments on pull requests will not trigger Registrator, as it is disabled. Please try commenting on a commit or issue.") + make_comment(api, evt, "Comments on pull requests will not trigger Registrator, as it is disabled. Please try commenting on a commit or issue.") else @debug("Comment is on a pull request") prid = get_prid(evt.payload) @@ -72,12 +72,12 @@ struct RequestParams{T<:RequestTrigger} @debug("Comment is on a pull request") elseif action_name == "approved" if CONFIG["disable_approval_process"] - make_comment(evt, "The `approved()` command is disabled.") + make_comment(api, evt, "The `approved()` command is disabled.") else registry_repos = [join(split(r["repo"], "/")[end-1:end], "/") for (n, r) in CONFIG["targets"]] if reponame in registry_repos @debug("Recieved approval comment") - commenter_can_register = has_register_rights(evt) + commenter_can_register = has_register_rights(api, evt) if commenter_can_register @debug("Commenter has register rights") if is_pull_request(evt.payload) @@ -108,24 +108,24 @@ struct RequestParams{T<:RequestTrigger} end end -function get_cloneurl_and_sha(rp::RequestParams{PullRequestTrigger}, auth) - pr = pull_request(rp.reponame, rp.trigger_src.prid; auth=auth) +function get_cloneurl_and_sha(api::GitHub.GitHubAPI, rp::RequestParams{PullRequestTrigger}, auth) + pr = pull_request(api, rp.reponame, rp.trigger_src.prid; auth=auth) cloneurl = pr.head.repo.html_url.uri * ".git" sha = pr.head.sha cloneurl, sha, nothing end -function get_cloneurl_and_sha(rp::RequestParams{CommitCommentTrigger}, auth) +function get_cloneurl_and_sha(api::GitHub.GitHubAPI, rp::RequestParams{CommitCommentTrigger}, auth) cloneurl = get_clone_url(rp.evt) sha = get_comment_commit_id(rp.evt) cloneurl, sha, nothing end -function get_cloneurl_and_sha(rp::RequestParams{IssueTrigger}, auth) +function get_cloneurl_and_sha(api::GitHub.GitHubAPI, rp::RequestParams{IssueTrigger}, auth) cloneurl = get_clone_url(rp.evt) - sha, err = get_sha_from_branch(rp.reponame, rp.trigger_src.branch; auth=auth) + sha, err = get_sha_from_branch(api, rp.reponame, rp.trigger_src.branch; auth=auth) cloneurl, sha, err end @@ -165,7 +165,7 @@ struct ProcessedParams cloneurl::Union{Nothing, String} cparams::CommonParams - function ProcessedParams(rp::RequestParams) + function ProcessedParams(api::GitHub.GitHubAPI, rp::RequestParams) if rp.cparams.error !== nothing @debug("Pre-check failed, not processing RequestParams: $(rp.cparams.error)") return ProcessedParams(nothing, nothing, copy(rp.cparams)) @@ -182,15 +182,15 @@ struct ProcessedParams is_private = rp.evt.payload["repository"]["private"] if is_private - auth = get_access_token(rp.evt) + auth = get_access_token(api, rp.evt) else auth = GitHub.AnonymousAuth() end - cloneurl, sha, err = get_cloneurl_and_sha(rp, auth) + cloneurl, sha, err = get_cloneurl_and_sha(api, rp, auth) if err === nothing && sha !== nothing - project, tree_sha, projectfile_found, projectfile_valid, err = verify_projectfile_from_sha(rp.reponame, sha; auth = auth, subdir = rp.subdir) + project, tree_sha, projectfile_found, projectfile_valid, err = verify_projectfile_from_sha(api, rp.reponame, sha; auth = auth, subdir = rp.subdir) if !projectfile_found err = "File (Julia)Project.toml not found" @debug(err) diff --git a/src/commentbot/verify_projectfile.jl b/src/commentbot/verify_projectfile.jl index 291687fa58..f67b6b53f8 100644 --- a/src/commentbot/verify_projectfile.jl +++ b/src/commentbot/verify_projectfile.jl @@ -47,7 +47,7 @@ function pfile_hasfields(p::Pkg.Types.Project) return true, nothing end -function verify_projectfile_from_sha(reponame, commit_sha; auth=GitHub.AnonymousAuth(), subdir = "") +function verify_projectfile_from_sha(api::GitHub.GitHubAPI, reponame, commit_sha; auth=GitHub.AnonymousAuth(), subdir = "") project = nothing projectfile_found = false projectfile_valid = false @@ -69,7 +69,7 @@ function verify_projectfile_from_sha(reponame, commit_sha; auth=GitHub.Anonymous @debug("Getting projectfile blob") if isa(auth, GitHub.AnonymousAuth) - a = get_user_auth() + a = get_user_auth(api) else a = auth end