eps1lon / actions-label-merge-conflict

GitHub action that adds a label once a PR has merge conflicts
47 stars 16 forks source link

Option to throttle the action #86

Open bryangingechen opened 2 years ago

bryangingechen commented 2 years ago

Hi, thanks for this very convenient action! We've been using it for a while at https://github.com/leanprover-community/mathlib (see here), but recently the action has been failing on every run with the error:

Error: GraphqlError: API rate limit exceeded for user ID XXXX. Error: API rate limit exceeded for user ID XXXX.

I suspect this is because we have a large number of open PRs (565 at the moment, but we're steadily approaching 600) and the action is making a large number of API calls in a short period of time.

Would it be possible to add an option to throttle the rate of calls somehow so that we can keep using your action? Thanks!

eps1lon commented 2 years ago

I suspect that's very hard to do since that would introduce statefulnes into the action. Have you checked if there are existing patterns that can throttle entire runs instead if single actions?

bryangingechen commented 2 years ago

I hadn't. I might be misunderstanding your suggestion, but our workflow only runs this one action once every 15 minutes (and we're even using a GitHub token from an account dedicated to this workflow, so that our other workflows don't contribute to the API limit).

What sort of thing did you have in mind?

eps1lon commented 2 years ago

If you already throttle the action what would be achieved if the action itself throttles? I don't see how the action could throttle that couldn't be achieved at the workflow level.

The only implementation I can see for throttling at the action level would involve adding statefulness i.e. each action call needs to be aware of the previous calls. I wouldn't know where to begin with implementations. If you have a concrete implementation in form of a PR I can take a look.

bryangingechen commented 2 years ago

Hmm, perhaps I wasn't being clear. What I had in mind was more along the lines of adding a (user-specified?) pause after each iteration of this for loop. That way the GitHub API calls can be spread out and we can hopefully avoid getting rate limited.