sourcegraph / sourcegraph-public-snapshot

Code AI platform with Code Search & Cody
https://sourcegraph.com
Other
10.11k stars 1.29k forks source link

batches: automatically configure webhooks wherever possible #42028

Open LawnGnome opened 2 years ago

LawnGnome commented 2 years ago

One of our biggest issues in Batch Changes is getting site admins to enable and configure webhooks. It's painful to do, since it has to be per-repo or (at best) per-org depending on the code host, and yet it's basically the difference between Batch Changes being usable and not much of the time. Anecdotally, it feels like we've seen an uptick in webhook-related support issues of late.

Our longer term plans for dealing with this have tended to be either eventually writing a GitHub App to fix this, or hoping that site-wide webhooks will do the job (which we've recently discovered they likely won't, because they don't get down to this level of granularity).

Meanwhile, it turns out that we got a rudimentary background worker to configure webhooks automatically in #39992 and #39833. (Who knew? Certainly not me. I stumbled across this while starting to build the same thing on a rainy Friday afternoon.)

This would be extremely useful for Batch Changes!

Unfortunately, it has a few drawbacks right now:

  1. It only supports GitHub.
  2. It only adds the push event type, which is useful for repo updates, but not for Batch Changes.
  3. It attempts to write the webhook configuration back to the external service configuration, which will fail if an overlay file is in use.
  4. There are some things hard coded in github.V3Client that probably shouldn't be, like the event types and the string to search for to consider a particular webhook a "Sourcegraph webhook".
  5. It's off by default, and turning it on is hidden behind an experimentalFeatures site configuration flag.

So, let's make it better so we can turn it on by default and our users can enjoy the benefits of having webhooks Just Work.

Rough plan of attack for GitHub:

Future incremental work:

Nice to haves:

chrispine commented 2 years ago

@malomarrec Thoughts on the priority of webhook related work? Feels like it comes after strategic readiness, so backlog, but wanted to hear what you thought.

courier-new commented 2 years ago

There's some active conversation around webhooks that Ryan Slade's driving here that may influence who/how/when we pick this up. I'd actually argue adequate automation around webhooks is incredibly important to strategic customers, for 2 reasons:

courier-new commented 2 years ago

This is also effectively tackling the same problem and serving as a direct complement to https://github.com/sourcegraph/sourcegraph/issues/24312, which has been a long-standing fave item on our board.

LawnGnome commented 2 years ago

Yeah, I'm going to take this off the board for now because Ryan and Alex are basically working on this already. This may come back later as a more tightly scoped ticket if I end up pitching in to help after outbound webhooks.