Adds a new:
- gazelle generator
- rule + rule targets + catchall target
for generating go-mockgen mocks & testing for their being up-to-date.
Each go_mockgen macro invocation adds targets for generating mocks, copying to the source tree, as well as testing whether the current source tree mocks are up-to-date.
How to use this: `bazel run //dev:go_mockgen` for the catch-all, or `bazel run //some/target:generate_mocks` for an individual package, and `bazel test //some/target:generate_mocks_tests` to test for up-to-date-ness. There is no catch-all for testing
This currently uses a fork of go-mockgen, with an open PR for upstream here: https://github.com/derision-test/go-mockgen/pull/50.
Closes https://github.com/sourcegraph/sourcegraph/issues/60099
## Test plan
Extensive testing during development, including the following cases:
- Deleting a generated file and its entry in a go_library/go_test `srcs` attribute list and then re-running `sg bazel configure`
- Adding a non-existent output directory to mockgen.test.yaml and running the bash one-liner emitted to prepare the workspace for rerunning `sg bazel configure`
The existing config tests a lot of existing paths anyway (creating mocks for a 3rd party library's interface, entries for a given output file in >1 config file etc)
This is a bigger change than I want, but the version of exp/slices we
used had a change from taking a Less func for SortFunc to a Compare. To
update a vulnerability we also bring in a new version of exp/slices, so
I seperated out this change.
All our uses of exp/slices are now covered by the stdlib, so I migrate
all our uses to it. In particular this mostly meant updating custom Less
functions to using the stdlib cmp.Compare.
The only functional change was a potential bug I found in
filter_file_contains.go. The comment for the sort says sort by Start
offset, but the code was incorrectly comparing the end offset for the
2nd argument. This makes sort's Less function break the expected
invariants, so the code was quite wrong. I expect in practice we didn't
notice it since most ranges did not overlap. This fix makes the compare
function respect the expected invariants and just seems correct.
Test Plan: CI and grep returns nothing for "golang.org/x/exp/slices" in
go files.
Cody no longer needs it and it is obsolete now!
Since App added a non-insignificant amount of new concepts and alternative code paths, I decided to take some time and remove it from out codebase.
This PR removes ~21k lines of code. If we ever want parts of single binary (app), the redis kv alternatives, or the release pipeline for a native mac app back, we can look back at this PR and revert parts of it, but maintaining 21k lines of code and many code paths for which I had to delete a surprisingly small amount of tests justifies this move for me very well.
Technically, to some extent SG App and Cody App both still existed in the codebase, but we don't distribute either of them anymore, so IMO we shouldn't keep this weight in our code.
So.. here we go.
This should not affect any of the existing deployments, we only remove functionality that was special-cased for app.
This PR proposes a new pattern for instantiating gitserver clients.
When we instantiate a new gitserver client, we should pass in a scope, a description of the environment it's used in.
When a client is passed down to an environment, we can augment the client with an additional scope.
What is this for?
Looking at Grafana charts for dotcom, we see that we make about 2000 requests per second to gitserver. We know what endpoints we're hitting, and what _container_ is making the request.
In Sourcegraph, containers are not a great boundary for services though. Some components stretch across multiple containers, and one container runs many different components, for example our worker container.
While there are probably at least 50 routines owned by various different teams in that container, our current metrics only tell us that worker is making a large amount of requests.
But we don't know who to talk to about it, because, again, worker is basically every team.
With scopes, we get more fine-grained insights and can group the metric by (container, op, scope), to get full insight into what _component_ (not _container_) is talking to gitserver.
* log: remove use of description paramter in Scoped
* temporarily point to sglog branch
* bazel configure + gazelle
* remove additional use of description param
* use latest versions of zoekt,log,mountinfo
* go.mod
support single-program execution
Now, `sg start single-program` starts a single-binary local dev server. This is similar to Cody app, but instead of using a Tauri desktop app UI and limiting to only Cody-related functionality, it runs a full Sourcegraph instance and lets you access it through your web browser. It is useful for local dev because it's less resource-intensive and has faster recompile/relink times than `sg start` (which runs many processes).