brew icon indicating copy to clipboard operation
brew copied to clipboard

Support caching of GitHub API responses

Open carlocab opened this issue 1 year ago • 5 comments

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

carlocab avatar Jun 05 '23 06:06 carlocab

See #15398 for additional context.

carlocab avatar Jun 05 '23 06:06 carlocab

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.

MikeMcQuaid avatar Jun 05 '23 13:06 MikeMcQuaid

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?

apainintheneck avatar Aug 13 '23 01:08 apainintheneck

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 avatar Aug 13 '23 02:08 apainintheneck

@apainintheneck I think we'd need to rely on e.g. GitHub Actions caches to share some of this between runs.

MikeMcQuaid avatar Aug 14 '23 11:08 MikeMcQuaid