Skip to content

Backend: New campaign flow

Created by: eseliger

Docs/Schema in PR #10921

STATUS: WIP pull request is https://github.com/sourcegraph/sourcegraph/pull/11675 and the tasks below as a WIP until we've done 3.19 planning.

Conceptual/Docs/GraphQL Schema

The PR in which these higher-level changes should be proposed/made/discussed is https://github.com/sourcegraph/sourcegraph/pull/10921

  • Schema for tracking existing changesets in campaign-spec.yml

Implementation Backend

The list below is not complete, but a rough overview of what has been done and needs to be done:

  • Pull in the GraphQL schema from https://github.com/sourcegraph/sourcegraph/pull/10921 as a skeleton (with only "TODOs" as implementation)
  • Remove GraphQL resolvers and majority of campaigns.Service methods that were only used in old workflow (I decided to keep the type definitions and database tables for Patch/PatchSet/ChangesetJob around, even though I anticipate that we will need to remove them)
  • Add campaign_specs & changeset_specs database tables, Go type definitions and methods in campaigns.Store
  • Add CampaignSpecByID query and CampaignSpec resolver (some methods still have TODOs)
  • Add ChangesetSpecByID query and ChangesetSpec resolver (some methods still have TODOs)
  • Implement createChangesetSpec mutation
  • Implement createCampaignSpec mutation
  • Implement applyCampaignSpec
  • Implement moveCampaign mutation
  • Update the GraphQL API to reflect newest state in #10921
  • Move fields from CampaignSpec.Spec to ChangesetSpec.Description after newest updates to #10921
  • Validate CampaignSpec in (*Service).CreateCampaignSpec (depends on schema, see above)
  • Validate ChangesetSpec in (*Service).CreateChangesetSpec (depends on schema, see above)
  • Allow on: (unquoted!) in YAML definition of CampaignSpec
  • Expire {Campaign,Changeset}Specs
    • Return proper value in {Campaign,Changeset} Spec.ExpiresAt
  • Implement ChangesetSpec/CampaignSpec resolvers so that CampaignSpec.PreviewURL works
  • In createCampaignSpec check the user has access to the namespace it's creating the spec for.
  • In moveCampaign check the user has access to the new namespace.
  • Implement Changeset.Status API
    • Add new state field to Changeset
    • Create "pending"/"unpublished" changesets when applying a CampaignSpec
      • Add internal state field to changesets
      • Add changeset_spec_id to changesets
    • ... many more things I have in a separate list
  • Implement the Reconciler that picks up unreconciled campaigns and creates the desired state
  • Implement tracking/importing of manual changesets