Before diving into the technical part of campaigns, make sure to read up on what campaigns are, what they're not and what we want them to be.
See "Campaigns design doc".
./enterprise/dev/start.sh
and wait until all repositories are cloned.The campaigns feature introduces a lot of new names, GraphQL queries and mutations and database tables. This section tries to explain the most common names and provide a mapping between the GraphQL types and their internal counterpart in the Go backend.
GraphQL type | Go type | Database table | Description |
---|---|---|---|
Campaign |
campaigns.Campaign |
campaigns |
A campaign is a collection of changesets. The central entity. |
ChangesetSpec |
campaigns.ChangesetSpec |
changeset_specs |
A changeset spec describes the desired state of a changeset. |
CampaignSpec |
campaigns.CampaignSpec |
campaign_specs |
A campaign spec describes the desired state of a campaign. |
ExternalChangeset |
campaigns.Changeset |
changesets |
Changeset is the unified name for pull requests/merge requests/etc. on code hosts. |
ChangesetEvent |
campaigns.ChangesetEvent |
changeset_events |
A changeset event is an event on a code host, e.g. a comment or a review on a pull request on GitHub. They are created by syncing the changesets from the code host on a regular basis and by accepting webhook events and turning them into changeset events. |
./cmd/frontend/graphqlbackend/campaigns.go
to get an overview of the campaigns GraphQL API../internal/campaigns/types.go
to see all campaigns-related type definitions../cmd/frontend/graphqlbackend/schema.graphql
../enterprise/internal/campaigns/resolvers/resolver.go
to see how the main mutation are implemented (look at createPatchSetFromPatches
and createCampaign
to see how the two main operations are implemented).enterprise/cmd/repo-updater/main.go
, and see how the enterprise repo-updater
uses campaigns.Syncer
to sync Changesets
.Campaigns create changesets (PRs) on code hosts. If you are not part of the Sourcegraph organization, we recommend you create dummy projects to safely test changes on so you do not spam real repositories with your tests. If you are part of the Sourcegraph organization, we have an account set up for this purpose.
To use this account, follow these steps:
sd9
user in 1PasswordCampaigns Testing Token
dev-private/enterprise/dev/external-services-config.json
to only contain a GitHub config with the token, like this:{ "GITHUB": [ { "authorization": {}, "url": "https://github.com", "token": "<TOKEN>", "repositoryQuery": ["affiliated"] } ] }