This repository was archived by the owner on Sep 30, 2024. It is now read-only.
frontend: add a dot-com API endpoint caching src versions by branch#40827
Merged
Conversation
Contributor
|
Codenotify: Notifying subscribers in CODENOTIFY files for diff bb543fa...2c274de.
|
eseliger
approved these changes
Aug 25, 2022
eseliger
left a comment
Member
There was a problem hiding this comment.
Wow, so much stuff you implemented here, even webhooks to make it close to real time! Great work, also on all the testing!
Piszmog
approved these changes
Aug 25, 2022
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
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.
This PR adds a simple version cache to the unauthenticated external REST API that reports the most recent version of src-cli for the given branch. This is the backend that will address #39468, but #40828 also has to be merged for this to be fully fixed.
The intention is that the sourcegraph.com deployment will enable the cache, and no other deployments will ever configure it.
The minimal configuration that will be required on sourcegraph.com will be:
{ "dotcom": { "srcCliVersionCache": { "enabled": true, "github": { "token": "TOKEN", "webhookSecret": "WEBHOOK_SECRET" } } } }This will need to be combined with a GitHub webhook on https://github.com/sourcegraph/src-cli that points to https://sourcegraph.com/.api/src-cli/versions/webhook, configured with the same
WEBHOOK_SECRETand with thereleaseevent type enabled.Probable questions
Why not use the
SOURCEGRAPHDOTCOM_MODEenvironment variable?This PR adds a small configuration section to the
dotcomsite configuration object that enables and configures the cache, but does not use theSOURCEGRAPHDOTCOM_MODEenvironment variable.This is both to simplify testing and reduce the matrix of possible configuration options. With this implementation, there are only two possible states: configuration present and enabled, in which case this API will respond, and literally anything else, in which case this API will 404 like any other unknown endpoint.
Why is the handler always installed?
Originally, I had the handler only conditionally hooked up if the configuration was enabled. However, it's considerably simpler if it's always present, since it means we can handle all the enable/disable behaviour in a single configuration watcher, and from a user perspective the disabled handler is indistinguishable from the route not existing in the router.
Test plan
This has (IMHO) good test coverage, and I've given it a pretty good hammering in the last day or so locally as part of developing this and #40828.