-
-
Notifications
You must be signed in to change notification settings - Fork 11.1k
Add new pr-publish command
#7202
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| require "cli/parser" | ||
| require "utils/github" | ||
|
|
||
| module Homebrew | ||
| module_function | ||
|
|
||
| def pr_publish_args | ||
| Homebrew::CLI::Parser.new do | ||
| usage_banner <<~EOS | ||
| `pr-publish` <pull_request> | ||
|
|
||
| Publishes bottles for a pull request with GitHub Actions. | ||
| Requires write access to the repository. | ||
| EOS | ||
| switch :verbose | ||
| end | ||
| end | ||
|
|
||
| def pr_publish | ||
| pr_publish_args.parse | ||
|
|
||
| odie "You need to specify a pull request number!" if Homebrew.args.named.empty? | ||
|
|
||
| args.named.each do |arg| | ||
| arg = "#{CoreTap.instance.default_remote}/pull/#{arg}" if arg.to_i.positive? | ||
| url_match = arg.match HOMEBREW_PULL_OR_COMMIT_URL_REGEX | ||
| _, user, repo, issue = *url_match | ||
| tap = Tap.fetch(user, repo) if repo.match?(HOMEBREW_OFFICIAL_REPO_PREFIXES_REGEX) | ||
| odie "Not a GitHub pull request: #{arg}" unless issue | ||
| ohai "Dispatching #{tap} pull request ##{issue}" | ||
| GitHub.dispatch(user, repo, "Publish ##{issue}", pull_request: issue) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could this (or a line after) output a URL that you can use to check progress? If not possible: no worries.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This unfortunately returns 204 No Content. We'd have to find it using another API call.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 😭. Even if it outputs the full PR URL somewhere that might be nice. Where does the "action" show up; just in the actions tab on the repo?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yup, just in the Actions tab. You can filter by actor and workflow type though which can help. In Linuxbrew/core we have @BrewTestBot ping the requestor when the upload job fails. This could be added to the workflow in Homebrew/core: https://github.com/Homebrew/linuxbrew-core/blob/3d460c215425e7d1547865ad0c2f5b4b7bce7dd7/.github/workflows/upload-bottles.yml#L165-L173
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeh, this would be great to have there too 👍 |
||
| end | ||
| end | ||
| end | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| require "cmd/shared_examples/args_parse" | ||
|
|
||
| describe "Homebrew.pr_publish_args" do | ||
| it_behaves_like "parseable arguments" | ||
| end |
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -431,6 +431,13 @@ def issue_comment_exists?(user, repo, pr, body) | |||||||||
| comments.any? { |comment| comment["body"].eql?(body) } | ||||||||||
| end | ||||||||||
|
|
||||||||||
| def dispatch(user, repo, event, **payload) | ||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
or
Suggested change
|
||||||||||
| url = "#{API_URL}/repos/#{user}/#{repo}/dispatches" | ||||||||||
| open_api(url, data: { event_type: event, client_payload: payload }, | ||||||||||
| request_method: :POST, | ||||||||||
| scopes: CREATE_ISSUE_FORK_OR_PR_SCOPES) | ||||||||||
| end | ||||||||||
|
|
||||||||||
| def api_errors | ||||||||||
| [GitHub::AuthenticationFailedError, GitHub::HTTPNotFoundError, | ||||||||||
| GitHub::RateLimitExceededError, GitHub::Error, JSON::ParserError].freeze | ||||||||||
|
|
||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jonchang This DSL would be preferable to use here