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

cmd/install: infer --overwrite when in GitHub Actions #18612

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

carlocab
Copy link
Member

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes? Here's an example.
  • Have you successfully run brew style with your changes locally?
  • Have you successfully run brew typecheck with your changes locally?
  • Have you successfully run brew tests with your changes locally?

Based on discussion at Homebrew/homebrew-core#195288.

I was initially inclined to scope this only to Python, but I think it
makes sense to apply more generally. The issue is that users often have
no control over what's already inside HOMEBREW_PREFIX when they run
brew install. Given that, I think it makes sense to assume users want
--overwrite unless configured otherwise with
HOMEBREW_GITHUB_ACTIONS_NO_INSTALL_OVERWRITE.

Based on discussion at Homebrew/homebrew-core#195288.

I was initially inclined to scope this only to Python, but I think it
makes sense to apply more generally. The issue is that users often have
no control over what's already inside `HOMEBREW_PREFIX` when they run
`brew install`. Given that, I think it makes sense to assume users want
`--overwrite` unless configured otherwise with
`HOMEBREW_GITHUB_ACTIONS_NO_INSTALL_OVERWRITE`.
Comment on lines +315 to +319
# 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
Copy link
Member Author

Choose a reason for hiding this comment

The 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.

Copy link
Member

Choose a reason for hiding this comment

The 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.

@@ -313,7 +339,7 @@ def run
keep_tmp: args.keep_tmp?,
debug_symbols: args.debug_symbols?,
force: args.force?,
overwrite: args.overwrite?,
overwrite:,
Copy link
Member Author

@carlocab carlocab Oct 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This approach doesn't quite work, unfortunately. This is because the --overwrite flag doesn't propagate to dependencies. Should it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Passed it on to dependencies in 79959ca.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This approach doesn't quite work, unfortunately. This is because the --overwrite flag doesn't propagate to dependencies. Should it?

I don't think it should.

@@ -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? &&
Copy link
Member

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?

Suggested change
ENV["HOMEBREW_GITHUB_ACTIONS_NO_INSTALL_OVERWRITE"].blank? &&
ENV["HOMEBREW_NO_GITHUB_ACTIONS_INSTALL_OVERWRITE"].blank? &&

would be my preferred naming format, for consistency

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`.
Copy link
Member

Choose a reason for hiding this comment

The 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.

Comment on lines +315 to +319
# 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
Copy link
Member

Choose a reason for hiding this comment

The 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.

@@ -313,7 +339,7 @@ def run
keep_tmp: args.keep_tmp?,
debug_symbols: args.debug_symbols?,
force: args.force?,
overwrite: args.overwrite?,
overwrite:,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This approach doesn't quite work, unfortunately. This is because the --overwrite flag doesn't propagate to dependencies. Should it?

I don't think it should.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants