Closed mrnugget closed 4 years ago
check that it's finished executing its CampaignJobs
If this is not true at the time the client calls createCampaign
with a CampaignPlan
id, we can't proceed in creating branches in git-server and everything that follows, which makes me think this needs to be processed, again, as some sort of background job pulled from a durable queue.
I'm thinking that repo-updater can periodically load all pending campaign jobs that have an associated campaign (via a campaign plan) and process them then.
Well, actually, the documentation in the schema says the mutation should error if the plan hasn't completed yet, so I guess that makes things simpler.
This is part of RFC 42. Read this section details.
When the
createCampaign
mutation is called with aCampaignPlan
ID the following needs to happen:Diff
s of theCampaignPlan
'sCampaignJobs
are turned into commits in their respective repositoriesChangeset
scampaignResolver.ChangesetCreationStatus
Technical Notes
(These do not cover everything in this issue, but are more of a braindump to help with the implementation)
The starting point is the
CreateCampaign
resolver here.This ticket is about the case where a
CampaignPlanID
is given in the arguments. If none is given, the existing code is executed.If a CampaignPlan is given, we need to:
CampaignPlan
CampaignJob
CampaignJobs
CampaignJobs
Diff to commit
The
Diff
,RepoID
,Rev
fields onCampaignJob
should be enough create a commit by talking togitserver
. Maybe we can useCreateCommitFromPatch
on thegitserver.Client
for this. Maybe it needs to be extended.Commits should probably all be created under
sourcegraph/*
branches or any other naming scheme that's explicit.After the commit is created, we need functionality in
gitserver
to push the newly-created branch.We also need to make sure that the newly-created branch/commit is not cleaned up by
gitserver'
s GC processes before we push it.Creating Pull Requests
Once the commit/branch have been pushed, we need to use a
CreatePullRequest
method on the code host clients to create a pull request from branch/commit.At the time of writing, these have not been implemented yet.
Pull requests to Changesets
Each created pull request needs to be turned into a
Changeset
and added to theCampaign
.Retrying
Keep in mind that
Creating Pull Requests
andPUll requests to Changesets
might fail and that the whole process ofCampaignJobs -> Pull Requests & Changesets
need to be idempotently retryable. This issue here does not cover the retry-functionality, but it is something to keep in mind.Clean up?
After the
CampaignJobs
have been successfully turned intoChangesets
, we probably want to "freeze" (or even clean up?) theCampaignJobs
.