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

cleanup_before: untap unneeded taps on GitHub-hosted runners #1250

Merged
merged 2 commits into from
Oct 2, 2024

Conversation

ZhongRuoyu
Copy link
Member

Should help us get rid of the strange warnings seen in 1. aws/tap/aws-sam-cli calls opoo unconditionally once evaluated 2. The tap aws/tap is installed on GitHub-hosted runners, and we evaluate all formulae when determining the dependents of testing formulae.

A more ideal and comprehensive solution would be to untap all unneeded taps by (recursively) determining which taps are actually needed by the formulae in the testing tap, but that requires evaluating all formulae in the testing tap and can be a bit more work. And in the end, for third-party taps, doing that will still not eliminate the warnings if a dependency has an unconditional opoo call like that. So for now, I'm restricting the cleanup to homebrew/core.

Footnotes

  1. https://github.com/Homebrew/homebrew-core/actions/runs/11148695947/job/30986582554?pr=192640

  2. https://github.com/aws/homebrew-tap/blob/f2dcc08fa89256b3893a6cfc82e3ac71b05ce28e/Formula/_aws-sam-cli.rb#L58

Should help us get rid of the strange warnings seen in [^1].
`aws/tap/aws-sam-cli` calls `opoo` unconditionally once evaluated [^2].
The tap `aws/tap` is installed on GitHub-hosted runners, and we evaluate
all formulae when determining the dependents of testing formulae.

A more ideal and comprehensive solution would be to untap all unneeded
taps by (recursively) determining which taps are actually needed by the
formulae in the testing tap, but that requires evaluating all formulae
in the testing tap and can be a bit more work. And in the end, for
third-party taps, doing that will still not eliminate the warnings if
a dependency has an unconditional `opoo` call like that. So for now, I'm
restricting the cleanup to `homebrew/core`.

[^1]: https://github.com/Homebrew/homebrew-core/actions/runs/11148695947/job/30986582554?pr=192640
[^2]: https://github.com/aws/homebrew-tap/blob/f2dcc08fa89256b3893a6cfc82e3ac71b05ce28e/Formula/_aws-sam-cli.rb#L58
Copy link
Member

@p-linnane p-linnane left a comment

Choose a reason for hiding this comment

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

Awesome, thanks!

@ZhongRuoyu ZhongRuoyu merged commit ff3e015 into master Oct 2, 2024
4 checks passed
@ZhongRuoyu ZhongRuoyu deleted the untap-unneeded-taps branch October 2, 2024 18:39
@Bo98
Copy link
Member

Bo98 commented Oct 2, 2024

# Keep all "brew" invocations after HOMEBREW_REPOSITORY operations
# (which cleans up Homebrew/brew)
taps_to_remove = Tap.map do |t|
next if t.name == tap&.name
next if ALLOWED_TAPS.include?(t.name)
t.path
end.uniq.compact
delete_or_move taps_to_remove
is already meant to do this but I guess it isn't working?

Comment on lines +53 to +57
if on_github_hosted_runner && tap.to_s == CoreTap.instance.name
(installed_taps - REQUIRED_TAPS).each do |tap|
test "brew", "untap", tap
end
end
Copy link
Member

@Bo98 Bo98 Oct 2, 2024

Choose a reason for hiding this comment

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

Won't this untap homebrew/core? It is not a required tap.

Copy link
Member Author

@ZhongRuoyu ZhongRuoyu Oct 2, 2024

Choose a reason for hiding this comment

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

Whoops -- I misread REQUIRED_TAPS as there was a CoreTap.instance.name below but that's ALLOWED_TAPS.

@MikeMcQuaid
Copy link
Member

Thanks @ZhongRuoyu, this needed reverted but I still think this approach is worth pursuing!

is already meant to do this but I guess it isn't working?

Yes, I think it'd be good to fixup that logic to handle this as expected.

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.

4 participants