-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
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
cmd/install: infer --overwrite
when in GitHub Actions
#18612
base: master
Are you sure you want to change the base?
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 |
---|---|---|
|
@@ -281,6 +281,33 @@ def run | |
puts "You're on your own. Failures are expected so don't create any issues, please!" | ||
end | ||
|
||
overwrite = if !args.overwrite? && | ||
GitHub::Actions.env_set? && | ||
ENV["HOMEBREW_GITHUB_ACTIONS_NO_INSTALL_OVERWRITE"].blank? && | ||
ENV["HOMEBREW_GITHUB_ACTIONS"].blank? | ||
if ENV["HOMEBREW_GITHUB_ACTIONS_NO_INSTALL_OVERWRITE_WARNING"].blank? | ||
message = <<~WARNING | ||
In GitHub Actions, `brew install` behaves the same as `brew install --overwrite`. | ||
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, sorry to be a pain here: this definitely feels like an overly broad change. Would like to see this scoped to only Python for now and we can consider widening it in future if desired. |
||
|
||
To disable this behaviour, set `HOMEBREW_GITHUB_ACTIONS_NO_INSTALL_OVERWRITE`. | ||
|
||
To silence this warning, set `HOMEBREW_GITHUB_ACTIONS_NO_INSTALL_OVERWRITE_WARNING` or pass `--overwrite` to `brew install`. | ||
WARNING | ||
|
||
puts GitHub::Actions::Annotation.new(:warning, message) | ||
|
||
# Print warning only once. | ||
github_env = ENV.fetch("GITHUB_ENV", "") | ||
if File.exist?(github_env) && File.writable?(github_env) | ||
File.open(github_env, "a") { |f| f.puts("HOMEBREW_GITHUB_ACTIONS_NO_INSTALL_OVERWRITE_WARNING=1") } | ||
end | ||
Comment on lines
+299
to
+303
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. I'm 50-50 about this bit, and don't mind dropping it. 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. Also don't feel strongly either way. If it's Python only: can drop. |
||
end | ||
|
||
true | ||
else | ||
args.overwrite? | ||
end | ||
|
||
installed_formulae = formulae.select do |f| | ||
Install.install_formula?( | ||
f, | ||
|
@@ -289,7 +316,7 @@ def run | |
only_dependencies: args.only_dependencies?, | ||
force: args.force?, | ||
quiet: args.quiet?, | ||
overwrite: args.overwrite?, | ||
overwrite:, | ||
) | ||
end | ||
|
||
|
@@ -313,7 +340,7 @@ def run | |
keep_tmp: args.keep_tmp?, | ||
debug_symbols: args.debug_symbols?, | ||
force: args.force?, | ||
overwrite: args.overwrite?, | ||
overwrite:, | ||
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 approach doesn't quite work, unfortunately. This is because the 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. Passed it on to dependencies in 79959ca. 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.
I don't think it should. |
||
debug: args.debug?, | ||
quiet: args.quiet?, | ||
verbose: args.verbose?, | ||
|
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.
Should we document this in
env_config.rb
?would be my preferred naming format, for consistency