brew
brew copied to clipboard
Support caching of GitHub API responses
Verification
- [X] This issue's title and/or description do not reference a single formula e.g.
brew install wget
. If they do, open an issue at https://github.com/Homebrew/homebrew-core/issues/new/choose instead.
Provide a detailed description of the proposed feature
The GitHub REST API supports caching using the ETag
header.
What is the motivation for the feature?
We use the GitHub API in a number of places now, so it would be good to use caching to speed up queries and avoid rate limits.
This would be especially useful for brew bump
, which makes a large number of API queries in a single run.
How will the feature be relevant to at least 90% of Homebrew users?
It would make our CI run more efficiently, which impacts all Homebrew users.
What alternatives to the feature have been considered?
Doing nothing, or using existing ad-hoc caching methods, such as:
https://github.com/Homebrew/brew/blob/e9a1cd41d78c7c99ccf415be24727756cfa3ec5f/Library/Homebrew/utils/github.rb#L531-L545
See #15398 for additional context.
If it has no native dependencies: it may be worth exploring https://github.com/octokit/octokit.rb for our API usage. It has support for caching, pagination and various other things that would benefit us.
I just took a look at brew bump
and even though there are a high volume of GitHub requests it's not obvious to me that we're repeating any of them. How exactly is caching supposed to help with this command in particular?
I should clarify a little bit. I can see the benefit of doing some caching which could help with running commands like brew bump
locally. The trick would be caching between commands though. I'm not sure how useful that would be on CI though since I'm not sure how much we're guaranteed to use the same machine for multiple commands and how much overlap would exist between them.
@apainintheneck I think we'd need to rely on e.g. GitHub Actions caches to share some of this between runs.