This repository was archived by the owner on Aug 29, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
open PRs sequentially but continue updating branches in parallel #261
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Contributor
Author
|
@marten-seemann Have you had a chance to look at this? I'm interested to hear what you think about this approach. I was thinking of trying it out on the next major release of unified CI for Go. |
Contributor
Author
|
Merging - as per verbal approval from @laurentsenta |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #36 🤞
Description
When deploying changes to all the repositories, we're hitting a secondary rate limit due to opening too many PRs too quickly. I believe the only problematic call involved in the process is the Create a Pull Request API call. The documentation mentions that hitting the endpoint too quickly may lead to hitting the limit.
That's why I propose to reorganise the
dispatch/copy-workflowprocedure in the following way:copy-workflowwith the batch; for each target(in up to 20 parallel jobs):web3-bot/syncbranch IF there are any changescopy-workflowto completecopy-workflowthat pushed changes to remoteweb3-bot/syncbranchThe main idea here is to do as much of parallelisable work inside
copy-workflowand parallelise it as much as possible. That only leaves the PR creation calls to be executed sequentially. Furthermore, by executing PR creation calls conditionally(only if needed) we're able to keep the runtime when we only update a handful of repos small.We could further optimise this procedure by performing the PR creation part in parallel to
copy-workflowexecution. I think that would be possible because thecopy-workflowdoesn't execute any GH API calls. However, I propose that we postpone any work in this direction until we deem it necessary because it would add even more complexity to thedispatchworkflow.Removing PR create API call from
copy-workflowTo accomplish this I remove the use of
peter-evans/create-pull-requestcompletely and replace it with:These 2 commands ensure that our local state, after copying all the necessary files, is reflected in the remote
web3-bot/syncbranch. They are only executed if needed.Dispatching
copy-workflowand waiting for the completionUnfortunately,
benc-uk/workflow-dispatchis not capable of waiting for the dispatched workflow completion. It can also be replaced by a simplegh workflow runcall(ghis already installed on the runners) so I decided to do just that.Sadly, the latter doesn't know how to wait for the workflow completion either. Nor does it return the dispatched workflow
idso we have to be clever about acquiring it. I decided to:copy-workflow;copy-workflow;copy-workflowuntil it's start date is after the recorded timestamp;copy-workflow.This works because
copy-workflows are being dispatched sequentially which means there is never more than onecopy-workflowrunning at a time.Once we have the id in hand, we can use
gh run watchto wait for the run to complete.Finding all the repositories that need PRs created
Once again, the Actions framework doesn't make it easy to retrieve this information. It doesn't support job outputs from matrix jobs(or rather it does but it only persist the output of the latest job which is not useful here).
The workaround I came up with is to:
copy-workflow: conditionally execute the branch push step;dispatch:copy-workflowrun;{owner}/{repository}format.Creating the PRs
It can be achieved with
gh api -X POST "/repos/$job_name/pulls".I also added a 3 second sleep after the GH API call. I decided to choose 3 seconds because that value comes up in multiple places across GH API so there's a chance it's going to work here too.
Overhead
I ran
dispatchworkflow in my account to measure the overhead of this setup. To achieve this I:dispatchwith an echo,copy-workflow,copy-workflowwith an echo,This means that the overhead numbers are for a case where we have to create PRs(and sleep for 3 seconds) for all the repositories in the configuration.
copy-workflow+ 1m 51s
= 4m 44s
+ 4m 7s
= 9m 34s
Testing
.github-test-targetfrom testing: dispatch + copy-workflow + PRNext step ideas if needed