From bc6a79171098f6619aef59503c4b8d45db7930c5 Mon Sep 17 00:00:00 2001 From: Jean-Hadrien Chabran Date: Wed, 1 Mar 2023 18:03:01 +0100 Subject: [PATCH] bazel: fix remaining backend tests (#47961) This PR fixes the last round of backend tests that are getting in the way. While most fixes are pertaining to adapting the code to deal with the sandbox, or adjusting targets in some cases, we had to ignore the tests from the database stitch migration (see https://github.com/sourcegraph/sourcegraph/pull/47961/commits/123cb550050ae817524e8b06abc1bbdfcb184f88) (cc @efritz) because they are making strong assumptions toward running inside the Sourcegraph repository, which is kinda non trivial to adapt. Another one, albeit non consequential is the disabling of some tests peforming external requests, which I think should be deleted anyway (https://github.com/sourcegraph/sourcegraph/pull/47961/commits/c83d8ebba88ad08b4cacaf9b3898c1ba7e0e63cb) Fix https://github.com/sourcegraph/sourcegraph/issues/46837 Fix https://github.com/sourcegraph/sourcegraph/issues/46856 Fix https://github.com/sourcegraph/sourcegraph/issues/46862 Fix https://github.com/sourcegraph/sourcegraph/issues/46864 Fix https://github.com/sourcegraph/sourcegraph/issues/46833 Fix https://github.com/sourcegraph/sourcegraph/issues/46835 Fix https://github.com/sourcegraph/sourcegraph/issues/46836 Fix https://github.com/sourcegraph/sourcegraph/issues/46847 Fix https://github.com/sourcegraph/sourcegraph/issues/46838 Fix https://github.com/sourcegraph/sourcegraph/issues/46843 Fix https://github.com/sourcegraph/sourcegraph/issues/46845 Fix https://github.com/sourcegraph/sourcegraph/issues/46849 Fix https://github.com/sourcegraph/sourcegraph/issues/46851 Fix https://github.com/sourcegraph/sourcegraph/issues/46855 Fix https://github.com/sourcegraph/sourcegraph/issues/46857 Fix https://github.com/sourcegraph/sourcegraph/issues/46858 Fix https://github.com/sourcegraph/sourcegraph/issues/46859 Fix https://github.com/sourcegraph/sourcegraph/issues/46861 Fix https://github.com/sourcegraph/sourcegraph/issues/46863 Fix https://github.com/sourcegraph/sourcegraph/issues/46865 Fix https://github.com/sourcegraph/sourcegraph/issues/46867 Fix https://github.com/sourcegraph/sourcegraph/issues/46853 ## Test plan Ran locally with bazel. --------- Co-authored-by: davejrt --- .golangci.yml | 1 + client/web/BUILD.bazel | 1 - cmd/blobstore/internal/blobstore/BUILD.bazel | 1 + cmd/frontend/auth/BUILD.bazel | 1 + cmd/frontend/backend/BUILD.bazel | 6 -- cmd/frontend/graphqlbackend/BUILD.bazel | 25 ++++++-- cmd/frontend/internal/app/BUILD.bazel | 1 + .../internal/app/jscontext/BUILD.bazel | 2 + .../internal/app/otlpadapter/BUILD.bazel | 16 +++-- cmd/frontend/internal/app/ui/BUILD.bazel | 3 +- .../internal/auth/accessrequest/BUILD.bazel | 37 +++++++++++ cmd/frontend/internal/bg/BUILD.bazel | 4 ++ cmd/frontend/internal/cli/config.go | 2 +- cmd/frontend/internal/handlerutil/BUILD.bazel | 1 - cmd/frontend/internal/highlight/BUILD.bazel | 5 ++ cmd/frontend/registry/api/BUILD.bazel | 31 +--------- cmd/gitserver/server/BUILD.bazel | 4 +- cmd/gitserver/server/cleanup_test.go | 4 +- cmd/gitserver/shared/BUILD.bazel | 2 - cmd/repo-updater/repoupdater/BUILD.bazel | 9 +++ cmd/repo-updater/shared/BUILD.bazel | 5 ++ cmd/searcher/internal/search/BUILD.bazel | 4 +- cmd/searcher/shared/BUILD.bazel | 2 - cmd/server/shared/BUILD.bazel | 1 + cmd/server/shared/assets/BUILD.bazel | 6 ++ cmd/symbols/internal/api/BUILD.bazel | 6 +- cmd/symbols/squirrel/BUILD.bazel | 1 + cmd/worker/internal/migrations/BUILD.bazel | 16 ++++- .../internal/outboundwebhooks/BUILD.bazel | 2 +- dev/build-tracker/BUILD.bazel | 2 +- dev/buildchecker/BUILD.bazel | 2 +- .../cmd/app-discover-repos/BUILD.bazel | 18 ++++++ dev/perforce/anonymiser/BUILD.bazel | 2 +- dev/scaletesting/bulkrepocreate/BUILD.bazel | 2 +- dev/scaletesting/bulkreposettings/BUILD.bazel | 2 +- dev/scaletesting/codehostcopy/BUILD.bazel | 2 +- .../syntheticgithubdata/BUILD.bazel | 2 +- dev/sg/BUILD.bazel | 2 +- dev/sg/internal/check/BUILD.bazel | 4 +- dev/sg/internal/generate/golang/BUILD.bazel | 2 +- dev/sg/internal/images/BUILD.bazel | 2 +- dev/sg/internal/migration/BUILD.bazel | 2 +- enterprise/cmd/embeddings/BUILD.bazel | 18 ++++++ enterprise/cmd/embeddings/shared/BUILD.bazel | 62 +++++++++++++++++++ .../internal/apiclient/files/BUILD.bazel | 2 + .../internal/apiclient/queue/BUILD.bazel | 5 +- .../cmd/executor/internal/command/BUILD.bazel | 4 +- .../cmd/executor/internal/config/BUILD.bazel | 2 +- .../cmd/executor/internal/run/BUILD.bazel | 2 +- .../cmd/executor/internal/worker/BUILD.bazel | 4 +- .../internal/worker/workspace/BUILD.bazel | 2 +- .../cmd/frontend/internal/auth/BUILD.bazel | 1 + .../internal/auth/azureoauth/BUILD.bazel | 49 +++++++++++++++ .../frontend/internal/auth/oauth/BUILD.bazel | 2 + .../internal/authz/resolvers/BUILD.bazel | 7 +-- .../internal/batches/resolvers/BUILD.bazel | 1 + .../frontend/internal/completions/BUILD.bazel | 17 +++++ .../completions/streaming/BUILD.bazel | 18 ++++++ .../streaming/anthropic/BUILD.bazel | 34 ++++++++++ .../streaming/anthropic/anthropic_test.go | 4 +- .../internal/completions/types/BUILD.bazel | 9 +++ .../internal/compute/resolvers/BUILD.bazel | 2 +- .../internal/compute/streaming/BUILD.bazel | 2 +- .../frontend/internal/embeddings/BUILD.bazel | 20 ++++++ .../internal/embeddings/resolvers/BUILD.bazel | 19 ++++++ .../internal/executorqueue/BUILD.bazel | 13 +++- .../executorqueue/handler/BUILD.bazel | 21 +++++-- .../executorqueue/queues/batches/BUILD.bazel | 4 +- .../queues/codeintel/BUILD.bazel | 4 +- .../internal/insights/resolvers/BUILD.bazel | 2 +- .../cmd/frontend/internal/own/BUILD.bazel | 2 + .../internal/own/resolvers/BUILD.bazel | 28 ++++++++- .../internal/repos/webhooks/BUILD.bazel | 6 ++ enterprise/cmd/frontend/shared/BUILD.bazel | 2 + .../repo-updater/internal/authz/BUILD.bazel | 6 +- .../cmd/worker/internal/codeintel/BUILD.bazel | 1 + .../embeddings/contextdetection/BUILD.bazel | 33 ++++++++++ .../internal/embeddings/repo/BUILD.bazel | 34 ++++++++++ .../cmd/worker/internal/telemetry/BUILD.bazel | 2 +- enterprise/cmd/worker/shared/BUILD.bazel | 2 + enterprise/dev/ci/internal/ci/BUILD.bazel | 1 + .../dev/ci/scripts/app-token/BUILD.bazel | 1 + .../dev/ci/scripts/app-token/main_test.go | 4 ++ .../internal/authz/perforce/BUILD.bazel | 2 +- .../authz/perforce/testdata/BUILD.bazel | 5 ++ .../internal/batches/processor/BUILD.bazel | 1 + .../internal/batches/reconciler/BUILD.bazel | 1 + .../internal/batches/service/BUILD.bazel | 2 + .../internal/batches/sources/BUILD.bazel | 6 ++ .../batches/sources/azuredevops/BUILD.bazel | 9 +++ enterprise/internal/batches/state/BUILD.bazel | 2 + enterprise/internal/batches/store/BUILD.bazel | 2 + enterprise/internal/batches/types/BUILD.bazel | 4 ++ .../internal/batches/webhooks/BUILD.bazel | 36 +++++++++-- .../internal/background/BUILD.bazel | 2 + .../internal/jobselector/BUILD.bazel | 4 +- .../autoindexing/internal/store/BUILD.bazel | 1 + .../transport/graphql/BUILD.bazel | 1 + .../codenav/internal/lsifstore/BUILD.bazel | 1 - .../ranking/internal/background/BUILD.bazel | 2 +- .../internal/codeintel/uploads/BUILD.bazel | 2 +- .../uploads/internal/background/BUILD.bazel | 1 - .../uploads/internal/lsifstore/BUILD.bazel | 10 +-- .../uploads/internal/store/BUILD.bazel | 2 + .../codeintel/uploads/shared/BUILD.bazel | 6 +- .../codemonitors/background/BUILD.bazel | 2 +- enterprise/internal/compute/BUILD.bazel | 2 +- .../internal/compute/client/BUILD.bazel | 2 +- enterprise/internal/database/BUILD.bazel | 9 +++ enterprise/internal/embeddings/BUILD.bazel | 34 ++++++++++ .../background/contextdetection/BUILD.bazel | 20 ++++++ .../embeddings/background/repo/BUILD.bazel | 22 +++++++ .../internal/embeddings/embed/BUILD.bazel | 33 ++++++++++ .../embeddings/similarity_search_test.go | 8 +-- .../internal/embeddings/split/BUILD.bazel | 17 +++++ .../internal/embeddings/split/split_test.go | 4 +- enterprise/internal/executor/BUILD.bazel | 19 ------ .../internal/executor/store/BUILD.bazel | 40 ++++++++++++ .../internal/executor/types/BUILD.bazel | 22 +++++++ .../internal/insights/aggregation/BUILD.bazel | 2 +- .../internal/insights/background/BUILD.bazel | 2 +- .../background/queryrunner/BUILD.bazel | 2 +- .../insights/background/retention/BUILD.bazel | 2 + .../internal/insights/compression/BUILD.bazel | 2 +- .../internal/insights/discovery/BUILD.bazel | 2 +- .../internal/insights/gitserver/BUILD.bazel | 2 +- .../internal/insights/pipeline/BUILD.bazel | 4 +- .../insights/query/querybuilder/BUILD.bazel | 2 +- .../internal/insights/scheduler/BUILD.bazel | 4 +- .../insights/scheduler/iterator/BUILD.bazel | 2 +- .../internal/insights/store/BUILD.bazel | 2 +- .../internal/insights/timeseries/BUILD.bazel | 2 +- enterprise/internal/notebooks/BUILD.bazel | 2 +- .../migrations/batches/BUILD.bazel | 14 ++++- .../migrations/codeintel/BUILD.bazel | 2 +- .../migrations/insights/BUILD.bazel | 2 +- .../insights/backfillv2/BUILD.bazel | 2 +- .../insights/recording_times/BUILD.bazel | 2 +- enterprise/internal/scim/BUILD.bazel | 21 ++++++- go.mod | 1 - go.sum | 1 - internal/BUILD.bazel | 1 + .../audit/integration/integration_test.go | 5 ++ internal/auth/BUILD.bazel | 15 ++++- internal/binary/BUILD.bazel | 8 +++ internal/cmd/git-combine/git-combine_test.go | 11 ++++ .../dependencies/internal/store/BUILD.bazel | 1 - internal/comby/BUILD.bazel | 2 +- internal/conf/BUILD.bazel | 2 - internal/database/BUILD.bazel | 4 ++ internal/database/dbconn/BUILD.bazel | 3 + internal/database/dbconn/rds/BUILD.bazel | 26 ++++++++ internal/database/fakedb/BUILD.bazel | 18 ++++++ .../database/migration/stitch/stitch_test.go | 18 ++++-- internal/database/migration/store/BUILD.bazel | 2 +- internal/extsvc/azuredevops/BUILD.bazel | 5 ++ internal/fastwalk/BUILD.bazel | 25 ++++++++ internal/gitserver/BUILD.bazel | 9 ++- .../gitserver/integration_tests/BUILD.bazel | 1 - .../gitserver/integration_tests/tree_test.go | 2 +- internal/gitserver/test_utils.go | 2 +- internal/gitserver/v1/BUILD.bazel | 30 ++++----- internal/gqlutil/BUILD.bazel | 1 + internal/grpc/BUILD.bazel | 1 + internal/grpc/defaults/BUILD.bazel | 1 + internal/insights/BUILD.bazel | 2 +- internal/limiter/BUILD.bazel | 5 +- internal/oobmigration/BUILD.bazel | 1 - .../migrations/batches/BUILD.bazel | 2 + internal/own/BUILD.bazel | 36 +++++++++++ internal/own/codeowners/BUILD.bazel | 9 ++- internal/own/codeowners/v1/BUILD.bazel | 31 ++-------- internal/repos/BUILD.bazel | 5 +- internal/repoupdater/BUILD.bazel | 9 ++- internal/repoupdater/protocol/BUILD.bazel | 2 + internal/repoupdater/v1/BUILD.bazel | 19 ++++++ internal/search/backend/BUILD.bazel | 2 + internal/search/codeownership/BUILD.bazel | 5 +- internal/search/commit/BUILD.bazel | 2 +- internal/search/job/jobutil/BUILD.bazel | 4 +- internal/search/job/printer/BUILD.bazel | 2 +- internal/search/keyword/BUILD.bazel | 3 +- internal/search/query/BUILD.bazel | 2 +- internal/search/repos/BUILD.bazel | 2 +- internal/search/result/BUILD.bazel | 3 +- internal/search/searcher/BUILD.bazel | 10 +-- internal/search/smartsearch/BUILD.bazel | 2 +- internal/search/streaming/BUILD.bazel | 2 +- internal/search/zoekt/BUILD.bazel | 2 +- internal/searcher/v1/BUILD.bazel | 27 ++++---- internal/service/servegit/BUILD.bazel | 2 + internal/service/svcmain/BUILD.bazel | 1 + internal/symbols/BUILD.bazel | 12 +++- internal/symbols/v1/BUILD.bazel | 22 +++---- internal/syncx/oncefunc_test.go | 5 +- internal/tracer/BUILD.bazel | 13 ++-- internal/txemail/BUILD.bazel | 2 +- internal/types/BUILD.bazel | 1 + internal/wrexec/cmd_test.go | 42 ++++++------- internal/wrexec/recording_cmd_test.go | 12 ++-- lib/codeintel/precise/diff/BUILD.bazel | 2 +- migrations/BUILD.bazel | 48 ++++++++++++++ 202 files changed, 1319 insertions(+), 333 deletions(-) create mode 100644 cmd/frontend/internal/auth/accessrequest/BUILD.bazel create mode 100644 dev/internal/cmd/app-discover-repos/BUILD.bazel create mode 100644 enterprise/cmd/embeddings/BUILD.bazel create mode 100644 enterprise/cmd/embeddings/shared/BUILD.bazel create mode 100644 enterprise/cmd/frontend/internal/auth/azureoauth/BUILD.bazel create mode 100644 enterprise/cmd/frontend/internal/completions/BUILD.bazel create mode 100644 enterprise/cmd/frontend/internal/completions/streaming/BUILD.bazel create mode 100644 enterprise/cmd/frontend/internal/completions/streaming/anthropic/BUILD.bazel create mode 100644 enterprise/cmd/frontend/internal/completions/types/BUILD.bazel create mode 100644 enterprise/cmd/frontend/internal/embeddings/BUILD.bazel create mode 100644 enterprise/cmd/frontend/internal/embeddings/resolvers/BUILD.bazel create mode 100644 enterprise/cmd/worker/internal/embeddings/contextdetection/BUILD.bazel create mode 100644 enterprise/cmd/worker/internal/embeddings/repo/BUILD.bazel create mode 100644 enterprise/internal/authz/perforce/testdata/BUILD.bazel create mode 100644 enterprise/internal/batches/sources/azuredevops/BUILD.bazel create mode 100644 enterprise/internal/embeddings/BUILD.bazel create mode 100644 enterprise/internal/embeddings/background/contextdetection/BUILD.bazel create mode 100644 enterprise/internal/embeddings/background/repo/BUILD.bazel create mode 100644 enterprise/internal/embeddings/embed/BUILD.bazel create mode 100644 enterprise/internal/embeddings/split/BUILD.bazel create mode 100644 enterprise/internal/executor/store/BUILD.bazel create mode 100644 enterprise/internal/executor/types/BUILD.bazel create mode 100644 internal/BUILD.bazel create mode 100644 internal/binary/BUILD.bazel create mode 100644 internal/database/dbconn/rds/BUILD.bazel create mode 100644 internal/database/fakedb/BUILD.bazel create mode 100644 internal/fastwalk/BUILD.bazel create mode 100644 internal/own/BUILD.bazel create mode 100644 internal/repoupdater/v1/BUILD.bazel diff --git a/.golangci.yml b/.golangci.yml index 905de8f44b0..766a1fb15bd 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -32,6 +32,7 @@ linters-settings: - github.com/hashicorp/go-multierror: "Use github.com/sourcegraph/sourcegraph/lib/errors instead" # More performant regexp - regexp: "Use github.com/grafana/regexp instead" + - github.com/hexops/autogold$: "Use github.com/hexops/autogold/v2 instead" gocritic: disabled-checks: - appendAssign # Too many false positives diff --git a/client/web/BUILD.bazel b/client/web/BUILD.bazel index b8f478b239b..acb350401ef 100644 --- a/client/web/BUILD.bazel +++ b/client/web/BUILD.bazel @@ -1820,7 +1820,6 @@ ENTERPRISE_BUNDLE_DATA_DEPS = BUNDLE_DATA_DEPS + [ # TODO(bazel): this is already in the main ts_project(srcs). Why also here? "src/enterprise/codeintel/configuration/schema.json", - ":enterprise-yaml", ] diff --git a/cmd/blobstore/internal/blobstore/BUILD.bazel b/cmd/blobstore/internal/blobstore/BUILD.bazel index c9820fc05b5..1e3bbce7703 100644 --- a/cmd/blobstore/internal/blobstore/BUILD.bazel +++ b/cmd/blobstore/internal/blobstore/BUILD.bazel @@ -23,6 +23,7 @@ go_library( go_test( name = "blobstore_test", srcs = ["blobstore_test.go"], + data = glob(["testdata/**"]), deps = [ ":blobstore", "//internal/observation", diff --git a/cmd/frontend/auth/BUILD.bazel b/cmd/frontend/auth/BUILD.bazel index 3d05ca0d704..8bb5c1c722b 100644 --- a/cmd/frontend/auth/BUILD.bazel +++ b/cmd/frontend/auth/BUILD.bazel @@ -54,6 +54,7 @@ go_test( "//schema", "@com_github_derision_test_go_mockgen//testutil/require", "@com_github_google_go_cmp//cmp", + "@com_github_stretchr_testify//assert", "@com_github_stretchr_testify//require", ], ) diff --git a/cmd/frontend/backend/BUILD.bazel b/cmd/frontend/backend/BUILD.bazel index 1c37d8047af..de1e7e5b365 100644 --- a/cmd/frontend/backend/BUILD.bazel +++ b/cmd/frontend/backend/BUILD.bazel @@ -9,7 +9,6 @@ go_library( "inventory.go", "mocks.go", "mocks_temp.go", - "own.go", "repos.go", "repos_mock.go", "symbols.go", @@ -48,8 +47,6 @@ go_library( "//internal/gitserver/gitdomain", "//internal/httpcli", "//internal/inventory", - "//internal/own/codeowners", - "//internal/own/codeowners/v1:codeowners", "//internal/randstring", "//internal/rcache", "//internal/repoupdater", @@ -77,7 +74,6 @@ go_test( name = "backend_test", srcs = [ "external_services_test.go", - "own_test.go", "repos_test.go", "repos_vcs_test.go", "user_emails_test.go", @@ -107,8 +103,6 @@ go_test( "//internal/gitserver", "//internal/gitserver/gitdomain", "//internal/inventory", - "//internal/own/codeowners", - "//internal/own/codeowners/v1:codeowners", "//internal/rcache", "//internal/repoupdater", "//internal/repoupdater/protocol", diff --git a/cmd/frontend/graphqlbackend/BUILD.bazel b/cmd/frontend/graphqlbackend/BUILD.bazel index 7e2a8f37385..58e2dbc18f7 100644 --- a/cmd/frontend/graphqlbackend/BUILD.bazel +++ b/cmd/frontend/graphqlbackend/BUILD.bazel @@ -17,6 +17,7 @@ js_library( go_library( name = "graphqlbackend", srcs = [ + "access_requests.go", "access_token.go", "access_tokens.go", "auth_provider.go", @@ -34,6 +35,7 @@ go_library( "doc.go", "dotcom.go", "email_invitation.go", + "embeddings.go", "empty_response.go", "event_log.go", "event_logs.go", @@ -46,7 +48,6 @@ go_library( "executor_secret_connection.go", "executor_secrets.go", "executors.go", - "extension_registry.go", "external_account.go", "external_account_data_resolver.go", "external_accounts.go", @@ -92,7 +93,7 @@ go_library( "own.go", "package_repos.go", "parse_search_query.go", - "permission_sync_jobs.go", + "permissions_sync_jobs.go", "person.go", "phabricator.go", "preview_repository_comparison.go", @@ -178,6 +179,7 @@ go_library( "outbound_webhooks.graphql", "rbac.graphql", "own.graphql", + "embeddings.graphql", ], importpath = "github.com/sourcegraph/sourcegraph/cmd/frontend/graphqlbackend", deps = [ @@ -197,6 +199,7 @@ go_library( "//cmd/frontend/internal/search/logs", "//cmd/frontend/internal/siteid", "//cmd/frontend/internal/suspiciousnames", + "//cmd/migrator/shared", "//internal/actor", "//internal/adminanalytics", "//internal/api", @@ -204,6 +207,7 @@ go_library( "//internal/auth/sourcegraphoperator", "//internal/authz", "//internal/authz/permssync", + "//internal/binary", "//internal/cloneurls", "//internal/codeintel/dependencies", "//internal/codeintel/resolvers", @@ -212,6 +216,8 @@ go_library( "//internal/conf/deploy", "//internal/conf/reposource", "//internal/database", + "//internal/database/migration/cliutil", + "//internal/database/migration/schemas", "//internal/encryption", "//internal/encryption/keyring", "//internal/env", @@ -269,7 +275,7 @@ go_library( "//internal/webhooks/outbound", "//lib/batches", "//lib/errors", - "//lib/group", + "//lib/output", "//schema", "@com_github_gogo_protobuf//jsonpb", "@com_github_golang_jwt_jwt_v4//:jwt", @@ -281,7 +287,7 @@ go_library( "@com_github_graph_gophers_graphql_go//errors", "@com_github_graph_gophers_graphql_go//introspection", "@com_github_graph_gophers_graphql_go//relay", - "@com_github_graph_gophers_graphql_go//trace", + "@com_github_graph_gophers_graphql_go//trace/otel", "@com_github_graphql_go_graphql//language/ast", "@com_github_graphql_go_graphql//language/kinds", "@com_github_graphql_go_graphql//language/parser", @@ -290,11 +296,11 @@ go_library( "@com_github_hexops_gotextdiff//myers", "@com_github_inconshreveable_log15//:log15", "@com_github_masterminds_semver//:semver", - "@com_github_neelance_parallel//:parallel", "@com_github_opentracing_opentracing_go//:opentracing-go", "@com_github_opentracing_opentracing_go//ext", "@com_github_prometheus_client_golang//prometheus", "@com_github_prometheus_client_golang//prometheus/promauto", + "@com_github_sourcegraph_conc//pool", "@com_github_sourcegraph_go_diff//diff", "@com_github_sourcegraph_go_langserver//pkg/lsp", "@com_github_sourcegraph_jsonx//:jsonx", @@ -304,12 +310,14 @@ go_library( "@com_github_sourcegraph_zoekt//stream", "@com_github_stretchr_testify//require", "@com_github_throttled_throttled_v2//:throttled", + "@io_opentelemetry_go_otel//:otel", ], ) go_test( name = "graphqlbackend_test", srcs = [ + "access_requests_test.go", "access_tokens_test.go", "client_configuration_test.go", "event_log_test.go", @@ -373,6 +381,8 @@ go_test( "virtual_file_test.go", "webhook_logs_test.go", ], + # graphqlbackend_test.go opens itself during its test, so we need to make it available. + data = ["graphqlbackend_test.go"], # keep embed = [":graphqlbackend"], deps = [ "//cmd/frontend/auth/providers", @@ -387,10 +397,12 @@ go_test( "//internal/auth", "//internal/authz", "//internal/authz/permssync", + "//internal/binary", "//internal/conf", "//internal/conf/conftypes", "//internal/database", "//internal/database/dbtest", + "//internal/database/fakedb", "//internal/encryption", "//internal/extsvc", "//internal/extsvc/gerrit", @@ -401,6 +413,7 @@ go_test( "//internal/gitserver/gitdomain", "//internal/gitserver/protocol", "//internal/inventory", + "//internal/oobmigration", "//internal/rcache", "//internal/repos", "//internal/repoupdater", @@ -432,7 +445,7 @@ go_test( "@com_github_graph_gophers_graphql_go//:graphql-go", "@com_github_graph_gophers_graphql_go//errors", "@com_github_graph_gophers_graphql_go//relay", - "@com_github_hexops_autogold//:autogold", + "@com_github_hexops_autogold_v2//:autogold", "@com_github_inconshreveable_log15//:log15", "@com_github_sourcegraph_go_diff//diff", "@com_github_sourcegraph_log//:log", diff --git a/cmd/frontend/internal/app/BUILD.bazel b/cmd/frontend/internal/app/BUILD.bazel index 2cdb5285eef..ff1ad075559 100644 --- a/cmd/frontend/internal/app/BUILD.bazel +++ b/cmd/frontend/internal/app/BUILD.bazel @@ -29,6 +29,7 @@ go_library( "//cmd/frontend/internal/app/otlpadapter", "//cmd/frontend/internal/app/router", "//cmd/frontend/internal/app/ui", + "//cmd/frontend/internal/auth/accessrequest", "//cmd/frontend/internal/auth/userpasswd", "//cmd/frontend/internal/routevar", "//cmd/frontend/internal/session", diff --git a/cmd/frontend/internal/app/jscontext/BUILD.bazel b/cmd/frontend/internal/app/jscontext/BUILD.bazel index a586165d375..2945b33e524 100644 --- a/cmd/frontend/internal/app/jscontext/BUILD.bazel +++ b/cmd/frontend/internal/app/jscontext/BUILD.bazel @@ -22,8 +22,10 @@ go_library( "//internal/database", "//internal/env", "//internal/lazyregexp", + "//internal/types", "//internal/version", "//schema", + "@com_github_graph_gophers_graphql_go//:graphql-go", ], ) diff --git a/cmd/frontend/internal/app/otlpadapter/BUILD.bazel b/cmd/frontend/internal/app/otlpadapter/BUILD.bazel index 0c62a9e7ace..e9d36f50a59 100644 --- a/cmd/frontend/internal/app/otlpadapter/BUILD.bazel +++ b/cmd/frontend/internal/app/otlpadapter/BUILD.bazel @@ -14,16 +14,22 @@ go_library( "//internal/otlpenv", "//lib/errors", "@com_github_gorilla_mux//:mux", + "@com_github_prometheus_client_golang//prometheus", "@com_github_sourcegraph_log//:log", "@com_github_sourcegraph_log//std", - "@io_opentelemetry_go_collector//component", - "@io_opentelemetry_go_collector//config", "@io_opentelemetry_go_collector//config/confighttp", + "@io_opentelemetry_go_collector//config/configtelemetry", "@io_opentelemetry_go_collector//config/configtls", - "@io_opentelemetry_go_collector//exporter/otlpexporter", - "@io_opentelemetry_go_collector//exporter/otlphttpexporter", - "@io_opentelemetry_go_collector//receiver/otlpreceiver", + "@io_opentelemetry_go_collector//exporter", + "@io_opentelemetry_go_collector//receiver", + "@io_opentelemetry_go_collector_component//:component", + "@io_opentelemetry_go_collector_exporter_otlpexporter//:otlpexporter", + "@io_opentelemetry_go_collector_exporter_otlphttpexporter//:otlphttpexporter", + "@io_opentelemetry_go_collector_receiver_otlpreceiver//:otlpreceiver", "@io_opentelemetry_go_otel//:otel", + "@io_opentelemetry_go_otel_exporters_prometheus//:prometheus", + "@io_opentelemetry_go_otel_metric//:metric", + "@io_opentelemetry_go_otel_sdk_metric//:metric", "@org_uber_go_atomic//:atomic", "@org_uber_go_zap//:zap", ], diff --git a/cmd/frontend/internal/app/ui/BUILD.bazel b/cmd/frontend/internal/app/ui/BUILD.bazel index e502986b007..d74c9a6cafd 100644 --- a/cmd/frontend/internal/app/ui/BUILD.bazel +++ b/cmd/frontend/internal/app/ui/BUILD.bazel @@ -7,7 +7,6 @@ go_library( "handlers.go", "help.go", "landing.go", - "legacy_extensions_redirects.go", "preview.go", "raw.go", "router.go", @@ -27,6 +26,7 @@ go_library( "//cmd/frontend/globals", "//cmd/frontend/hubspot", "//cmd/frontend/hubspot/hubspotutil", + "//cmd/frontend/internal/app/assetsutil", "//cmd/frontend/internal/app/jscontext", "//cmd/frontend/internal/app/ui/router", "//cmd/frontend/internal/handlerutil", @@ -97,7 +97,6 @@ go_test( "//internal/search/result", "//internal/types", "//internal/version", - "//schema", "//ui/assets", "@com_github_gorilla_mux//:mux", "@com_github_stretchr_testify//assert", diff --git a/cmd/frontend/internal/auth/accessrequest/BUILD.bazel b/cmd/frontend/internal/auth/accessrequest/BUILD.bazel new file mode 100644 index 00000000000..90ba9e1871e --- /dev/null +++ b/cmd/frontend/internal/auth/accessrequest/BUILD.bazel @@ -0,0 +1,37 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") + +go_library( + name = "accessrequest", + srcs = ["handlers.go"], + importpath = "github.com/sourcegraph/sourcegraph/cmd/frontend/internal/auth/accessrequest", + visibility = ["//cmd/frontend:__subpackages__"], + deps = [ + "//cmd/frontend/internal/auth/userpasswd", + "//internal/actor", + "//internal/conf", + "//internal/database", + "//internal/deviceid", + "//internal/errcode", + "//internal/featureflag", + "//internal/types", + "//internal/usagestats", + "@com_github_sourcegraph_log//:log", + ], +) + +go_test( + name = "accessrequest_test", + srcs = ["handlers_test.go"], + embed = [":accessrequest"], + deps = [ + "//internal/conf", + "//internal/database", + "//internal/database/dbtest", + "//internal/errcode", + "//internal/types", + "//schema", + "@com_github_sourcegraph_log//logtest", + "@com_github_stretchr_testify//require", + "@tools_gotest//assert", + ], +) diff --git a/cmd/frontend/internal/bg/BUILD.bazel b/cmd/frontend/internal/bg/BUILD.bazel index 603e3fa4b0b..4c9d23c279f 100644 --- a/cmd/frontend/internal/bg/BUILD.bazel +++ b/cmd/frontend/internal/bg/BUILD.bazel @@ -3,6 +3,7 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library") go_library( name = "bg", srcs = [ + "app_ready.go", "check_redis_cache_eviction_policy.go", "delete_old_cache_data_in_redis.go", "delete_old_event_logs_in_postgres.go", @@ -12,6 +13,8 @@ go_library( importpath = "github.com/sourcegraph/sourcegraph/cmd/frontend/internal/bg", visibility = ["//cmd/frontend:__subpackages__"], deps = [ + "//cmd/frontend/globals", + "//internal/conf/deploy", "//internal/database", "//internal/rbac", "//internal/rcache", @@ -20,6 +23,7 @@ go_library( "//lib/errors", "@com_github_gomodule_redigo//redis", "@com_github_inconshreveable_log15//:log15", + "@com_github_pkg_browser//:browser", "@com_github_sourcegraph_log//:log", ], ) diff --git a/cmd/frontend/internal/cli/config.go b/cmd/frontend/internal/cli/config.go index 11ab1634ff0..471786ba992 100644 --- a/cmd/frontend/internal/cli/config.go +++ b/cmd/frontend/internal/cli/config.go @@ -519,7 +519,7 @@ func gitserverAddr(environ []string) (string, error) { // Detect 'go test' and setup default addresses in that case. p, err := os.Executable() - if err == nil && strings.HasSuffix(p, ".test") { + if err == nil && (strings.HasSuffix(filepath.Base(p), "_test") || strings.HasSuffix(p, ".test")) { return "gitserver:3178", nil } diff --git a/cmd/frontend/internal/handlerutil/BUILD.bazel b/cmd/frontend/internal/handlerutil/BUILD.bazel index 9f1e938539b..2a0532ef646 100644 --- a/cmd/frontend/internal/handlerutil/BUILD.bazel +++ b/cmd/frontend/internal/handlerutil/BUILD.bazel @@ -28,7 +28,6 @@ go_library( "@com_github_getsentry_raven_go//:raven-go", "@com_github_gorilla_mux//:mux", "@com_github_inconshreveable_log15//:log15", - "@com_github_neelance_parallel//:parallel", "@com_github_sourcegraph_log//:log", ], ) diff --git a/cmd/frontend/internal/highlight/BUILD.bazel b/cmd/frontend/internal/highlight/BUILD.bazel index fe5acff015b..41c7ec9c7d1 100644 --- a/cmd/frontend/internal/highlight/BUILD.bazel +++ b/cmd/frontend/internal/highlight/BUILD.bazel @@ -3,6 +3,7 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") go_library( name = "highlight", srcs = [ + "chroma.go", "highlight.go", "html.go", "language.go", @@ -12,14 +13,18 @@ go_library( importpath = "github.com/sourcegraph/sourcegraph/cmd/frontend/internal/highlight", visibility = ["//cmd/frontend:__subpackages__"], deps = [ + "//internal/binary", "//internal/conf", "//internal/conf/conftypes", + "//internal/conf/deploy", "//internal/env", "//internal/gosyntect", "//internal/honey", "//internal/observation", "//internal/trace/ot", "//lib/errors", + "@com_github_alecthomas_chroma_v2//:chroma", + "@com_github_alecthomas_chroma_v2//lexers", "@com_github_go_enry_go_enry_v2//:go-enry", "@com_github_grafana_regexp//:regexp", "@com_github_inconshreveable_log15//:log15", diff --git a/cmd/frontend/registry/api/BUILD.bazel b/cmd/frontend/registry/api/BUILD.bazel index 8a8dcccb07b..aa0e3f949c4 100644 --- a/cmd/frontend/registry/api/BUILD.bazel +++ b/cmd/frontend/registry/api/BUILD.bazel @@ -1,47 +1,18 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@io_bazel_rules_go//go:def.bzl", "go_library") go_library( name = "api", srcs = [ "doc.go", - "extension_connection_graphql.go", - "extension_graphql.go", - "extension_manifest.go", - "extension_remote_graphql.go", - "extensions.go", "extensions_helpers.go", "gating.go", "http_api.go", - "registry_graphql.go", ], importpath = "github.com/sourcegraph/sourcegraph/cmd/frontend/registry/api", visibility = ["//visibility:public"], deps = [ "//cmd/frontend/envvar", - "//cmd/frontend/graphqlbackend", "//cmd/frontend/registry/client", - "//internal/conf", - "//internal/database", - "//internal/jsonc", "//lib/errors", - "@com_github_graph_gophers_graphql_go//:graphql-go", - "@com_github_graph_gophers_graphql_go//relay", - ], -) - -go_test( - name = "api_test", - srcs = [ - "extension_connection_graphql_test.go", - "extension_manifest_test.go", - "extensions_test.go", - ], - embed = [":api"], - deps = [ - "//cmd/frontend/envvar", - "//cmd/frontend/graphqlbackend", - "//cmd/frontend/registry/client", - "//internal/conf", - "//schema", ], ) diff --git a/cmd/gitserver/server/BUILD.bazel b/cmd/gitserver/server/BUILD.bazel index 175c20483e7..68604e6584d 100644 --- a/cmd/gitserver/server/BUILD.bazel +++ b/cmd/gitserver/server/BUILD.bazel @@ -63,8 +63,8 @@ go_library( "//internal/honey", "//internal/hostname", "//internal/lazyregexp", + "//internal/limiter", "//internal/metrics", - "//internal/mutablelimiter", "//internal/observation", "//internal/ratelimit", "//internal/search/streaming/http", @@ -137,7 +137,7 @@ go_test( "//internal/gitserver/protocol", "//internal/httpcli", "//internal/httptestutil", - "//internal/mutablelimiter", + "//internal/limiter", "//internal/observation", "//internal/ratelimit", "//internal/testutil", diff --git a/cmd/gitserver/server/cleanup_test.go b/cmd/gitserver/server/cleanup_test.go index 2f4494fb268..94e5a74b968 100644 --- a/cmd/gitserver/server/cleanup_test.go +++ b/cmd/gitserver/server/cleanup_test.go @@ -272,7 +272,7 @@ func TestGitGCAuto(t *testing.T) { // Create a test repository with detectable garbage that GC can prune. wd := t.TempDir() repo := filepath.Join(wd, "garbage-repo") - runCmd(t, wd, "git", "init", repo) + runCmd(t, wd, "git", "init", "--initial-branch", "main", repo) // First we need to generate a moderate number of commits. for i := 0; i < 50; i++ { @@ -290,7 +290,7 @@ func TestGitGCAuto(t *testing.T) { } // Bring everything back together in one branch. - runCmd(t, repo, "git", "checkout", "master") + runCmd(t, repo, "git", "checkout", "main") runCmd(t, repo, "git", "merge", "secondary") // Now create a bare repo like gitserver expects diff --git a/cmd/gitserver/shared/BUILD.bazel b/cmd/gitserver/shared/BUILD.bazel index 567f10fbc5f..c59aeff228f 100644 --- a/cmd/gitserver/shared/BUILD.bazel +++ b/cmd/gitserver/shared/BUILD.bazel @@ -49,8 +49,6 @@ go_library( "@com_github_json_iterator_go//:go", "@com_github_sourcegraph_log//:log", "@com_github_tidwall_gjson//:gjson", - "@org_golang_google_grpc//:go_default_library", - "@org_golang_google_grpc//reflection", "@org_golang_x_sync//semaphore", "@org_golang_x_time//rate", ], diff --git a/cmd/repo-updater/repoupdater/BUILD.bazel b/cmd/repo-updater/repoupdater/BUILD.bazel index 7311d9c2615..4c85495aade 100644 --- a/cmd/repo-updater/repoupdater/BUILD.bazel +++ b/cmd/repo-updater/repoupdater/BUILD.bazel @@ -3,6 +3,7 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") go_library( name = "repoupdater", srcs = [ + "grpc_server.go", "observability.go", "server.go", ], @@ -15,6 +16,7 @@ go_library( "//internal/codeintel/dependencies", "//internal/database", "//internal/errcode", + "//internal/extsvc", "//internal/extsvc/github", "//internal/httpcli", "//internal/instrumentation", @@ -22,6 +24,7 @@ go_library( "//internal/observation", "//internal/repos", "//internal/repoupdater/protocol", + "//internal/repoupdater/v1:repoupdater", "//internal/trace", "//internal/types", "//lib/errors", @@ -29,6 +32,8 @@ go_library( "@com_github_sourcegraph_log//:log", "@io_opentelemetry_go_otel//attribute", "@io_opentelemetry_go_otel_trace//:trace", + "@org_golang_google_grpc//codes", + "@org_golang_google_grpc//status", ], ) @@ -50,10 +55,13 @@ go_test( "//internal/extsvc/awscodecommit", "//internal/extsvc/github", "//internal/extsvc/gitlab", + "//internal/grpc", + "//internal/grpc/defaults", "//internal/observation", "//internal/repos", "//internal/repoupdater", "//internal/repoupdater/protocol", + "//internal/repoupdater/v1:repoupdater", "//internal/timeutil", "//internal/types", "//internal/types/typestest", @@ -63,5 +71,6 @@ go_test( "@com_github_inconshreveable_log15//:log15", "@com_github_sourcegraph_log//logtest", "@io_opentelemetry_go_otel_trace//:trace", + "@org_golang_google_grpc//:go_default_library", ], ) diff --git a/cmd/repo-updater/shared/BUILD.bazel b/cmd/repo-updater/shared/BUILD.bazel index ed4b7f9f64d..66e9d61394b 100644 --- a/cmd/repo-updater/shared/BUILD.bazel +++ b/cmd/repo-updater/shared/BUILD.bazel @@ -28,12 +28,15 @@ go_library( "//internal/env", "//internal/extsvc", "//internal/goroutine", + "//internal/grpc", + "//internal/grpc/defaults", "//internal/httpcli", "//internal/httpserver", "//internal/instrumentation", "//internal/observation", "//internal/ratelimit", "//internal/repos", + "//internal/repoupdater/v1:repoupdater", "//internal/service", "//internal/trace", "//internal/types", @@ -42,6 +45,8 @@ go_library( "@com_github_prometheus_client_golang//prometheus", "@com_github_sourcegraph_log//:log", "@io_opentelemetry_go_otel//:otel", + "@org_golang_google_grpc//:go_default_library", + "@org_golang_google_grpc//reflection", "@org_golang_x_time//rate", ], ) diff --git a/cmd/searcher/internal/search/BUILD.bazel b/cmd/searcher/internal/search/BUILD.bazel index aa781a6d680..4f87600d25f 100644 --- a/cmd/searcher/internal/search/BUILD.bazel +++ b/cmd/searcher/internal/search/BUILD.bazel @@ -27,8 +27,8 @@ go_library( "//internal/errcode", "//internal/gitserver", "//internal/lazyregexp", + "//internal/limiter", "//internal/metrics", - "//internal/mutablelimiter", "//internal/observation", "//internal/search", "//internal/search/backend", @@ -93,11 +93,11 @@ go_test( "//internal/search/backend", "//internal/search/searcher", "//lib/errors", - "//lib/group", "//schema", "@com_github_google_go_cmp//cmp", "@com_github_grafana_regexp//:regexp", "@com_github_roaringbitmap_roaring//:roaring", + "@com_github_sourcegraph_conc//pool", "@com_github_sourcegraph_log//logtest", "@com_github_sourcegraph_zoekt//:zoekt", "@com_github_sourcegraph_zoekt//query", diff --git a/cmd/searcher/shared/BUILD.bazel b/cmd/searcher/shared/BUILD.bazel index b6f5b00e587..d636a8224eb 100644 --- a/cmd/searcher/shared/BUILD.bazel +++ b/cmd/searcher/shared/BUILD.bazel @@ -30,8 +30,6 @@ go_library( "//lib/errors", "@com_github_keegancsmith_tmpfriend//:tmpfriend", "@com_github_sourcegraph_log//:log", - "@org_golang_google_grpc//:go_default_library", - "@org_golang_google_grpc//reflection", "@org_golang_x_sync//errgroup", ], ) diff --git a/cmd/server/shared/BUILD.bazel b/cmd/server/shared/BUILD.bazel index e042b2704a8..73771de2e2e 100644 --- a/cmd/server/shared/BUILD.bazel +++ b/cmd/server/shared/BUILD.bazel @@ -37,6 +37,7 @@ go_test( "nginx_test.go", "redis_test.go", ], + data = ["//cmd/server/shared/assets:nginx"], embed = [":shared"], deps = ["@com_github_google_go_cmp//cmp"], ) diff --git a/cmd/server/shared/assets/BUILD.bazel b/cmd/server/shared/assets/BUILD.bazel index 6ff5243bcfe..fec4e11a1a5 100644 --- a/cmd/server/shared/assets/BUILD.bazel +++ b/cmd/server/shared/assets/BUILD.bazel @@ -1,5 +1,11 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library") +filegroup( + name = "nginx", + srcs = glob(["nginx/**"]), + visibility = ["//visibility:public"], +) + go_library( name = "assets", srcs = ["assets.go"], diff --git a/cmd/symbols/internal/api/BUILD.bazel b/cmd/symbols/internal/api/BUILD.bazel index d43f5682113..ffa06127cbc 100644 --- a/cmd/symbols/internal/api/BUILD.bazel +++ b/cmd/symbols/internal/api/BUILD.bazel @@ -32,8 +32,8 @@ go_library( "@com_github_sourcegraph_go_ctags//:go-ctags", "@com_github_sourcegraph_log//:log", "@io_opentelemetry_go_otel//attribute", - "@org_golang_google_grpc//:go_default_library", - "@org_golang_google_grpc//reflection", + "@org_golang_google_grpc//codes", + "@org_golang_google_grpc//status", ], ) @@ -62,6 +62,8 @@ go_test( "//internal/symbols", "//internal/types", "//lib/errors", + "@com_github_google_go_cmp//cmp", + "@com_github_google_go_cmp//cmp/cmpopts", "@com_github_sourcegraph_go_ctags//:go-ctags", "@org_golang_x_sync//semaphore", ], diff --git a/cmd/symbols/squirrel/BUILD.bazel b/cmd/symbols/squirrel/BUILD.bazel index 058fec31b9c..4c4682a9a2d 100644 --- a/cmd/symbols/squirrel/BUILD.bazel +++ b/cmd/symbols/squirrel/BUILD.bazel @@ -46,6 +46,7 @@ go_test( "local_code_intel_test.go", "service_test.go", ], + data = glob(["test_repos/**"]), # keep embed = [":squirrel"], deps = [ "//internal/search", diff --git a/cmd/worker/internal/migrations/BUILD.bazel b/cmd/worker/internal/migrations/BUILD.bazel index 8000bd76689..da839fd320b 100644 --- a/cmd/worker/internal/migrations/BUILD.bazel +++ b/cmd/worker/internal/migrations/BUILD.bazel @@ -1,8 +1,11 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") go_library( name = "migrations", - srcs = ["init.go"], + srcs = [ + "init.go", + "version.go", + ], importpath = "github.com/sourcegraph/sourcegraph/cmd/worker/internal/migrations", visibility = ["//cmd/worker:__subpackages__"], deps = [ @@ -12,6 +15,15 @@ go_library( "//internal/goroutine", "//internal/observation", "//internal/oobmigration", + "//internal/version", "//lib/errors", + "@com_github_sourcegraph_log//:log", ], ) + +go_test( + name = "migrations_test", + srcs = ["init_test.go"], + embed = [":migrations"], + deps = ["//internal/oobmigration"], +) diff --git a/cmd/worker/internal/outboundwebhooks/BUILD.bazel b/cmd/worker/internal/outboundwebhooks/BUILD.bazel index 1a76cfaa75b..feffca7e7b0 100644 --- a/cmd/worker/internal/outboundwebhooks/BUILD.bazel +++ b/cmd/worker/internal/outboundwebhooks/BUILD.bazel @@ -30,8 +30,8 @@ go_library( "//internal/workerutil/dbworker", "//internal/workerutil/dbworker/store", "//lib/errors", - "//lib/group", "@com_github_keegancsmith_sqlf//:sqlf", + "@com_github_sourcegraph_conc//pool", "@com_github_sourcegraph_log//:log", ], ) diff --git a/dev/build-tracker/BUILD.bazel b/dev/build-tracker/BUILD.bazel index c7b88cd86d4..76f1b0c007c 100644 --- a/dev/build-tracker/BUILD.bazel +++ b/dev/build-tracker/BUILD.bazel @@ -39,7 +39,7 @@ go_test( "//dev/team", "@com_github_buildkite_go_buildkite_v3//buildkite", "@com_github_gorilla_mux//:mux", - "@com_github_hexops_autogold//:autogold", + "@com_github_hexops_autogold_v2//:autogold", "@com_github_sourcegraph_log//logtest", "@com_github_stretchr_testify//assert", "@com_github_stretchr_testify//require", diff --git a/dev/buildchecker/BUILD.bazel b/dev/buildchecker/BUILD.bazel index 26313ef4eb1..05d69a537af 100644 --- a/dev/buildchecker/BUILD.bazel +++ b/dev/buildchecker/BUILD.bazel @@ -48,7 +48,7 @@ go_test( "@com_github_buildkite_go_buildkite_v3//buildkite", "@com_github_dnaeon_go_vcr//cassette", "@com_github_google_go_github_v41//github", - "@com_github_hexops_autogold//:autogold", + "@com_github_hexops_autogold_v2//:autogold", "@com_github_stretchr_testify//assert", "@org_golang_x_oauth2//:oauth2", ], diff --git a/dev/internal/cmd/app-discover-repos/BUILD.bazel b/dev/internal/cmd/app-discover-repos/BUILD.bazel new file mode 100644 index 00000000000..9ef11e84f36 --- /dev/null +++ b/dev/internal/cmd/app-discover-repos/BUILD.bazel @@ -0,0 +1,18 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") + +go_library( + name = "app-discover-repos_lib", + srcs = ["app-discover-repos.go"], + importpath = "github.com/sourcegraph/sourcegraph/dev/internal/cmd/app-discover-repos", + visibility = ["//visibility:private"], + deps = [ + "//internal/service/servegit", + "@com_github_sourcegraph_log//:log", + ], +) + +go_binary( + name = "app-discover-repos", + embed = [":app-discover-repos_lib"], + visibility = ["//dev:__subpackages__"], +) diff --git a/dev/perforce/anonymiser/BUILD.bazel b/dev/perforce/anonymiser/BUILD.bazel index 49ed4554af7..7620e78c5b8 100644 --- a/dev/perforce/anonymiser/BUILD.bazel +++ b/dev/perforce/anonymiser/BUILD.bazel @@ -19,5 +19,5 @@ go_test( srcs = ["main_test.go"], data = glob(["testdata/**"]), embed = [":anonymiser_lib"], - deps = ["@com_github_hexops_autogold//:autogold"], + deps = ["@com_github_hexops_autogold_v2//:autogold"], ) diff --git a/dev/scaletesting/bulkrepocreate/BUILD.bazel b/dev/scaletesting/bulkrepocreate/BUILD.bazel index b165f03ac48..9287ce5727d 100644 --- a/dev/scaletesting/bulkrepocreate/BUILD.bazel +++ b/dev/scaletesting/bulkrepocreate/BUILD.bazel @@ -10,10 +10,10 @@ go_library( visibility = ["//visibility:private"], deps = [ "//dev/scaletesting/internal/store", - "//lib/group", "//lib/output", "@com_github_google_go_github_v41//github", "@com_github_mattn_go_sqlite3//:go-sqlite3", + "@com_github_sourcegraph_conc//pool", "@com_github_sourcegraph_run//:run", "@org_golang_x_oauth2//:oauth2", ], diff --git a/dev/scaletesting/bulkreposettings/BUILD.bazel b/dev/scaletesting/bulkreposettings/BUILD.bazel index b2d6a68be18..4871637dd6a 100644 --- a/dev/scaletesting/bulkreposettings/BUILD.bazel +++ b/dev/scaletesting/bulkreposettings/BUILD.bazel @@ -8,9 +8,9 @@ go_library( deps = [ "//dev/scaletesting/internal/store", "//lib/errors", - "//lib/group", "//lib/output", "@com_github_google_go_github//github", + "@com_github_sourcegraph_conc//pool", "@com_github_sourcegraph_log//:log", "@com_github_urfave_cli_v2//:cli", "@org_golang_x_oauth2//:oauth2", diff --git a/dev/scaletesting/codehostcopy/BUILD.bazel b/dev/scaletesting/codehostcopy/BUILD.bazel index 20ffe56830a..0ad7f74f0e1 100644 --- a/dev/scaletesting/codehostcopy/BUILD.bazel +++ b/dev/scaletesting/codehostcopy/BUILD.bazel @@ -18,9 +18,9 @@ go_library( "//dev/scaletesting/codehostcopy/bitbucket", "//dev/scaletesting/internal/store", "//lib/errors", - "//lib/group", "//lib/output", "@com_github_google_go_github//github", + "@com_github_sourcegraph_conc//pool", "@com_github_sourcegraph_log//:log", "@com_github_sourcegraph_run//:run", "@com_github_urfave_cli_v2//:cli", diff --git a/dev/scaletesting/syntheticgithubdata/BUILD.bazel b/dev/scaletesting/syntheticgithubdata/BUILD.bazel index e4abef90c6a..869199c8376 100644 --- a/dev/scaletesting/syntheticgithubdata/BUILD.bazel +++ b/dev/scaletesting/syntheticgithubdata/BUILD.bazel @@ -14,10 +14,10 @@ go_library( importpath = "github.com/sourcegraph/sourcegraph/dev/scaletesting/syntheticgithubdata", visibility = ["//visibility:private"], deps = [ - "//lib/group", "//lib/output", "@com_github_google_go_github_v41//github", "@com_github_mattn_go_sqlite3//:go-sqlite3", + "@com_github_sourcegraph_conc//pool", "@org_golang_x_oauth2//:oauth2", ], ) diff --git a/dev/sg/BUILD.bazel b/dev/sg/BUILD.bazel index 67fa62c8464..a7235f5fd33 100644 --- a/dev/sg/BUILD.bazel +++ b/dev/sg/BUILD.bazel @@ -148,7 +148,7 @@ go_test( "//dev/sg/internal/std", "//lib/output/outputtest", "@com_github_google_go_cmp//cmp", - "@com_github_hexops_autogold//:autogold", + "@com_github_hexops_autogold_v2//:autogold", "@com_github_stretchr_testify//assert", "@com_github_urfave_cli_v2//:cli", ], diff --git a/dev/sg/internal/check/BUILD.bazel b/dev/sg/internal/check/BUILD.bazel index 435ea6d8b95..7b1dcd09f03 100644 --- a/dev/sg/internal/check/BUILD.bazel +++ b/dev/sg/internal/check/BUILD.bazel @@ -18,10 +18,12 @@ go_library( "//dev/sg/internal/std", "//dev/sg/internal/usershell", "//dev/sg/root", + "//internal/limiter", "//lib/errors", - "//lib/group", "//lib/output", "@com_github_masterminds_semver//:semver", + "@com_github_sourcegraph_conc//pool", + "@com_github_sourcegraph_conc//stream", "@io_opentelemetry_go_otel//attribute", "@io_opentelemetry_go_otel_trace//:trace", "@org_uber_go_atomic//:atomic", diff --git a/dev/sg/internal/generate/golang/BUILD.bazel b/dev/sg/internal/generate/golang/BUILD.bazel index 82cd0da68d3..16d4e48db01 100644 --- a/dev/sg/internal/generate/golang/BUILD.bazel +++ b/dev/sg/internal/generate/golang/BUILD.bazel @@ -10,9 +10,9 @@ go_library( "//dev/sg/internal/std", "//dev/sg/root", "//lib/errors", - "//lib/group", "//lib/output", "@com_github_grafana_regexp//:regexp", + "@com_github_sourcegraph_conc//pool", "@com_github_sourcegraph_run//:run", ], ) diff --git a/dev/sg/internal/images/BUILD.bazel b/dev/sg/internal/images/BUILD.bazel index bd58360c467..a3b622d1cc4 100644 --- a/dev/sg/internal/images/BUILD.bazel +++ b/dev/sg/internal/images/BUILD.bazel @@ -12,12 +12,12 @@ go_library( "//dev/sg/internal/std", "//enterprise/dev/ci/images", "//lib/errors", - "//lib/group", "//lib/output", "@com_github_distribution_distribution_v3//reference", "@com_github_docker_docker_credential_helpers//credentials", "@com_github_masterminds_semver//:semver", "@com_github_opencontainers_go_digest//:go-digest", + "@com_github_sourcegraph_conc//pool", "@in_gopkg_yaml_v3//:yaml_v3", "@io_k8s_sigs_kustomize_kyaml//kio", "@io_k8s_sigs_kustomize_kyaml//yaml", diff --git a/dev/sg/internal/migration/BUILD.bazel b/dev/sg/internal/migration/BUILD.bazel index 31c2162021b..f63eb530570 100644 --- a/dev/sg/internal/migration/BUILD.bazel +++ b/dev/sg/internal/migration/BUILD.bazel @@ -38,7 +38,7 @@ go_test( srcs = ["util_test.go"], embed = [":migration"], deps = [ - "@com_github_hexops_autogold//:autogold", + "@com_github_hexops_autogold_v2//:autogold", "@com_github_stretchr_testify//require", ], ) diff --git a/enterprise/cmd/embeddings/BUILD.bazel b/enterprise/cmd/embeddings/BUILD.bazel new file mode 100644 index 00000000000..4df7cc7e335 --- /dev/null +++ b/enterprise/cmd/embeddings/BUILD.bazel @@ -0,0 +1,18 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") + +go_library( + name = "embeddings_lib", + srcs = ["main.go"], + importpath = "github.com/sourcegraph/sourcegraph/enterprise/cmd/embeddings", + visibility = ["//visibility:private"], + deps = [ + "//enterprise/cmd/embeddings/shared", + "//enterprise/cmd/sourcegraph/enterprisecmd", + ], +) + +go_binary( + name = "embeddings", + embed = [":embeddings_lib"], + visibility = ["//visibility:public"], +) diff --git a/enterprise/cmd/embeddings/shared/BUILD.bazel b/enterprise/cmd/embeddings/shared/BUILD.bazel new file mode 100644 index 00000000000..5072a29f994 --- /dev/null +++ b/enterprise/cmd/embeddings/shared/BUILD.bazel @@ -0,0 +1,62 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") + +go_library( + name = "shared", + srcs = [ + "config.go", + "context_detection.go", + "context_detection_cache.go", + "download_file.go", + "main.go", + "query_embeddings_cache.go", + "repo_embedding_index_cache.go", + "search.go", + "service.go", + ], + importpath = "github.com/sourcegraph/sourcegraph/enterprise/cmd/embeddings/shared", + visibility = ["//visibility:public"], + deps = [ + "//cmd/frontend/globals", + "//enterprise/internal/authz", + "//enterprise/internal/authz/subrepoperms", + "//enterprise/internal/database", + "//enterprise/internal/embeddings", + "//enterprise/internal/embeddings/background/repo", + "//enterprise/internal/embeddings/embed", + "//internal/actor", + "//internal/api", + "//internal/authz", + "//internal/conf", + "//internal/conf/conftypes", + "//internal/database", + "//internal/database/connections/live", + "//internal/debugserver", + "//internal/env", + "//internal/gitserver", + "//internal/goroutine", + "//internal/honey", + "//internal/httpserver", + "//internal/instrumentation", + "//internal/lazyregexp", + "//internal/observation", + "//internal/service", + "//internal/trace", + "//internal/uploadstore", + "//lib/errors", + "@com_github_hashicorp_golang_lru//:golang-lru", + "@com_github_sourcegraph_log//:log", + ], +) + +go_test( + name = "shared_test", + srcs = ["repo_embedding_index_cache_test.go"], + embed = [":shared"], + deps = [ + "//enterprise/internal/embeddings", + "//enterprise/internal/embeddings/background/repo", + "//internal/api", + "//internal/database", + "//internal/types", + ], +) diff --git a/enterprise/cmd/executor/internal/apiclient/files/BUILD.bazel b/enterprise/cmd/executor/internal/apiclient/files/BUILD.bazel index 8d0fc28e656..972298c2b5a 100644 --- a/enterprise/cmd/executor/internal/apiclient/files/BUILD.bazel +++ b/enterprise/cmd/executor/internal/apiclient/files/BUILD.bazel @@ -11,6 +11,7 @@ go_library( deps = [ "//enterprise/cmd/executor/internal/apiclient", "//enterprise/cmd/executor/internal/worker/workspace", + "//enterprise/internal/executor/types", "//internal/metrics", "//internal/observation", "//lib/errors", @@ -25,6 +26,7 @@ go_test( deps = [ ":files", "//enterprise/cmd/executor/internal/apiclient", + "//enterprise/internal/executor/types", "//internal/observation", "//lib/errors", "@com_github_stretchr_testify//assert", diff --git a/enterprise/cmd/executor/internal/apiclient/queue/BUILD.bazel b/enterprise/cmd/executor/internal/apiclient/queue/BUILD.bazel index d2fd7a16bdf..e83c6dedb93 100644 --- a/enterprise/cmd/executor/internal/apiclient/queue/BUILD.bazel +++ b/enterprise/cmd/executor/internal/apiclient/queue/BUILD.bazel @@ -12,7 +12,7 @@ go_library( deps = [ "//enterprise/cmd/executor/internal/apiclient", "//enterprise/cmd/executor/internal/command", - "//enterprise/internal/executor", + "//enterprise/internal/executor/types", "//internal/executor", "//internal/metrics", "//internal/observation", @@ -32,11 +32,14 @@ go_test( deps = [ ":queue", "//enterprise/cmd/executor/internal/apiclient", + "//enterprise/internal/executor/types", "//internal/executor", "//internal/observation", + "//lib/errors", "@com_github_google_go_cmp//cmp", "@com_github_prometheus_client_golang//prometheus", "@com_github_prometheus_client_model//go", + "@com_github_stretchr_testify//assert", "@com_github_stretchr_testify//require", ], ) diff --git a/enterprise/cmd/executor/internal/command/BUILD.bazel b/enterprise/cmd/executor/internal/command/BUILD.bazel index d69214cab86..92a531fa189 100644 --- a/enterprise/cmd/executor/internal/command/BUILD.bazel +++ b/enterprise/cmd/executor/internal/command/BUILD.bazel @@ -15,7 +15,7 @@ go_library( visibility = ["//enterprise/cmd/executor:__subpackages__"], deps = [ "//enterprise/cmd/executor/internal/config", - "//enterprise/internal/executor", + "//enterprise/internal/executor/types", "//internal/executor", "//internal/lazyregexp", "//internal/metrics", @@ -43,7 +43,7 @@ go_test( ], embed = [":command"], deps = [ - "//enterprise/internal/executor", + "//enterprise/internal/executor/types", "//internal/executor", "//internal/observation", "//lib/errors", diff --git a/enterprise/cmd/executor/internal/config/BUILD.bazel b/enterprise/cmd/executor/internal/config/BUILD.bazel index 6d64255f40e..b414853d304 100644 --- a/enterprise/cmd/executor/internal/config/BUILD.bazel +++ b/enterprise/cmd/executor/internal/config/BUILD.bazel @@ -9,7 +9,7 @@ go_library( importpath = "github.com/sourcegraph/sourcegraph/enterprise/cmd/executor/internal/config", visibility = ["//enterprise/cmd/executor:__subpackages__"], deps = [ - "//enterprise/internal/executor", + "//enterprise/internal/executor/types", "//internal/conf/confdefaults", "//internal/conf/deploy", "//internal/env", diff --git a/enterprise/cmd/executor/internal/run/BUILD.bazel b/enterprise/cmd/executor/internal/run/BUILD.bazel index 712ee255c3c..26562b4e5e4 100644 --- a/enterprise/cmd/executor/internal/run/BUILD.bazel +++ b/enterprise/cmd/executor/internal/run/BUILD.bazel @@ -20,7 +20,7 @@ go_library( "//enterprise/cmd/executor/internal/janitor", "//enterprise/cmd/executor/internal/worker", "//enterprise/cmd/executor/internal/worker/workspace", - "//enterprise/internal/executor", + "//enterprise/internal/executor/types", "//internal/download", "//internal/goroutine", "//internal/observation", diff --git a/enterprise/cmd/executor/internal/worker/BUILD.bazel b/enterprise/cmd/executor/internal/worker/BUILD.bazel index bf6eff7f9ae..f56e27670af 100644 --- a/enterprise/cmd/executor/internal/worker/BUILD.bazel +++ b/enterprise/cmd/executor/internal/worker/BUILD.bazel @@ -18,7 +18,7 @@ go_library( "//enterprise/cmd/executor/internal/janitor", "//enterprise/cmd/executor/internal/metrics", "//enterprise/cmd/executor/internal/worker/workspace", - "//enterprise/internal/executor", + "//enterprise/internal/executor/types", "//internal/goroutine", "//internal/honey", "//internal/observation", @@ -44,7 +44,7 @@ go_test( "//enterprise/cmd/executor/internal/command", "//enterprise/cmd/executor/internal/janitor", "//enterprise/cmd/executor/internal/worker/workspace", - "//enterprise/internal/executor", + "//enterprise/internal/executor/types", "//internal/executor", "//internal/observation", "@com_github_google_go_cmp//cmp", diff --git a/enterprise/cmd/executor/internal/worker/workspace/BUILD.bazel b/enterprise/cmd/executor/internal/worker/workspace/BUILD.bazel index 9f044c0f809..b70bce92c3a 100644 --- a/enterprise/cmd/executor/internal/worker/workspace/BUILD.bazel +++ b/enterprise/cmd/executor/internal/worker/workspace/BUILD.bazel @@ -14,7 +14,7 @@ go_library( visibility = ["//enterprise/cmd/executor:__subpackages__"], deps = [ "//enterprise/cmd/executor/internal/command", - "//enterprise/internal/executor", + "//enterprise/internal/executor/types", "//lib/errors", "@com_github_c2h5oh_datasize//:datasize", ], diff --git a/enterprise/cmd/frontend/internal/auth/BUILD.bazel b/enterprise/cmd/frontend/internal/auth/BUILD.bazel index d4dfa3784b5..253fc8eee22 100644 --- a/enterprise/cmd/frontend/internal/auth/BUILD.bazel +++ b/enterprise/cmd/frontend/internal/auth/BUILD.bazel @@ -9,6 +9,7 @@ go_library( "//cmd/frontend/auth", "//cmd/frontend/external/app", "//cmd/frontend/graphqlbackend", + "//enterprise/cmd/frontend/internal/auth/azureoauth", "//enterprise/cmd/frontend/internal/auth/bitbucketcloudoauth", "//enterprise/cmd/frontend/internal/auth/gerrit", "//enterprise/cmd/frontend/internal/auth/githuboauth", diff --git a/enterprise/cmd/frontend/internal/auth/azureoauth/BUILD.bazel b/enterprise/cmd/frontend/internal/auth/azureoauth/BUILD.bazel new file mode 100644 index 00000000000..f7b038f3f2d --- /dev/null +++ b/enterprise/cmd/frontend/internal/auth/azureoauth/BUILD.bazel @@ -0,0 +1,49 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") + +go_library( + name = "azureoauth", + srcs = [ + "login.go", + "middleware.go", + "provider.go", + "session.go", + ], + importpath = "github.com/sourcegraph/sourcegraph/enterprise/cmd/frontend/internal/auth/azureoauth", + visibility = ["//enterprise/cmd/frontend:__subpackages__"], + deps = [ + "//cmd/frontend/auth", + "//cmd/frontend/auth/providers", + "//enterprise/cmd/frontend/internal/auth/oauth", + "//enterprise/internal/licensing", + "//internal/actor", + "//internal/conf", + "//internal/conf/conftypes", + "//internal/database", + "//internal/extsvc", + "//internal/extsvc/auth", + "//internal/extsvc/azuredevops", + "//lib/errors", + "//schema", + "@com_github_dghubble_gologin//:gologin", + "@com_github_dghubble_gologin//oauth2", + "@com_github_sourcegraph_log//:log", + "@org_golang_x_oauth2//:oauth2", + ], +) + +go_test( + name = "azureoauth_test", + srcs = ["provider_test.go"], + embed = [":azureoauth"], + deps = [ + "//enterprise/cmd/frontend/internal/auth/oauth", + "//internal/conf", + "//internal/database", + "//internal/database/dbtest", + "//internal/extsvc", + "//schema", + "@com_github_google_go_cmp//cmp", + "@com_github_sourcegraph_log//logtest", + "@org_golang_x_oauth2//:oauth2", + ], +) diff --git a/enterprise/cmd/frontend/internal/auth/oauth/BUILD.bazel b/enterprise/cmd/frontend/internal/auth/oauth/BUILD.bazel index 64cf7595071..83f0b1d9861 100644 --- a/enterprise/cmd/frontend/internal/auth/oauth/BUILD.bazel +++ b/enterprise/cmd/frontend/internal/auth/oauth/BUILD.bazel @@ -7,6 +7,7 @@ go_library( "middleware.go", "provider.go", "session.go", + "utils.go", ], importpath = "github.com/sourcegraph/sourcegraph/enterprise/cmd/frontend/internal/auth/oauth", visibility = ["//enterprise/cmd/frontend:__subpackages__"], @@ -22,6 +23,7 @@ go_library( "//internal/database", "//internal/env", "//internal/extsvc", + "//internal/extsvc/azuredevops", "//internal/extsvc/bitbucketcloud", "//internal/extsvc/github", "//internal/extsvc/gitlab", diff --git a/enterprise/cmd/frontend/internal/authz/resolvers/BUILD.bazel b/enterprise/cmd/frontend/internal/authz/resolvers/BUILD.bazel index 06e4c793bcf..e42dc5fdb88 100644 --- a/enterprise/cmd/frontend/internal/authz/resolvers/BUILD.bazel +++ b/enterprise/cmd/frontend/internal/authz/resolvers/BUILD.bazel @@ -4,7 +4,7 @@ go_library( name = "resolvers", srcs = [ "bitbucket_projects_permission_jobs.go", - "permission_sync_jobs.go", + "permissions_info.go", "permissions_sync_jobs.go", "repositories.go", "resolver.go", @@ -17,7 +17,6 @@ go_library( "//cmd/frontend/globals", "//cmd/frontend/graphqlbackend", "//cmd/frontend/graphqlbackend/graphqlutil", - "//enterprise/internal/authz/syncjobs", "//enterprise/internal/database", "//enterprise/internal/licensing", "//internal/actor", @@ -27,7 +26,6 @@ go_library( "//internal/authz/permssync", "//internal/database", "//internal/errcode", - "//internal/executor", "//internal/extsvc", "//internal/gitserver", "//internal/gqlutil", @@ -44,7 +42,7 @@ go_library( go_test( name = "resolvers_test", srcs = [ - "permission_sync_jobs_test.go", + "permissions_sync_jobs_test.go", "resolver_test.go", ], embed = [":resolvers"], @@ -54,7 +52,6 @@ go_test( "//cmd/frontend/graphqlbackend", "//cmd/frontend/graphqlbackend/graphqlutil", "//enterprise/internal/authz/github", - "//enterprise/internal/authz/syncjobs", "//enterprise/internal/database", "//enterprise/internal/licensing", "//internal/actor", diff --git a/enterprise/cmd/frontend/internal/batches/resolvers/BUILD.bazel b/enterprise/cmd/frontend/internal/batches/resolvers/BUILD.bazel index 8aa82989aca..b5e827ff2c8 100644 --- a/enterprise/cmd/frontend/internal/batches/resolvers/BUILD.bazel +++ b/enterprise/cmd/frontend/internal/batches/resolvers/BUILD.bazel @@ -103,6 +103,7 @@ go_test( "changeset_spec_connection_test.go", "changeset_spec_test.go", "changeset_test.go", + "changesets_stats_test.go", "code_host_connection_test.go", "credential_test.go", "main_test.go", diff --git a/enterprise/cmd/frontend/internal/completions/BUILD.bazel b/enterprise/cmd/frontend/internal/completions/BUILD.bazel new file mode 100644 index 00000000000..55ae8815696 --- /dev/null +++ b/enterprise/cmd/frontend/internal/completions/BUILD.bazel @@ -0,0 +1,17 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "completions", + srcs = ["init.go"], + importpath = "github.com/sourcegraph/sourcegraph/enterprise/cmd/frontend/internal/completions", + visibility = ["//enterprise/cmd/frontend:__subpackages__"], + deps = [ + "//cmd/frontend/enterprise", + "//enterprise/cmd/frontend/internal/completions/streaming", + "//enterprise/internal/codeintel", + "//internal/conf/conftypes", + "//internal/database", + "//internal/observation", + "@com_github_sourcegraph_log//:log", + ], +) diff --git a/enterprise/cmd/frontend/internal/completions/streaming/BUILD.bazel b/enterprise/cmd/frontend/internal/completions/streaming/BUILD.bazel new file mode 100644 index 00000000000..dd2279ff648 --- /dev/null +++ b/enterprise/cmd/frontend/internal/completions/streaming/BUILD.bazel @@ -0,0 +1,18 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "streaming", + srcs = ["stream.go"], + importpath = "github.com/sourcegraph/sourcegraph/enterprise/cmd/frontend/internal/completions/streaming", + visibility = ["//enterprise/cmd/frontend:__subpackages__"], + deps = [ + "//enterprise/cmd/frontend/internal/completions/streaming/anthropic", + "//enterprise/cmd/frontend/internal/completions/types", + "//internal/conf", + "//internal/httpcli", + "//internal/search/streaming/http", + "//internal/trace", + "//lib/errors", + "@com_github_sourcegraph_log//:log", + ], +) diff --git a/enterprise/cmd/frontend/internal/completions/streaming/anthropic/BUILD.bazel b/enterprise/cmd/frontend/internal/completions/streaming/anthropic/BUILD.bazel new file mode 100644 index 00000000000..03a0b5937f7 --- /dev/null +++ b/enterprise/cmd/frontend/internal/completions/streaming/anthropic/BUILD.bazel @@ -0,0 +1,34 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") + +go_library( + name = "anthropic", + srcs = [ + "anthropic.go", + "decoder.go", + "prompt.go", + ], + importpath = "github.com/sourcegraph/sourcegraph/enterprise/cmd/frontend/internal/completions/streaming/anthropic", + visibility = ["//enterprise/cmd/frontend:__subpackages__"], + deps = [ + "//enterprise/cmd/frontend/internal/completions/types", + "//internal/httpcli", + "//lib/errors", + ], +) + +go_test( + name = "anthropic_test", + srcs = [ + "anthropic_test.go", + "decoder_test.go", + "prompt_test.go", + ], + data = glob(["testdata/**"]), + embed = [":anthropic"], + deps = [ + "//enterprise/cmd/frontend/internal/completions/types", + "@com_github_hexops_autogold_v2//:autogold", + "@com_github_stretchr_testify//assert", + "@com_github_stretchr_testify//require", + ], +) diff --git a/enterprise/cmd/frontend/internal/completions/streaming/anthropic/anthropic_test.go b/enterprise/cmd/frontend/internal/completions/streaming/anthropic/anthropic_test.go index 7331a4131bb..216b989a632 100644 --- a/enterprise/cmd/frontend/internal/completions/streaming/anthropic/anthropic_test.go +++ b/enterprise/cmd/frontend/internal/completions/streaming/anthropic/anthropic_test.go @@ -8,7 +8,7 @@ import ( "net/http" "testing" - "github.com/hexops/autogold" + "github.com/hexops/autogold/v2" "github.com/stretchr/testify/assert" "github.com/sourcegraph/sourcegraph/enterprise/cmd/frontend/internal/completions/types" @@ -57,7 +57,7 @@ func TestValidAnthropicStream(t *testing.T) { if err != nil { t.Fatal(err) } - autogold.Equal(t, events) + autogold.ExpectFile(t, events) } func TestInvalidAnthropicStream(t *testing.T) { diff --git a/enterprise/cmd/frontend/internal/completions/types/BUILD.bazel b/enterprise/cmd/frontend/internal/completions/types/BUILD.bazel new file mode 100644 index 00000000000..42dd8b6868c --- /dev/null +++ b/enterprise/cmd/frontend/internal/completions/types/BUILD.bazel @@ -0,0 +1,9 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "types", + srcs = ["types.go"], + importpath = "github.com/sourcegraph/sourcegraph/enterprise/cmd/frontend/internal/completions/types", + visibility = ["//enterprise/cmd/frontend:__subpackages__"], + deps = ["//lib/errors"], +) diff --git a/enterprise/cmd/frontend/internal/compute/resolvers/BUILD.bazel b/enterprise/cmd/frontend/internal/compute/resolvers/BUILD.bazel index 11cba691648..ef124560e9d 100644 --- a/enterprise/cmd/frontend/internal/compute/resolvers/BUILD.bazel +++ b/enterprise/cmd/frontend/internal/compute/resolvers/BUILD.bazel @@ -26,6 +26,6 @@ go_test( "//enterprise/internal/compute", "//internal/database", "//internal/search/result", - "@com_github_hexops_autogold//:autogold", + "@com_github_hexops_autogold_v2//:autogold", ], ) diff --git a/enterprise/cmd/frontend/internal/compute/streaming/BUILD.bazel b/enterprise/cmd/frontend/internal/compute/streaming/BUILD.bazel index 1380bf608fa..5ff93dd9d08 100644 --- a/enterprise/cmd/frontend/internal/compute/streaming/BUILD.bazel +++ b/enterprise/cmd/frontend/internal/compute/streaming/BUILD.bazel @@ -23,8 +23,8 @@ go_library( "//internal/search/streaming/http", "//internal/trace", "//lib/errors", - "//lib/group", "@com_github_opentracing_opentracing_go//log", + "@com_github_sourcegraph_conc//stream", "@com_github_sourcegraph_log//:log", ], ) diff --git a/enterprise/cmd/frontend/internal/embeddings/BUILD.bazel b/enterprise/cmd/frontend/internal/embeddings/BUILD.bazel new file mode 100644 index 00000000000..3b0a6e3d68c --- /dev/null +++ b/enterprise/cmd/frontend/internal/embeddings/BUILD.bazel @@ -0,0 +1,20 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "embeddings", + srcs = ["init.go"], + importpath = "github.com/sourcegraph/sourcegraph/enterprise/cmd/frontend/internal/embeddings", + visibility = ["//enterprise/cmd/frontend:__subpackages__"], + deps = [ + "//cmd/frontend/enterprise", + "//enterprise/cmd/frontend/internal/embeddings/resolvers", + "//enterprise/internal/codeintel", + "//enterprise/internal/embeddings", + "//enterprise/internal/embeddings/background/contextdetection", + "//enterprise/internal/embeddings/background/repo", + "//internal/conf/conftypes", + "//internal/database", + "//internal/gitserver", + "//internal/observation", + ], +) diff --git a/enterprise/cmd/frontend/internal/embeddings/resolvers/BUILD.bazel b/enterprise/cmd/frontend/internal/embeddings/resolvers/BUILD.bazel new file mode 100644 index 00000000000..46f47f8f9d5 --- /dev/null +++ b/enterprise/cmd/frontend/internal/embeddings/resolvers/BUILD.bazel @@ -0,0 +1,19 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "resolvers", + srcs = ["resolvers.go"], + importpath = "github.com/sourcegraph/sourcegraph/enterprise/cmd/frontend/internal/embeddings/resolvers", + visibility = ["//enterprise/cmd/frontend:__subpackages__"], + deps = [ + "//cmd/frontend/graphqlbackend", + "//enterprise/internal/embeddings", + "//enterprise/internal/embeddings/background/contextdetection", + "//enterprise/internal/embeddings/background/repo", + "//internal/api", + "//internal/auth", + "//internal/database", + "//internal/gitserver", + "//lib/errors", + ], +) diff --git a/enterprise/cmd/frontend/internal/executorqueue/BUILD.bazel b/enterprise/cmd/frontend/internal/executorqueue/BUILD.bazel index 8ac6ccbf509..53fe49509d7 100644 --- a/enterprise/cmd/frontend/internal/executorqueue/BUILD.bazel +++ b/enterprise/cmd/frontend/internal/executorqueue/BUILD.bazel @@ -14,8 +14,10 @@ go_library( "//enterprise/cmd/frontend/internal/executorqueue/handler", "//enterprise/cmd/frontend/internal/executorqueue/queues/batches", "//enterprise/cmd/frontend/internal/executorqueue/queues/codeintel", + "//enterprise/internal/executor/store", "//internal/actor", "//internal/api", + "//internal/conf", "//internal/conf/confdefaults", "//internal/conf/conftypes", "//internal/conf/deploy", @@ -24,8 +26,8 @@ go_library( "//internal/httpcli", "//internal/metrics/store", "//internal/observation", + "//lib/errors", "@com_github_gorilla_mux//:mux", - "@com_github_inconshreveable_log15//:log15", "@com_github_sourcegraph_log//:log", ], ) @@ -39,7 +41,16 @@ go_test( ], embed = [":executorqueue"], deps = [ + "//enterprise/internal/executor/store", "//internal/api", + "//internal/conf", + "//internal/database", + "//internal/types", + "//lib/errors", + "//schema", + "@com_github_gorilla_mux//:mux", "@com_github_sourcegraph_log//logtest", + "@com_github_stretchr_testify//assert", + "@com_github_stretchr_testify//require", ], ) diff --git a/enterprise/cmd/frontend/internal/executorqueue/handler/BUILD.bazel b/enterprise/cmd/frontend/internal/executorqueue/handler/BUILD.bazel index 3816511e876..6d88a1ce24c 100644 --- a/enterprise/cmd/frontend/internal/executorqueue/handler/BUILD.bazel +++ b/enterprise/cmd/frontend/internal/executorqueue/handler/BUILD.bazel @@ -9,7 +9,8 @@ go_library( importpath = "github.com/sourcegraph/sourcegraph/enterprise/cmd/frontend/internal/executorqueue/handler", visibility = ["//enterprise/cmd/frontend:__subpackages__"], deps = [ - "//enterprise/internal/executor", + "//enterprise/internal/executor/store", + "//enterprise/internal/executor/types", "//internal/database", "//internal/executor", "//internal/metrics/store", @@ -20,7 +21,6 @@ go_library( "//lib/errors", "@com_github_gorilla_mux//:mux", "@com_github_grafana_regexp//:regexp", - "@com_github_inconshreveable_log15//:log15", "@com_github_prometheus_client_model//go", "@com_github_prometheus_common//expfmt", "@com_github_sourcegraph_log//:log", @@ -29,10 +29,14 @@ go_library( go_test( name = "handler_test", - srcs = ["handler_test.go"], - embed = [":handler"], + srcs = [ + "handler_test.go", + "routes_test.go", + ], deps = [ - "//enterprise/internal/executor", + ":handler", + "//enterprise/internal/executor/store", + "//enterprise/internal/executor/types", "//internal/database", "//internal/executor", "//internal/metrics/store", @@ -40,6 +44,11 @@ go_test( "//internal/workerutil/dbworker/store", "//internal/workerutil/dbworker/store/mocks", "//lib/errors", - "@com_github_google_go_cmp//cmp", + "@com_github_gorilla_mux//:mux", + "@com_github_prometheus_client_model//go", + "@com_github_prometheus_common//expfmt", + "@com_github_stretchr_testify//assert", + "@com_github_stretchr_testify//mock", + "@com_github_stretchr_testify//require", ], ) diff --git a/enterprise/cmd/frontend/internal/executorqueue/queues/batches/BUILD.bazel b/enterprise/cmd/frontend/internal/executorqueue/queues/batches/BUILD.bazel index 896056a0ecc..c614c2beb42 100644 --- a/enterprise/cmd/frontend/internal/executorqueue/queues/batches/BUILD.bazel +++ b/enterprise/cmd/frontend/internal/executorqueue/queues/batches/BUILD.bazel @@ -13,7 +13,7 @@ go_library( "//enterprise/cmd/frontend/internal/executorqueue/handler", "//enterprise/internal/batches/store", "//enterprise/internal/batches/types", - "//enterprise/internal/executor", + "//enterprise/internal/executor/types", "//internal/actor", "//internal/conf", "//internal/database", @@ -39,7 +39,7 @@ go_test( "//cmd/frontend/graphqlbackend", "//enterprise/internal/batches/store", "//enterprise/internal/batches/types", - "//enterprise/internal/executor", + "//enterprise/internal/executor/types", "//internal/api", "//internal/conf", "//internal/database", diff --git a/enterprise/cmd/frontend/internal/executorqueue/queues/codeintel/BUILD.bazel b/enterprise/cmd/frontend/internal/executorqueue/queues/codeintel/BUILD.bazel index 36e02dfcb00..36f99e648f9 100644 --- a/enterprise/cmd/frontend/internal/executorqueue/queues/codeintel/BUILD.bazel +++ b/enterprise/cmd/frontend/internal/executorqueue/queues/codeintel/BUILD.bazel @@ -12,7 +12,7 @@ go_library( "//enterprise/cmd/frontend/internal/executorqueue/handler", "//enterprise/internal/codeintel/autoindexing", "//enterprise/internal/codeintel/shared/types", - "//enterprise/internal/executor", + "//enterprise/internal/executor/types", "//internal/conf", "//internal/database", "//internal/encryption/keyring", @@ -31,7 +31,7 @@ go_test( deps = [ "//enterprise/cmd/frontend/internal/executorqueue/handler", "//enterprise/internal/codeintel/shared/types", - "//enterprise/internal/executor", + "//enterprise/internal/executor/types", "//internal/conf", "//internal/database", "//internal/src-cli", diff --git a/enterprise/cmd/frontend/internal/insights/resolvers/BUILD.bazel b/enterprise/cmd/frontend/internal/insights/resolvers/BUILD.bazel index 564fc7ff378..2bebaecd78e 100644 --- a/enterprise/cmd/frontend/internal/insights/resolvers/BUILD.bazel +++ b/enterprise/cmd/frontend/internal/insights/resolvers/BUILD.bazel @@ -83,7 +83,7 @@ go_test( "//lib/errors", "@com_github_google_go_cmp//cmp", "@com_github_graph_gophers_graphql_go//relay", - "@com_github_hexops_autogold//:autogold", + "@com_github_hexops_autogold_v2//:autogold", "@com_github_sourcegraph_log//logtest", "@com_github_stretchr_testify//assert", "@com_github_stretchr_testify//require", diff --git a/enterprise/cmd/frontend/internal/own/BUILD.bazel b/enterprise/cmd/frontend/internal/own/BUILD.bazel index bf414deea35..e7cca92fa31 100644 --- a/enterprise/cmd/frontend/internal/own/BUILD.bazel +++ b/enterprise/cmd/frontend/internal/own/BUILD.bazel @@ -11,6 +11,8 @@ go_library( "//enterprise/internal/codeintel", "//internal/conf/conftypes", "//internal/database", + "//internal/gitserver", "//internal/observation", + "//internal/own", ], ) diff --git a/enterprise/cmd/frontend/internal/own/resolvers/BUILD.bazel b/enterprise/cmd/frontend/internal/own/resolvers/BUILD.bazel index 956c87a75f1..429c2778af2 100644 --- a/enterprise/cmd/frontend/internal/own/resolvers/BUILD.bazel +++ b/enterprise/cmd/frontend/internal/own/resolvers/BUILD.bazel @@ -1,4 +1,4 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") go_library( name = "resolvers", @@ -7,6 +7,30 @@ go_library( visibility = ["//enterprise/cmd/frontend:__subpackages__"], deps = [ "//cmd/frontend/graphqlbackend", - "@com_github_graph_gophers_graphql_go//:graphql-go", + "//cmd/frontend/graphqlbackend/graphqlutil", + "//internal/api", + "//internal/database", + "//internal/own", + "//internal/own/codeowners", + ], +) + +go_test( + name = "resolvers_test", + srcs = ["resolvers_test.go"], + deps = [ + ":resolvers", + "//cmd/frontend/backend", + "//cmd/frontend/graphqlbackend", + "//internal/actor", + "//internal/api", + "//internal/authz", + "//internal/database", + "//internal/database/fakedb", + "//internal/gitserver", + "//internal/own/codeowners", + "//internal/own/codeowners/v1:codeowners", + "//internal/types", + "@com_github_graph_gophers_graphql_go//relay", ], ) diff --git a/enterprise/cmd/frontend/internal/repos/webhooks/BUILD.bazel b/enterprise/cmd/frontend/internal/repos/webhooks/BUILD.bazel index 52b20b858c8..26bf873f286 100644 --- a/enterprise/cmd/frontend/internal/repos/webhooks/BUILD.bazel +++ b/enterprise/cmd/frontend/internal/repos/webhooks/BUILD.bazel @@ -41,13 +41,19 @@ go_test( "//internal/extsvc/bitbucketcloud", "//internal/extsvc/bitbucketserver", "//internal/extsvc/gitlab/webhooks", + "//internal/grpc", + "//internal/grpc/defaults", "//internal/httpcli", "//internal/repos", "//internal/repoupdater", "//internal/repoupdater/protocol", + "//internal/repoupdater/v1:repoupdater", "//internal/types", "//schema", "@com_github_sourcegraph_log//logtest", "@com_github_stretchr_testify//assert", + "@org_golang_google_grpc//:go_default_library", + "@org_golang_google_grpc//codes", + "@org_golang_google_grpc//status", ], ) diff --git a/enterprise/cmd/frontend/shared/BUILD.bazel b/enterprise/cmd/frontend/shared/BUILD.bazel index 52d3dad18fa..40c106d96a9 100644 --- a/enterprise/cmd/frontend/shared/BUILD.bazel +++ b/enterprise/cmd/frontend/shared/BUILD.bazel @@ -18,8 +18,10 @@ go_library( "//enterprise/cmd/frontend/internal/batches", "//enterprise/cmd/frontend/internal/codeintel", "//enterprise/cmd/frontend/internal/codemonitors", + "//enterprise/cmd/frontend/internal/completions", "//enterprise/cmd/frontend/internal/compute", "//enterprise/cmd/frontend/internal/dotcom", + "//enterprise/cmd/frontend/internal/embeddings", "//enterprise/cmd/frontend/internal/executorqueue", "//enterprise/cmd/frontend/internal/insights", "//enterprise/cmd/frontend/internal/licensing/init", diff --git a/enterprise/cmd/repo-updater/internal/authz/BUILD.bazel b/enterprise/cmd/repo-updater/internal/authz/BUILD.bazel index ce6e2a2eea9..88d736feccf 100644 --- a/enterprise/cmd/repo-updater/internal/authz/BUILD.bazel +++ b/enterprise/cmd/repo-updater/internal/authz/BUILD.bazel @@ -14,7 +14,6 @@ go_library( deps = [ "//cmd/frontend/envvar", "//cmd/frontend/globals", - "//enterprise/internal/authz/syncjobs", "//enterprise/internal/database", "//enterprise/internal/licensing", "//internal/api", @@ -36,12 +35,13 @@ go_library( "//internal/workerutil/dbworker", "//internal/workerutil/dbworker/store", "//lib/errors", - "//lib/group", "@com_github_keegancsmith_sqlf//:sqlf", "@com_github_prometheus_client_golang//prometheus", "@com_github_prometheus_client_golang//prometheus/promauto", + "@com_github_sourcegraph_conc//pool", "@com_github_sourcegraph_log//:log", "@io_opentelemetry_go_otel//attribute", + "@org_golang_x_exp//maps", ], ) @@ -78,11 +78,11 @@ go_test( "//internal/workerutil/dbworker", "//internal/workerutil/dbworker/store", "//lib/errors", - "//lib/group", "@com_github_derision_test_go_mockgen//testutil/require", "@com_github_google_go_cmp//cmp", "@com_github_grafana_regexp//:regexp", "@com_github_inconshreveable_log15//:log15", + "@com_github_sourcegraph_conc//pool", "@com_github_sourcegraph_log//logtest", "@com_github_stretchr_testify//assert", "@com_github_stretchr_testify//require", diff --git a/enterprise/cmd/worker/internal/codeintel/BUILD.bazel b/enterprise/cmd/worker/internal/codeintel/BUILD.bazel index 67636e2604f..5a13186afb0 100644 --- a/enterprise/cmd/worker/internal/codeintel/BUILD.bazel +++ b/enterprise/cmd/worker/internal/codeintel/BUILD.bazel @@ -6,6 +6,7 @@ go_library( "autoindexing_dependency_scheduler_job.go", "autoindexing_janitor.go", "autoindexing_scheduler_job.go", + "autoindexing_summary_builder.go", "commitgraph_updater_job.go", "crates_syncer.go", "lsifuploadstore_expirer.go", diff --git a/enterprise/cmd/worker/internal/embeddings/contextdetection/BUILD.bazel b/enterprise/cmd/worker/internal/embeddings/contextdetection/BUILD.bazel new file mode 100644 index 00000000000..32144c70477 --- /dev/null +++ b/enterprise/cmd/worker/internal/embeddings/contextdetection/BUILD.bazel @@ -0,0 +1,33 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "contextdetection", + srcs = [ + "dataset.go", + "handler.go", + "janitor.go", + "worker.go", + ], + importpath = "github.com/sourcegraph/sourcegraph/enterprise/cmd/worker/internal/embeddings/contextdetection", + visibility = ["//enterprise/cmd/worker:__subpackages__"], + deps = [ + "//cmd/worker/job", + "//cmd/worker/shared/init/db", + "//enterprise/internal/database", + "//enterprise/internal/embeddings", + "//enterprise/internal/embeddings/background/contextdetection", + "//enterprise/internal/embeddings/embed", + "//internal/actor", + "//internal/conf", + "//internal/env", + "//internal/gitserver", + "//internal/goroutine", + "//internal/observation", + "//internal/uploadstore", + "//internal/workerutil", + "//internal/workerutil/dbworker", + "//internal/workerutil/dbworker/store", + "//lib/errors", + "@com_github_sourcegraph_log//:log", + ], +) diff --git a/enterprise/cmd/worker/internal/embeddings/repo/BUILD.bazel b/enterprise/cmd/worker/internal/embeddings/repo/BUILD.bazel new file mode 100644 index 00000000000..e993e375c16 --- /dev/null +++ b/enterprise/cmd/worker/internal/embeddings/repo/BUILD.bazel @@ -0,0 +1,34 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "repo", + srcs = [ + "handler.go", + "janitor.go", + "worker.go", + ], + importpath = "github.com/sourcegraph/sourcegraph/enterprise/cmd/worker/internal/embeddings/repo", + visibility = ["//enterprise/cmd/worker:__subpackages__"], + deps = [ + "//cmd/worker/job", + "//cmd/worker/shared/init/db", + "//enterprise/internal/database", + "//enterprise/internal/embeddings", + "//enterprise/internal/embeddings/background/repo", + "//enterprise/internal/embeddings/embed", + "//enterprise/internal/embeddings/split", + "//internal/actor", + "//internal/conf", + "//internal/env", + "//internal/gitserver", + "//internal/goroutine", + "//internal/observation", + "//internal/uploadstore", + "//internal/workerutil", + "//internal/workerutil/dbworker", + "//internal/workerutil/dbworker/store", + "//lib/errors", + "@com_github_grafana_regexp//:regexp", + "@com_github_sourcegraph_log//:log", + ], +) diff --git a/enterprise/cmd/worker/internal/telemetry/BUILD.bazel b/enterprise/cmd/worker/internal/telemetry/BUILD.bazel index a9a1ec7429e..68984a2e943 100644 --- a/enterprise/cmd/worker/internal/telemetry/BUILD.bazel +++ b/enterprise/cmd/worker/internal/telemetry/BUILD.bazel @@ -44,7 +44,7 @@ go_test( "//lib/errors", "//schema", "@com_github_google_go_cmp//cmp", - "@com_github_hexops_autogold//:autogold", + "@com_github_hexops_autogold_v2//:autogold", "@com_github_hexops_valast//:valast", "@com_github_keegancsmith_sqlf//:sqlf", "@com_github_lib_pq//:pq", diff --git a/enterprise/cmd/worker/shared/BUILD.bazel b/enterprise/cmd/worker/shared/BUILD.bazel index b452fe3de41..d91f0f0b5a3 100644 --- a/enterprise/cmd/worker/shared/BUILD.bazel +++ b/enterprise/cmd/worker/shared/BUILD.bazel @@ -17,6 +17,8 @@ go_library( "//enterprise/cmd/worker/internal/batches", "//enterprise/cmd/worker/internal/codeintel", "//enterprise/cmd/worker/internal/codemonitors", + "//enterprise/cmd/worker/internal/embeddings/contextdetection", + "//enterprise/cmd/worker/internal/embeddings/repo", "//enterprise/cmd/worker/internal/executors", "//enterprise/cmd/worker/internal/insights", "//enterprise/cmd/worker/internal/permissions", diff --git a/enterprise/dev/ci/internal/ci/BUILD.bazel b/enterprise/dev/ci/internal/ci/BUILD.bazel index 99f9dc2359a..81cf3967800 100644 --- a/enterprise/dev/ci/internal/ci/BUILD.bazel +++ b/enterprise/dev/ci/internal/ci/BUILD.bazel @@ -20,6 +20,7 @@ go_library( "//enterprise/dev/ci/internal/ci/changed", "//enterprise/dev/ci/internal/ci/operations", "//internal/lazyregexp", + "//internal/oobmigration", "//lib/errors", "@com_github_masterminds_semver//:semver", "@com_github_sourcegraph_log//:log", diff --git a/enterprise/dev/ci/scripts/app-token/BUILD.bazel b/enterprise/dev/ci/scripts/app-token/BUILD.bazel index 45df267d8cc..c5ece8349d1 100644 --- a/enterprise/dev/ci/scripts/app-token/BUILD.bazel +++ b/enterprise/dev/ci/scripts/app-token/BUILD.bazel @@ -23,6 +23,7 @@ go_test( name = "app-token_test", srcs = ["main_test.go"], embed = [":app-token_lib"], + env = {"BUILDKITE": "true"}, deps = [ "//internal/httptestutil", "@com_github_dnaeon_go_vcr//cassette", diff --git a/enterprise/dev/ci/scripts/app-token/main_test.go b/enterprise/dev/ci/scripts/app-token/main_test.go index a5eac7c14ec..064748fcfae 100644 --- a/enterprise/dev/ci/scripts/app-token/main_test.go +++ b/enterprise/dev/ci/scripts/app-token/main_test.go @@ -63,6 +63,10 @@ func newTestGitHubClient(ctx context.Context, t *testing.T) (ghc *github.Client, } func TestGetInstallAccessToken(t *testing.T) { + // We cannot perform external network requests in Bazel tests, it breaks the sandbox. + if os.Getenv("BAZEL_TEST") == "1" { + t.Skip("Skipping due to network request") + } ctx := context.Background() ghc, stop := newTestGitHubClient(ctx, t) diff --git a/enterprise/internal/authz/perforce/BUILD.bazel b/enterprise/internal/authz/perforce/BUILD.bazel index 791fe4153fd..5672394105a 100644 --- a/enterprise/internal/authz/perforce/BUILD.bazel +++ b/enterprise/internal/authz/perforce/BUILD.bazel @@ -34,7 +34,7 @@ go_test( "perforce_test.go", "protects_test.go", ], - data = glob(["testdata/**"]), + data = ["//enterprise/internal/authz/perforce/testdata:data"], embed = [":perforce"], deps = [ "//enterprise/internal/authz/subrepoperms", diff --git a/enterprise/internal/authz/perforce/testdata/BUILD.bazel b/enterprise/internal/authz/perforce/testdata/BUILD.bazel new file mode 100644 index 00000000000..7d86f3b5921 --- /dev/null +++ b/enterprise/internal/authz/perforce/testdata/BUILD.bazel @@ -0,0 +1,5 @@ +filegroup( + name = "data", + srcs = glob(["*.txt"]), + visibility = ["//enterprise/internal/authz/perforce:__subpackages__"], +) diff --git a/enterprise/internal/batches/processor/BUILD.bazel b/enterprise/internal/batches/processor/BUILD.bazel index da1500c0706..f4a1fb82fab 100644 --- a/enterprise/internal/batches/processor/BUILD.bazel +++ b/enterprise/internal/batches/processor/BUILD.bazel @@ -7,6 +7,7 @@ go_library( visibility = ["//enterprise:__subpackages__"], deps = [ "//enterprise/internal/batches/global", + "//enterprise/internal/batches/graphql", "//enterprise/internal/batches/service", "//enterprise/internal/batches/sources", "//enterprise/internal/batches/state", diff --git a/enterprise/internal/batches/reconciler/BUILD.bazel b/enterprise/internal/batches/reconciler/BUILD.bazel index f6c45eda4c7..445bb8d778a 100644 --- a/enterprise/internal/batches/reconciler/BUILD.bazel +++ b/enterprise/internal/batches/reconciler/BUILD.bazel @@ -11,6 +11,7 @@ go_library( importpath = "github.com/sourcegraph/sourcegraph/enterprise/internal/batches/reconciler", visibility = ["//enterprise:__subpackages__"], deps = [ + "//enterprise/internal/batches/graphql", "//enterprise/internal/batches/sources", "//enterprise/internal/batches/state", "//enterprise/internal/batches/store", diff --git a/enterprise/internal/batches/service/BUILD.bazel b/enterprise/internal/batches/service/BUILD.bazel index 16e25aefbfd..82cff1f5165 100644 --- a/enterprise/internal/batches/service/BUILD.bazel +++ b/enterprise/internal/batches/service/BUILD.bazel @@ -13,6 +13,7 @@ go_library( visibility = ["//enterprise:__subpackages__"], deps = [ "//enterprise/internal/batches/global", + "//enterprise/internal/batches/graphql", "//enterprise/internal/batches/rewirer", "//enterprise/internal/batches/sources", "//enterprise/internal/batches/store", @@ -44,6 +45,7 @@ go_library( "//lib/errors", "@com_github_gobwas_glob//:glob", "@com_github_grafana_regexp//:regexp", + "@com_github_graph_gophers_graphql_go//:graphql-go", "@com_github_opentracing_opentracing_go//log", "@com_github_sourcegraph_log//:log", "@in_gopkg_yaml_v2//:yaml_v2", diff --git a/enterprise/internal/batches/sources/BUILD.bazel b/enterprise/internal/batches/sources/BUILD.bazel index 4614bbb4a88..8ed7a683e3c 100644 --- a/enterprise/internal/batches/sources/BUILD.bazel +++ b/enterprise/internal/batches/sources/BUILD.bazel @@ -3,6 +3,7 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") go_library( name = "sources", srcs = [ + "azuredevops.go", "bitbucketcloud.go", "bitbucketserver.go", "common.go", @@ -14,6 +15,7 @@ go_library( importpath = "github.com/sourcegraph/sourcegraph/enterprise/internal/batches/sources", visibility = ["//enterprise:__subpackages__"], deps = [ + "//enterprise/internal/batches/sources/azuredevops", "//enterprise/internal/batches/sources/bitbucketcloud", "//enterprise/internal/batches/store", "//enterprise/internal/batches/types", @@ -21,6 +23,7 @@ go_library( "//internal/errcode", "//internal/extsvc", "//internal/extsvc/auth", + "//internal/extsvc/azuredevops", "//internal/extsvc/bitbucketcloud", "//internal/extsvc/bitbucketserver", "//internal/extsvc/github", @@ -42,6 +45,7 @@ go_library( go_test( name = "sources_test", srcs = [ + "azuredevops_test.go", "bitbucketcloud_test.go", "bitbucketserver_test.go", "github_test.go", @@ -53,6 +57,7 @@ go_test( data = glob(["testdata/**"]), embed = [":sources"], deps = [ + "//enterprise/internal/batches/sources/azuredevops", "//enterprise/internal/batches/sources/bitbucketcloud", "//enterprise/internal/batches/store", "//enterprise/internal/batches/types", @@ -61,6 +66,7 @@ go_test( "//internal/errcode", "//internal/extsvc", "//internal/extsvc/auth", + "//internal/extsvc/azuredevops", "//internal/extsvc/bitbucketcloud", "//internal/extsvc/bitbucketserver", "//internal/extsvc/github", diff --git a/enterprise/internal/batches/sources/azuredevops/BUILD.bazel b/enterprise/internal/batches/sources/azuredevops/BUILD.bazel new file mode 100644 index 00000000000..67bfcbf8716 --- /dev/null +++ b/enterprise/internal/batches/sources/azuredevops/BUILD.bazel @@ -0,0 +1,9 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "azuredevops", + srcs = ["types.go"], + importpath = "github.com/sourcegraph/sourcegraph/enterprise/internal/batches/sources/azuredevops", + visibility = ["//enterprise:__subpackages__"], + deps = ["//internal/extsvc/azuredevops"], +) diff --git a/enterprise/internal/batches/state/BUILD.bazel b/enterprise/internal/batches/state/BUILD.bazel index 9eeee1851ee..a1407bee622 100644 --- a/enterprise/internal/batches/state/BUILD.bazel +++ b/enterprise/internal/batches/state/BUILD.bazel @@ -11,6 +11,7 @@ go_library( importpath = "github.com/sourcegraph/sourcegraph/enterprise/internal/batches/state", visibility = ["//enterprise:__subpackages__"], deps = [ + "//enterprise/internal/batches/sources/azuredevops", "//enterprise/internal/batches/sources/bitbucketcloud", "//enterprise/internal/batches/types", "//internal/actor", @@ -18,6 +19,7 @@ go_library( "//internal/authz", "//internal/database", "//internal/extsvc", + "//internal/extsvc/azuredevops", "//internal/extsvc/bitbucketcloud", "//internal/extsvc/bitbucketserver", "//internal/extsvc/github", diff --git a/enterprise/internal/batches/store/BUILD.bazel b/enterprise/internal/batches/store/BUILD.bazel index 8644fef9f6e..212c63ee61b 100644 --- a/enterprise/internal/batches/store/BUILD.bazel +++ b/enterprise/internal/batches/store/BUILD.bazel @@ -28,6 +28,7 @@ go_library( visibility = ["//enterprise:__subpackages__"], deps = [ "//enterprise/internal/batches/search", + "//enterprise/internal/batches/sources/azuredevops", "//enterprise/internal/batches/sources/bitbucketcloud", "//enterprise/internal/batches/store/author", "//enterprise/internal/batches/types", @@ -41,6 +42,7 @@ go_library( "//internal/executor", "//internal/extsvc", "//internal/extsvc/auth", + "//internal/extsvc/azuredevops", "//internal/extsvc/bitbucketcloud", "//internal/extsvc/bitbucketserver", "//internal/extsvc/github", diff --git a/enterprise/internal/batches/types/BUILD.bazel b/enterprise/internal/batches/types/BUILD.bazel index bba4053952f..800f0df7f8e 100644 --- a/enterprise/internal/batches/types/BUILD.bazel +++ b/enterprise/internal/batches/types/BUILD.bazel @@ -26,6 +26,7 @@ go_library( importpath = "github.com/sourcegraph/sourcegraph/enterprise/internal/batches/types", visibility = ["//enterprise:__subpackages__"], deps = [ + "//enterprise/internal/batches/sources/azuredevops", "//enterprise/internal/batches/sources/bitbucketcloud", "//internal/api", "//internal/api/internalapi", @@ -45,6 +46,7 @@ go_library( "//lib/batches", "//lib/batches/execution", "//lib/errors", + "@com_github_goware_urlx//:urlx", "@com_github_graph_gophers_graphql_go//:graphql-go", "@com_github_graph_gophers_graphql_go//relay", "@com_github_inconshreveable_log15//:log15", @@ -65,10 +67,12 @@ go_test( ], embed = [":types"], deps = [ + "//enterprise/internal/batches/sources/azuredevops", "//enterprise/internal/batches/sources/bitbucketcloud", "//internal/database", "//internal/executor", "//internal/extsvc", + "//internal/extsvc/azuredevops", "//internal/extsvc/bitbucketcloud", "//internal/extsvc/bitbucketserver", "//internal/extsvc/github", diff --git a/enterprise/internal/batches/webhooks/BUILD.bazel b/enterprise/internal/batches/webhooks/BUILD.bazel index 9808446e0aa..fc19fa1dcc3 100644 --- a/enterprise/internal/batches/webhooks/BUILD.bazel +++ b/enterprise/internal/batches/webhooks/BUILD.bazel @@ -1,4 +1,4 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") go_library( name = "webhooks", @@ -6,21 +6,49 @@ go_library( "batch_change.go", "changeset.go", "event_types.go", + "gql.go", "util.go", "webhooks.go", ], importpath = "github.com/sourcegraph/sourcegraph/enterprise/internal/batches/webhooks", visibility = ["//enterprise:__subpackages__"], deps = [ - "//enterprise/internal/batches/graphql", - "//enterprise/internal/batches/types", - "//internal/database", + "//internal/api/internalapi", "//internal/database/basestore", "//internal/encryption", "//internal/encryption/keyring", + "//internal/httpcli", "//internal/webhooks/outbound", "//lib/errors", "@com_github_graph_gophers_graphql_go//:graphql-go", + "@com_github_graphql_go_graphql//gqlerrors", "@com_github_sourcegraph_log//:log", ], ) + +go_test( + name = "webhooks_test", + srcs = [ + "batch_change_test.go", + "changeset_test.go", + ], + embed = [":webhooks"], + deps = [ + "//cmd/frontend/graphqlbackend", + "//enterprise/internal/batches/graphql", + "//enterprise/internal/batches/store", + "//enterprise/internal/batches/testing", + "//enterprise/internal/batches/types", + "//internal/actor", + "//internal/database", + "//internal/database/dbtest", + "//internal/observation", + "//internal/timeutil", + "@com_github_google_go_cmp//cmp", + "@com_github_google_go_cmp//cmp/cmpopts", + "@com_github_graph_gophers_graphql_go//:graphql-go", + "@com_github_sourcegraph_log//logtest", + "@com_github_stretchr_testify//mock", + "@com_github_stretchr_testify//require", + ], +) diff --git a/enterprise/internal/codeintel/autoindexing/internal/background/BUILD.bazel b/enterprise/internal/codeintel/autoindexing/internal/background/BUILD.bazel index b5a20c312f6..29019a73774 100644 --- a/enterprise/internal/codeintel/autoindexing/internal/background/BUILD.bazel +++ b/enterprise/internal/codeintel/autoindexing/internal/background/BUILD.bazel @@ -9,6 +9,7 @@ go_library( "job_dependency_sync_scheduler.go", "job_resetters.go", "job_scheduler.go", + "job_summary_builder.go", "metrics_janitor.go", "metrics_resetter.go", "utils.go", @@ -18,6 +19,7 @@ go_library( deps = [ "//cmd/frontend/envvar", "//enterprise/internal/codeintel/autoindexing/internal/inference", + "//enterprise/internal/codeintel/autoindexing/internal/jobselector", "//enterprise/internal/codeintel/autoindexing/internal/store", "//enterprise/internal/codeintel/autoindexing/shared", "//enterprise/internal/codeintel/policies/enterprise", diff --git a/enterprise/internal/codeintel/autoindexing/internal/jobselector/BUILD.bazel b/enterprise/internal/codeintel/autoindexing/internal/jobselector/BUILD.bazel index 3f39ed16b0b..1fa24e1c1dc 100644 --- a/enterprise/internal/codeintel/autoindexing/internal/jobselector/BUILD.bazel +++ b/enterprise/internal/codeintel/autoindexing/internal/jobselector/BUILD.bazel @@ -9,13 +9,15 @@ go_library( importpath = "github.com/sourcegraph/sourcegraph/enterprise/internal/codeintel/autoindexing/internal/jobselector", visibility = ["//enterprise:__subpackages__"], deps = [ - "//enterprise/internal/codeintel/autoindexing/internal/background", "//enterprise/internal/codeintel/autoindexing/internal/store", "//enterprise/internal/codeintel/shared/types", + "//enterprise/internal/codeintel/uploads/shared", "//internal/api", "//internal/env", + "//internal/gitserver/gitdomain", "//lib/codeintel/autoindex/config", "//lib/errors", + "@com_github_grafana_regexp//:regexp", "@com_github_sourcegraph_log//:log", ], ) diff --git a/enterprise/internal/codeintel/autoindexing/internal/store/BUILD.bazel b/enterprise/internal/codeintel/autoindexing/internal/store/BUILD.bazel index f253830404a..ffd8a5ccb82 100644 --- a/enterprise/internal/codeintel/autoindexing/internal/store/BUILD.bazel +++ b/enterprise/internal/codeintel/autoindexing/internal/store/BUILD.bazel @@ -45,6 +45,7 @@ go_test( "store_expiration_test.go", "store_indexes_test.go", "store_language_support_test.go", + "store_repositories_test.go", "store_sourced_commits_test.go", ], embed = [":store"], diff --git a/enterprise/internal/codeintel/autoindexing/transport/graphql/BUILD.bazel b/enterprise/internal/codeintel/autoindexing/transport/graphql/BUILD.bazel index 7dca58fd0b2..0b858cf60f8 100644 --- a/enterprise/internal/codeintel/autoindexing/transport/graphql/BUILD.bazel +++ b/enterprise/internal/codeintel/autoindexing/transport/graphql/BUILD.bazel @@ -20,6 +20,7 @@ go_library( visibility = ["//enterprise:__subpackages__"], deps = [ "//cmd/frontend/graphqlbackend/graphqlutil", + "//enterprise/internal/codeintel/autoindexing/internal/inference", "//enterprise/internal/codeintel/autoindexing/shared", "//enterprise/internal/codeintel/shared/resolvers", "//enterprise/internal/codeintel/shared/types", diff --git a/enterprise/internal/codeintel/codenav/internal/lsifstore/BUILD.bazel b/enterprise/internal/codeintel/codenav/internal/lsifstore/BUILD.bazel index 59537d62020..32cff77e52d 100644 --- a/enterprise/internal/codeintel/codenav/internal/lsifstore/BUILD.bazel +++ b/enterprise/internal/codeintel/codenav/internal/lsifstore/BUILD.bazel @@ -15,7 +15,6 @@ go_library( "observability.go", "scan.go", "scip_decompressor.go", - "serializer.go", "types.go", ], importpath = "github.com/sourcegraph/sourcegraph/enterprise/internal/codeintel/codenav/internal/lsifstore", diff --git a/enterprise/internal/codeintel/ranking/internal/background/BUILD.bazel b/enterprise/internal/codeintel/ranking/internal/background/BUILD.bazel index 8a6bdd07dce..be288368e9a 100644 --- a/enterprise/internal/codeintel/ranking/internal/background/BUILD.bazel +++ b/enterprise/internal/codeintel/ranking/internal/background/BUILD.bazel @@ -27,10 +27,10 @@ go_library( "//internal/search", "//internal/search/result", "//lib/errors", - "//lib/group", "@com_github_dcadenas_pagerank//:pagerank", "@com_github_grafana_regexp//:regexp", "@com_github_prometheus_client_golang//prometheus", + "@com_github_sourcegraph_conc//pool", "@com_github_sourcegraph_log//:log", "@com_google_cloud_go_storage//:storage", "@org_golang_google_api//iterator", diff --git a/enterprise/internal/codeintel/uploads/BUILD.bazel b/enterprise/internal/codeintel/uploads/BUILD.bazel index cfc57b164be..073e8468fad 100644 --- a/enterprise/internal/codeintel/uploads/BUILD.bazel +++ b/enterprise/internal/codeintel/uploads/BUILD.bazel @@ -41,11 +41,11 @@ go_library( "//internal/workerutil/dbworker/store", "//lib/codeintel/precise", "//lib/errors", - "//lib/group", "@com_github_derision_test_glock//:glock", "@com_github_grafana_regexp//:regexp", "@com_github_opentracing_opentracing_go//log", "@com_github_prometheus_client_golang//prometheus", + "@com_github_sourcegraph_conc//pool", "@com_github_sourcegraph_log//:log", "@com_github_sourcegraph_scip//bindings/go/scip", "@com_google_cloud_go_storage//:storage", diff --git a/enterprise/internal/codeintel/uploads/internal/background/BUILD.bazel b/enterprise/internal/codeintel/uploads/internal/background/BUILD.bazel index 2f5cb3da826..977360ad68c 100644 --- a/enterprise/internal/codeintel/uploads/internal/background/BUILD.bazel +++ b/enterprise/internal/codeintel/uploads/internal/background/BUILD.bazel @@ -45,7 +45,6 @@ go_library( "//internal/workerutil", "//internal/workerutil/dbworker", "//internal/workerutil/dbworker/store", - "//lib/codeintel/lsif/conversion", "//lib/codeintel/pathexistence", "//lib/codeintel/precise", "//lib/errors", diff --git a/enterprise/internal/codeintel/uploads/internal/lsifstore/BUILD.bazel b/enterprise/internal/codeintel/uploads/internal/lsifstore/BUILD.bazel index f2975f344d3..5ace2b8742a 100644 --- a/enterprise/internal/codeintel/uploads/internal/lsifstore/BUILD.bazel +++ b/enterprise/internal/codeintel/uploads/internal/lsifstore/BUILD.bazel @@ -3,17 +3,14 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") go_library( name = "lsifstore", srcs = [ - "data_write.go", "lsifstore.go", "lsifstore_delete.go", "lsifstore_documents.go", "lsifstore_janitor.go", + "lsifstore_ranking.go", "lsifstore_reconcile.go", "observability.go", - "scip_compressor.go", - "scip_decompressor.go", "scip_write.go", - "serializer.go", "stream.go", ], importpath = "github.com/sourcegraph/sourcegraph/enterprise/internal/codeintel/uploads/internal/lsifstore", @@ -22,10 +19,10 @@ go_library( "//enterprise/internal/codeintel/shared", "//enterprise/internal/codeintel/shared/trie", "//enterprise/internal/codeintel/shared/types", + "//enterprise/internal/codeintel/uploads/shared", "//internal/database/basestore", "//internal/database/batch", "//internal/database/dbutil", - "//internal/goroutine", "//internal/metrics", "//internal/observation", "//lib/codeintel/precise", @@ -34,7 +31,6 @@ go_library( "@com_github_lib_pq//:pq", "@com_github_opentracing_opentracing_go//log", "@com_github_sourcegraph_scip//bindings/go/scip", - "@io_opentelemetry_go_otel//attribute", "@org_golang_google_protobuf//proto", ], ) @@ -47,7 +43,6 @@ go_test( "lsifstore_janitor_test.go", "lsifstore_reconcile_test.go", "scip_write_test.go", - "serializer_test.go", ], data = glob(["testdata/**"]), embed = [":lsifstore"], @@ -56,7 +51,6 @@ go_test( "//internal/database/basestore", "//internal/database/dbtest", "//internal/observation", - "//lib/codeintel/precise", "@com_github_google_go_cmp//cmp", "@com_github_keegancsmith_sqlf//:sqlf", "@com_github_sourcegraph_log//:log", diff --git a/enterprise/internal/codeintel/uploads/internal/store/BUILD.bazel b/enterprise/internal/codeintel/uploads/internal/store/BUILD.bazel index 1487dbdb945..7719db475ee 100644 --- a/enterprise/internal/codeintel/uploads/internal/store/BUILD.bazel +++ b/enterprise/internal/codeintel/uploads/internal/store/BUILD.bazel @@ -14,6 +14,7 @@ go_library( # TODO JH: I don't know what this isn't getting picked up by Gazelle "store_index.go", # keep "store_packages.go", + "store_ranking.go", "store_reconcile.go", "store_references.go", "store_repositories.go", @@ -60,6 +61,7 @@ go_test( # TODO JH: I don't know what this isn't getting picked up by Gazelle "store_index_test.go", # keep "store_packages_test.go", + "store_ranking_test.go", "store_reconcile_test.go", "store_references_test.go", "store_repositories_test.go", diff --git a/enterprise/internal/codeintel/uploads/shared/BUILD.bazel b/enterprise/internal/codeintel/uploads/shared/BUILD.bazel index 5ec643b92d1..97781a26bcc 100644 --- a/enterprise/internal/codeintel/uploads/shared/BUILD.bazel +++ b/enterprise/internal/codeintel/uploads/shared/BUILD.bazel @@ -2,7 +2,11 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library") go_library( name = "shared", - srcs = ["types.go"], + srcs = [ + "scip_compressor.go", + "scip_decompressor.go", + "types.go", + ], importpath = "github.com/sourcegraph/sourcegraph/enterprise/internal/codeintel/uploads/shared", visibility = ["//enterprise:__subpackages__"], deps = [ diff --git a/enterprise/internal/codemonitors/background/BUILD.bazel b/enterprise/internal/codemonitors/background/BUILD.bazel index b2aa2ef90f7..c8576de5b78 100644 --- a/enterprise/internal/codemonitors/background/BUILD.bazel +++ b/enterprise/internal/codemonitors/background/BUILD.bazel @@ -65,7 +65,7 @@ go_test( "//internal/search/result", "//internal/txemail", "@com_github_graph_gophers_graphql_go//relay", - "@com_github_hexops_autogold//:autogold", + "@com_github_hexops_autogold_v2//:autogold", "@com_github_sourcegraph_log//logtest", "@com_github_stretchr_testify//require", ], diff --git a/enterprise/internal/compute/BUILD.bazel b/enterprise/internal/compute/BUILD.bazel index 52e648c10f6..86a678ca054 100644 --- a/enterprise/internal/compute/BUILD.bazel +++ b/enterprise/internal/compute/BUILD.bazel @@ -47,6 +47,6 @@ go_test( "//internal/search/result", "//internal/types", "@com_github_grafana_regexp//:regexp", - "@com_github_hexops_autogold//:autogold", + "@com_github_hexops_autogold_v2//:autogold", ], ) diff --git a/enterprise/internal/compute/client/BUILD.bazel b/enterprise/internal/compute/client/BUILD.bazel index 079aad6458e..ca7de0281b7 100644 --- a/enterprise/internal/compute/client/BUILD.bazel +++ b/enterprise/internal/compute/client/BUILD.bazel @@ -27,6 +27,6 @@ go_test( "//enterprise/internal/compute", "//internal/search/streaming/api", "//internal/search/streaming/http", - "@com_github_hexops_autogold//:autogold", + "@com_github_hexops_autogold_v2//:autogold", ], ) diff --git a/enterprise/internal/database/BUILD.bazel b/enterprise/internal/database/BUILD.bazel index 422d8b39008..45889a41726 100644 --- a/enterprise/internal/database/BUILD.bazel +++ b/enterprise/internal/database/BUILD.bazel @@ -14,6 +14,7 @@ go_library( "code_monitor_trigger_jobs.go", "code_monitor_webhook.go", "code_monitors.go", + "codeowners.go", "database.go", "external_services.go", "mocks_temp.go", @@ -39,6 +40,7 @@ go_library( "//internal/database/dbutil", "//internal/encryption", "//internal/extsvc", + "//internal/own/codeowners/v1:codeowners", "//internal/search/result", "//internal/timeutil", "//internal/trace", @@ -47,12 +49,14 @@ go_library( "//schema", "@com_github_graph_gophers_graphql_go//:graphql-go", "@com_github_graph_gophers_graphql_go//relay", + "@com_github_jackc_pgconn//:pgconn", "@com_github_keegancsmith_sqlf//:sqlf", "@com_github_lib_pq//:pq", "@com_github_opentracing_opentracing_go//log", "@com_github_sourcegraph_log//:log", "@com_github_sourcegraph_log//logtest", "@com_github_stretchr_testify//require", + "@org_golang_google_protobuf//proto", ], ) @@ -69,6 +73,7 @@ go_test( "code_monitor_test.go", "code_monitor_trigger_jobs_test.go", "code_monitor_webhook_test.go", + "codeowners_test.go", "db_test.go", "external_services_test.go", "integration_test.go", @@ -85,9 +90,11 @@ go_test( "//internal/authz", "//internal/conf", "//internal/database", + "//internal/database/basestore", "//internal/database/dbtest", "//internal/database/dbutil", "//internal/extsvc", + "//internal/own/codeowners/v1:codeowners", "//internal/search/result", "//internal/timeutil", "//internal/types", @@ -102,6 +109,8 @@ go_test( "@com_github_sourcegraph_log//logtest", "@com_github_stretchr_testify//assert", "@com_github_stretchr_testify//require", + "@org_golang_google_protobuf//testing/protocmp", + "@org_golang_x_exp//maps", "@org_golang_x_sync//errgroup", ], ) diff --git a/enterprise/internal/embeddings/BUILD.bazel b/enterprise/internal/embeddings/BUILD.bazel new file mode 100644 index 00000000000..58fbfff2026 --- /dev/null +++ b/enterprise/internal/embeddings/BUILD.bazel @@ -0,0 +1,34 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") + +go_library( + name = "embeddings", + srcs = [ + "client.go", + "index_name.go", + "similarity_search.go", + "tokens.go", + "types.go", + "uploadstore.go", + ], + importpath = "github.com/sourcegraph/sourcegraph/enterprise/internal/embeddings", + visibility = ["//enterprise:__subpackages__"], + deps = [ + "//internal/api", + "//internal/conf/conftypes", + "//internal/endpoint", + "//internal/env", + "//internal/httpcli", + "//internal/lazyregexp", + "//internal/observation", + "//internal/uploadstore", + "//lib/errors", + ], +) + +go_test( + name = "embeddings_test", + srcs = ["similarity_search_test.go"], + data = glob(["testdata/**"]), + embed = [":embeddings"], + deps = ["@com_github_hexops_autogold_v2//:autogold"], +) diff --git a/enterprise/internal/embeddings/background/contextdetection/BUILD.bazel b/enterprise/internal/embeddings/background/contextdetection/BUILD.bazel new file mode 100644 index 00000000000..2f6e082c928 --- /dev/null +++ b/enterprise/internal/embeddings/background/contextdetection/BUILD.bazel @@ -0,0 +1,20 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "contextdetection", + srcs = [ + "store.go", + "types.go", + ], + importpath = "github.com/sourcegraph/sourcegraph/enterprise/internal/embeddings/background/contextdetection", + visibility = ["//enterprise:__subpackages__"], + deps = [ + "//internal/database/basestore", + "//internal/database/dbutil", + "//internal/executor", + "//internal/observation", + "//internal/workerutil/dbworker/store", + "@com_github_keegancsmith_sqlf//:sqlf", + "@com_github_lib_pq//:pq", + ], +) diff --git a/enterprise/internal/embeddings/background/repo/BUILD.bazel b/enterprise/internal/embeddings/background/repo/BUILD.bazel new file mode 100644 index 00000000000..b425c8fa6ec --- /dev/null +++ b/enterprise/internal/embeddings/background/repo/BUILD.bazel @@ -0,0 +1,22 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "repo", + srcs = [ + "mocks_temp.go", + "store.go", + "types.go", + ], + importpath = "github.com/sourcegraph/sourcegraph/enterprise/internal/embeddings/background/repo", + visibility = ["//enterprise:__subpackages__"], + deps = [ + "//internal/api", + "//internal/database/basestore", + "//internal/database/dbutil", + "//internal/executor", + "//internal/observation", + "//internal/workerutil/dbworker/store", + "@com_github_keegancsmith_sqlf//:sqlf", + "@com_github_lib_pq//:pq", + ], +) diff --git a/enterprise/internal/embeddings/embed/BUILD.bazel b/enterprise/internal/embeddings/embed/BUILD.bazel new file mode 100644 index 00000000000..155414309f3 --- /dev/null +++ b/enterprise/internal/embeddings/embed/BUILD.bazel @@ -0,0 +1,33 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") + +go_library( + name = "embed", + srcs = [ + "api.go", + "embed.go", + "files.go", + ], + importpath = "github.com/sourcegraph/sourcegraph/enterprise/internal/embeddings/embed", + visibility = ["//enterprise:__subpackages__"], + deps = [ + "//enterprise/internal/embeddings", + "//enterprise/internal/embeddings/split", + "//internal/api", + "//internal/binary", + "//internal/conf", + "//internal/httpcli", + "//lib/errors", + "//schema", + ], +) + +go_test( + name = "embed_test", + srcs = ["embed_test.go"], + embed = [":embed"], + deps = [ + "//enterprise/internal/embeddings/split", + "//internal/api", + "//lib/errors", + ], +) diff --git a/enterprise/internal/embeddings/similarity_search_test.go b/enterprise/internal/embeddings/similarity_search_test.go index 0df05fead81..e9076cd104a 100644 --- a/enterprise/internal/embeddings/similarity_search_test.go +++ b/enterprise/internal/embeddings/similarity_search_test.go @@ -3,7 +3,7 @@ package embeddings import ( "testing" - "github.com/hexops/autogold" + "github.com/hexops/autogold/v2" ) func TestSimilaritySearch(t *testing.T) { @@ -25,18 +25,18 @@ func TestSimilaritySearch(t *testing.T) { t.Run("find row with exact match", func(t *testing.T) { query := embeddings[0:3] results := index.SimilaritySearch(query, 1) - autogold.Equal(t, results) + autogold.ExpectFile(t, results) }) t.Run("find nearest neighbors", func(t *testing.T) { query := []float32{0.87006284, 0.48336824, 0.09667365} results := index.SimilaritySearch(query, 2) - autogold.Equal(t, results) + autogold.ExpectFile(t, results) }) t.Run("request more results then there are rows", func(t *testing.T) { query := embeddings[0:3] results := index.SimilaritySearch(query, 5) - autogold.Equal(t, results) + autogold.ExpectFile(t, results) }) } diff --git a/enterprise/internal/embeddings/split/BUILD.bazel b/enterprise/internal/embeddings/split/BUILD.bazel new file mode 100644 index 00000000000..68c7ca89cfa --- /dev/null +++ b/enterprise/internal/embeddings/split/BUILD.bazel @@ -0,0 +1,17 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") + +go_library( + name = "split", + srcs = ["split.go"], + importpath = "github.com/sourcegraph/sourcegraph/enterprise/internal/embeddings/split", + visibility = ["//enterprise:__subpackages__"], + deps = ["//enterprise/internal/embeddings"], +) + +go_test( + name = "split_test", + srcs = ["split_test.go"], + data = glob(["testdata/**"]), + embed = [":split"], + deps = ["@com_github_hexops_autogold_v2//:autogold"], +) diff --git a/enterprise/internal/embeddings/split/split_test.go b/enterprise/internal/embeddings/split/split_test.go index 13e3844a20f..4d70dd3b61f 100644 --- a/enterprise/internal/embeddings/split/split_test.go +++ b/enterprise/internal/embeddings/split/split_test.go @@ -3,7 +3,7 @@ package split import ( "testing" - "github.com/hexops/autogold" + "github.com/hexops/autogold/v2" ) func TestSplitIntoEmbeddableChunks(t *testing.T) { @@ -19,5 +19,5 @@ Line Line ` chunks := SplitIntoEmbeddableChunks(content, "", SplitOptions{ChunkTokensThreshold: 4, ChunkEarlySplitTokensThreshold: 1}) - autogold.Equal(t, chunks) + autogold.ExpectFile(t, chunks) } diff --git a/enterprise/internal/executor/BUILD.bazel b/enterprise/internal/executor/BUILD.bazel index d26ea865c9b..e69de29bb2d 100644 --- a/enterprise/internal/executor/BUILD.bazel +++ b/enterprise/internal/executor/BUILD.bazel @@ -1,19 +0,0 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") - -go_library( - name = "executor", - srcs = ["client_types.go"], - importpath = "github.com/sourcegraph/sourcegraph/enterprise/internal/executor", - visibility = ["//enterprise:__subpackages__"], - deps = ["//internal/executor"], -) - -go_test( - name = "executor_test", - srcs = ["client_types_test.go"], - embed = [":executor"], - deps = [ - "@com_github_google_go_cmp//cmp", - "@com_github_stretchr_testify//require", - ], -) diff --git a/enterprise/internal/executor/store/BUILD.bazel b/enterprise/internal/executor/store/BUILD.bazel new file mode 100644 index 00000000000..847c9e7ce58 --- /dev/null +++ b/enterprise/internal/executor/store/BUILD.bazel @@ -0,0 +1,40 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") + +go_library( + name = "store", + srcs = [ + "mocks_temp.go", + "observability.go", + "store.go", + ], + importpath = "github.com/sourcegraph/sourcegraph/enterprise/internal/executor/store", + visibility = ["//enterprise:__subpackages__"], + deps = [ + "//internal/database", + "//internal/database/basestore", + "//internal/hashutil", + "//internal/metrics", + "//internal/observation", + "//lib/errors", + "@com_github_jackc_pgconn//:pgconn", + "@com_github_keegancsmith_sqlf//:sqlf", + "@com_github_sourcegraph_log//:log", + ], +) + +go_test( + name = "store_test", + srcs = ["store_test.go"], + deps = [ + ":store", + "//enterprise/internal/batches/testing", + "//internal/database", + "//internal/database/dbtest", + "//internal/extsvc", + "//internal/observation", + "//lib/errors", + "@com_github_sourcegraph_log//logtest", + "@com_github_stretchr_testify//assert", + "@com_github_stretchr_testify//require", + ], +) diff --git a/enterprise/internal/executor/types/BUILD.bazel b/enterprise/internal/executor/types/BUILD.bazel new file mode 100644 index 00000000000..80bec648966 --- /dev/null +++ b/enterprise/internal/executor/types/BUILD.bazel @@ -0,0 +1,22 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") + +go_library( + name = "types", + srcs = [ + "http.go", + "job.go", + ], + importpath = "github.com/sourcegraph/sourcegraph/enterprise/internal/executor/types", + visibility = ["//enterprise:__subpackages__"], + deps = ["//internal/executor"], +) + +go_test( + name = "types_test", + srcs = ["job_test.go"], + embed = [":types"], + deps = [ + "@com_github_google_go_cmp//cmp", + "@com_github_stretchr_testify//require", + ], +) diff --git a/enterprise/internal/insights/aggregation/BUILD.bazel b/enterprise/internal/insights/aggregation/BUILD.bazel index 683640134ca..9b971b9d0e4 100644 --- a/enterprise/internal/insights/aggregation/BUILD.bazel +++ b/enterprise/internal/insights/aggregation/BUILD.bazel @@ -39,6 +39,6 @@ go_test( "//internal/search/result", "//internal/search/streaming", "//internal/types", - "@com_github_hexops_autogold//:autogold", + "@com_github_hexops_autogold_v2//:autogold", ], ) diff --git a/enterprise/internal/insights/background/BUILD.bazel b/enterprise/internal/insights/background/BUILD.bazel index a518ee87499..e67956974d9 100644 --- a/enterprise/internal/insights/background/BUILD.bazel +++ b/enterprise/internal/insights/background/BUILD.bazel @@ -72,7 +72,7 @@ go_test( "//internal/timeutil", "//internal/types", "//lib/errors", - "@com_github_hexops_autogold//:autogold", + "@com_github_hexops_autogold_v2//:autogold", "@com_github_keegancsmith_sqlf//:sqlf", "@com_github_sourcegraph_log//logtest", ], diff --git a/enterprise/internal/insights/background/queryrunner/BUILD.bazel b/enterprise/internal/insights/background/queryrunner/BUILD.bazel index 08404656e9a..c5f82d373bd 100644 --- a/enterprise/internal/insights/background/queryrunner/BUILD.bazel +++ b/enterprise/internal/insights/background/queryrunner/BUILD.bazel @@ -71,7 +71,7 @@ go_test( "//internal/types", "//internal/workerutil/dbworker/store", "//lib/errors", - "@com_github_hexops_autogold//:autogold", + "@com_github_hexops_autogold_v2//:autogold", "@com_github_keegancsmith_sqlf//:sqlf", "@com_github_sourcegraph_log//logtest", "@com_github_stretchr_testify//require", diff --git a/enterprise/internal/insights/background/retention/BUILD.bazel b/enterprise/internal/insights/background/retention/BUILD.bazel index e12b08d5f27..dec3ffa3f8d 100644 --- a/enterprise/internal/insights/background/retention/BUILD.bazel +++ b/enterprise/internal/insights/background/retention/BUILD.bazel @@ -41,6 +41,8 @@ go_test( "//internal/database/basestore", "//internal/database/dbtest", "//internal/observation", + "//schema", "@com_github_sourcegraph_log//logtest", + "@com_github_stretchr_testify//assert", ], ) diff --git a/enterprise/internal/insights/compression/BUILD.bazel b/enterprise/internal/insights/compression/BUILD.bazel index 5453956bfcc..451ddf41a6d 100644 --- a/enterprise/internal/insights/compression/BUILD.bazel +++ b/enterprise/internal/insights/compression/BUILD.bazel @@ -23,7 +23,7 @@ go_test( "//internal/api", "//internal/gitserver/gitdomain", "//lib/errors", - "@com_github_hexops_autogold//:autogold", + "@com_github_hexops_autogold_v2//:autogold", "@com_github_sourcegraph_log//logtest", ], ) diff --git a/enterprise/internal/insights/discovery/BUILD.bazel b/enterprise/internal/insights/discovery/BUILD.bazel index 04aa65d49c5..63a46b0a50b 100644 --- a/enterprise/internal/insights/discovery/BUILD.bazel +++ b/enterprise/internal/insights/discovery/BUILD.bazel @@ -39,7 +39,7 @@ go_test( "//internal/api", "//internal/database", "//internal/types", - "@com_github_hexops_autogold//:autogold", + "@com_github_hexops_autogold_v2//:autogold", "@com_github_prometheus_client_golang//prometheus", ], ) diff --git a/enterprise/internal/insights/gitserver/BUILD.bazel b/enterprise/internal/insights/gitserver/BUILD.bazel index 3332c9e959c..7729d8c726c 100644 --- a/enterprise/internal/insights/gitserver/BUILD.bazel +++ b/enterprise/internal/insights/gitserver/BUILD.bazel @@ -23,6 +23,6 @@ go_test( embed = [":gitserver"], deps = [ "//lib/errors", - "@com_github_hexops_autogold//:autogold", + "@com_github_hexops_autogold_v2//:autogold", ], ) diff --git a/enterprise/internal/insights/pipeline/BUILD.bazel b/enterprise/internal/insights/pipeline/BUILD.bazel index d26fa2711a1..13ad10fc2a8 100644 --- a/enterprise/internal/insights/pipeline/BUILD.bazel +++ b/enterprise/internal/insights/pipeline/BUILD.bazel @@ -19,10 +19,10 @@ go_library( "//internal/search/query", "//internal/types", "//lib/errors", - "//lib/group", "@com_github_derision_test_glock//:glock", "@com_github_prometheus_client_golang//prometheus", "@com_github_prometheus_client_golang//prometheus/promauto", + "@com_github_sourcegraph_conc//pool", "@com_github_sourcegraph_log//:log", ], ) @@ -44,7 +44,7 @@ go_test( "//internal/types", "//lib/errors", "@com_github_derision_test_glock//:glock", - "@com_github_hexops_autogold//:autogold", + "@com_github_hexops_autogold_v2//:autogold", "@com_github_sourcegraph_log//logtest", "@org_golang_x_time//rate", ], diff --git a/enterprise/internal/insights/query/querybuilder/BUILD.bazel b/enterprise/internal/insights/query/querybuilder/BUILD.bazel index ef7aa027cd3..64791faf98b 100644 --- a/enterprise/internal/insights/query/querybuilder/BUILD.bazel +++ b/enterprise/internal/insights/query/querybuilder/BUILD.bazel @@ -32,7 +32,7 @@ go_test( "//lib/errors", "@com_github_google_go_cmp//cmp", "@com_github_grafana_regexp//:regexp", - "@com_github_hexops_autogold//:autogold", + "@com_github_hexops_autogold_v2//:autogold", "@com_github_stretchr_testify//require", ], ) diff --git a/enterprise/internal/insights/scheduler/BUILD.bazel b/enterprise/internal/insights/scheduler/BUILD.bazel index ff055178fc8..061ef65ea9a 100644 --- a/enterprise/internal/insights/scheduler/BUILD.bazel +++ b/enterprise/internal/insights/scheduler/BUILD.bazel @@ -38,10 +38,10 @@ go_library( "//internal/workerutil/dbworker", "//internal/workerutil/dbworker/store", "//lib/errors", - "//lib/group", "@com_github_derision_test_glock//:glock", "@com_github_keegancsmith_sqlf//:sqlf", "@com_github_lib_pq//:pq", + "@com_github_sourcegraph_conc//pool", "@com_github_sourcegraph_log//:log", ], ) @@ -72,7 +72,7 @@ go_test( "//internal/types", "//lib/errors", "@com_github_derision_test_glock//:glock", - "@com_github_hexops_autogold//:autogold", + "@com_github_hexops_autogold_v2//:autogold", "@com_github_sourcegraph_log//logtest", "@com_github_stretchr_testify//assert", "@com_github_stretchr_testify//require", diff --git a/enterprise/internal/insights/scheduler/iterator/BUILD.bazel b/enterprise/internal/insights/scheduler/iterator/BUILD.bazel index b9340cfafd4..3f0b8c0e7dd 100644 --- a/enterprise/internal/insights/scheduler/iterator/BUILD.bazel +++ b/enterprise/internal/insights/scheduler/iterator/BUILD.bazel @@ -27,7 +27,7 @@ go_test( "//internal/database/dbtest", "//lib/errors", "@com_github_derision_test_glock//:glock", - "@com_github_hexops_autogold//:autogold", + "@com_github_hexops_autogold_v2//:autogold", "@com_github_sourcegraph_log//logtest", "@com_github_stretchr_testify//require", ], diff --git a/enterprise/internal/insights/store/BUILD.bazel b/enterprise/internal/insights/store/BUILD.bazel index 9c282a50f6f..de4137a94c4 100644 --- a/enterprise/internal/insights/store/BUILD.bazel +++ b/enterprise/internal/insights/store/BUILD.bazel @@ -55,7 +55,7 @@ go_test( "//internal/timeutil", "//lib/errors", "@com_github_google_go_cmp//cmp", - "@com_github_hexops_autogold//:autogold", + "@com_github_hexops_autogold_v2//:autogold", "@com_github_hexops_valast//:valast", "@com_github_keegancsmith_sqlf//:sqlf", "@com_github_sourcegraph_log//logtest", diff --git a/enterprise/internal/insights/timeseries/BUILD.bazel b/enterprise/internal/insights/timeseries/BUILD.bazel index b1931c40487..2664d7f287c 100644 --- a/enterprise/internal/insights/timeseries/BUILD.bazel +++ b/enterprise/internal/insights/timeseries/BUILD.bazel @@ -21,6 +21,6 @@ go_test( deps = [ "//enterprise/internal/insights/types", "@com_github_google_go_cmp//cmp", - "@com_github_hexops_autogold//:autogold", + "@com_github_hexops_autogold_v2//:autogold", ], ) diff --git a/enterprise/internal/notebooks/BUILD.bazel b/enterprise/internal/notebooks/BUILD.bazel index f252504d73c..edf17f471af 100644 --- a/enterprise/internal/notebooks/BUILD.bazel +++ b/enterprise/internal/notebooks/BUILD.bazel @@ -34,7 +34,7 @@ go_test( "//internal/database", "//internal/database/dbtest", "//lib/errors", - "@com_github_hexops_autogold//:autogold", + "@com_github_hexops_autogold_v2//:autogold", "@com_github_sourcegraph_log//logtest", ], ) diff --git a/enterprise/internal/oobmigration/migrations/batches/BUILD.bazel b/enterprise/internal/oobmigration/migrations/batches/BUILD.bazel index 01db849cee6..17e73305d34 100644 --- a/enterprise/internal/oobmigration/migrations/batches/BUILD.bazel +++ b/enterprise/internal/oobmigration/migrations/batches/BUILD.bazel @@ -23,17 +23,29 @@ go_library( go_test( name = "batches_test", - srcs = ["ssh_migrator_test.go"], + srcs = [ + "external_fork_name_migrator_test.go", + "ssh_migrator_test.go", + ], embed = [":batches"], deps = [ + "//enterprise/internal/batches/sources/bitbucketcloud", + "//enterprise/internal/batches/store", + "//enterprise/internal/batches/testing", "//internal/actor", + "//internal/api", "//internal/database", "//internal/database/basestore", "//internal/database/dbtest", "//internal/database/dbutil", "//internal/encryption", "//internal/encryption/testing", + "//internal/extsvc", + "//internal/extsvc/bitbucketcloud", + "//internal/extsvc/bitbucketserver", + "//internal/observation", "@com_github_keegancsmith_sqlf//:sqlf", "@com_github_sourcegraph_log//logtest", + "@com_github_stretchr_testify//assert", ], ) diff --git a/enterprise/internal/oobmigration/migrations/codeintel/BUILD.bazel b/enterprise/internal/oobmigration/migrations/codeintel/BUILD.bazel index de4bcffa68c..e3494f5b6b6 100644 --- a/enterprise/internal/oobmigration/migrations/codeintel/BUILD.bazel +++ b/enterprise/internal/oobmigration/migrations/codeintel/BUILD.bazel @@ -23,9 +23,9 @@ go_library( "//lib/codeintel/lsif/scip", "//lib/codeintel/precise", "//lib/errors", - "//lib/group", "@com_github_keegancsmith_sqlf//:sqlf", "@com_github_lib_pq//:pq", + "@com_github_sourcegraph_conc//pool", "@com_github_sourcegraph_scip//bindings/go/scip", "@io_k8s_utils//lru", "@org_golang_google_protobuf//proto", diff --git a/enterprise/internal/oobmigration/migrations/insights/BUILD.bazel b/enterprise/internal/oobmigration/migrations/insights/BUILD.bazel index cba94c9358e..b921f0f1726 100644 --- a/enterprise/internal/oobmigration/migrations/insights/BUILD.bazel +++ b/enterprise/internal/oobmigration/migrations/insights/BUILD.bazel @@ -38,7 +38,7 @@ go_test( "//internal/database/basestore", "//internal/database/dbtest", "//internal/database/dbutil", - "@com_github_hexops_autogold//:autogold", + "@com_github_hexops_autogold_v2//:autogold", "@com_github_keegancsmith_sqlf//:sqlf", "@com_github_lib_pq//:pq", "@com_github_sourcegraph_log//logtest", diff --git a/enterprise/internal/oobmigration/migrations/insights/backfillv2/BUILD.bazel b/enterprise/internal/oobmigration/migrations/insights/backfillv2/BUILD.bazel index 28b197ef6b2..60599b35920 100644 --- a/enterprise/internal/oobmigration/migrations/insights/backfillv2/BUILD.bazel +++ b/enterprise/internal/oobmigration/migrations/insights/backfillv2/BUILD.bazel @@ -29,7 +29,7 @@ go_test( "//internal/database/basestore", "//internal/database/dbtest", "@com_github_derision_test_glock//:glock", - "@com_github_hexops_autogold//:autogold", + "@com_github_hexops_autogold_v2//:autogold", "@com_github_keegancsmith_sqlf//:sqlf", "@com_github_lib_pq//:pq", "@com_github_sourcegraph_log//logtest", diff --git a/enterprise/internal/oobmigration/migrations/insights/recording_times/BUILD.bazel b/enterprise/internal/oobmigration/migrations/insights/recording_times/BUILD.bazel index 7ec777a2c79..0a7d65d28f9 100644 --- a/enterprise/internal/oobmigration/migrations/insights/recording_times/BUILD.bazel +++ b/enterprise/internal/oobmigration/migrations/insights/recording_times/BUILD.bazel @@ -29,7 +29,7 @@ go_test( "//internal/database/basestore", "//internal/database/dbtest", "@com_github_google_go_cmp//cmp", - "@com_github_hexops_autogold//:autogold", + "@com_github_hexops_autogold_v2//:autogold", "@com_github_keegancsmith_sqlf//:sqlf", "@com_github_sourcegraph_log//logtest", ], diff --git a/enterprise/internal/scim/BUILD.bazel b/enterprise/internal/scim/BUILD.bazel index c5bc78194e4..921f5fb71e0 100644 --- a/enterprise/internal/scim/BUILD.bazel +++ b/enterprise/internal/scim/BUILD.bazel @@ -4,14 +4,25 @@ go_library( name = "scim", srcs = [ "init.go", + "mock_db.go", + "test_util.go", "user.go", + "user_account_data.go", + "user_create.go", + "user_delete.go", + "user_get.go", + "user_patch.go", + "user_replace.go", + "user_schema.go", ], importpath = "github.com/sourcegraph/sourcegraph/enterprise/internal/scim", visibility = ["//enterprise:__subpackages__"], deps = [ + "//cmd/frontend/auth", "//cmd/frontend/enterprise", "//enterprise/internal/codeintel", "//enterprise/internal/scim/filter", + "//internal/authz", "//internal/conf", "//internal/conf/conftypes", "//internal/database", @@ -23,18 +34,22 @@ go_library( "@com_github_elimity_com_scim//errors", "@com_github_elimity_com_scim//optional", "@com_github_elimity_com_scim//schema", + "@com_github_scim2_filter_parser_v2//:filter-parser", "@com_github_sourcegraph_log//:log", ], ) go_test( name = "scim_test", - srcs = ["user_test.go"], + srcs = [ + "user_create_test.go", + "user_get_test.go", + "user_patch_test.go", + "user_replace_test.go", + ], embed = [":scim"], deps = [ - "//internal/database", "//internal/observation", - "//internal/types", "@com_github_elimity_com_scim//:scim", "@com_github_scim2_filter_parser_v2//:filter-parser", "@com_github_stretchr_testify//assert", diff --git a/go.mod b/go.mod index ed2a0904194..b94375d3971 100644 --- a/go.mod +++ b/go.mod @@ -257,7 +257,6 @@ require ( github.com/golang-jwt/jwt v3.2.2+incompatible github.com/google/go-github/v47 v47.1.0 github.com/grpc-ecosystem/go-grpc-middleware/providers/openmetrics/v2 v2.0.0-rc.3 - github.com/hexops/autogold v1.3.1 github.com/hexops/autogold/v2 v2.1.0 github.com/k3a/html2text v1.1.0 github.com/opsgenie/opsgenie-go-sdk-v2 v1.2.13 diff --git a/go.sum b/go.sum index 3e460cdb5b6..de0d82b1b60 100644 --- a/go.sum +++ b/go.sum @@ -1364,7 +1364,6 @@ github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb/go.mod h1:+NfK9FKe github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM= github.com/hexops/autogold v0.8.1/go.mod h1:97HLDXyG23akzAoRYJh/2OBs3kd80eHyKPvZw0S5ZBY= github.com/hexops/autogold v1.3.1 h1:YgxF9OHWbEIUjhDbpnLhgVsjUDsiHDTyDfy2lrfdlzo= -github.com/hexops/autogold v1.3.1/go.mod h1:sQO+mQUCVfxOKPht+ipDSkJ2SCJ7BNJVHZexsXqWMx4= github.com/hexops/autogold/v2 v2.1.0 h1:5s9J6CROngFPkgowSkV20bIflBrImSdDqIpoXJeZSkU= github.com/hexops/autogold/v2 v2.1.0/go.mod h1:cYVc0tJn6v9Uf9xMOHvmH6scuTxsVJSxGcKR/yOVPzY= github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM= diff --git a/internal/BUILD.bazel b/internal/BUILD.bazel new file mode 100644 index 00000000000..a46e019a5f6 --- /dev/null +++ b/internal/BUILD.bazel @@ -0,0 +1 @@ +exports_files(["buf.yaml"]) diff --git a/internal/audit/integration/integration_test.go b/internal/audit/integration/integration_test.go index 93530994b48..9a91e911781 100644 --- a/internal/audit/integration/integration_test.go +++ b/internal/audit/integration/integration_test.go @@ -2,6 +2,7 @@ package integration import ( "context" + "os" "strings" "testing" @@ -10,6 +11,10 @@ import ( ) func TestIntegration(t *testing.T) { + if os.Getenv("BAZEL_TEST") == "1" { + t.Skip("Don't run test due to running commands in bazel sandbox.") + } + // audit logs are logged under INFO severity t.Setenv("SRC_LOG_LEVEL", "info") diff --git a/internal/auth/BUILD.bazel b/internal/auth/BUILD.bazel index 71c0be1b2b2..59b7bb6be13 100644 --- a/internal/auth/BUILD.bazel +++ b/internal/auth/BUILD.bazel @@ -1,4 +1,4 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") go_library( name = "auth", @@ -17,3 +17,16 @@ go_library( "//lib/errors", ], ) + +go_test( + name = "auth_test", + srcs = ["site_admin_test.go"], + embed = [":auth"], + deps = [ + "//internal/actor", + "//internal/database", + "//internal/types", + "//lib/errors", + "@com_github_stretchr_testify//require", + ], +) diff --git a/internal/binary/BUILD.bazel b/internal/binary/BUILD.bazel new file mode 100644 index 00000000000..7d5d27494fd --- /dev/null +++ b/internal/binary/BUILD.bazel @@ -0,0 +1,8 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "binary", + srcs = ["binary.go"], + importpath = "github.com/sourcegraph/sourcegraph/internal/binary", + visibility = ["//:__subpackages__"], +) diff --git a/internal/cmd/git-combine/git-combine_test.go b/internal/cmd/git-combine/git-combine_test.go index 4af8bf743d0..a49b792fa2e 100644 --- a/internal/cmd/git-combine/git-combine_test.go +++ b/internal/cmd/git-combine/git-combine_test.go @@ -24,7 +24,18 @@ func TestCombine(t *testing.T) { set -ex +mkdir origin +cd origin +git init +echo "foobar" > README.md +git add README.md +git commit -m "initial commit" +echo "foobar" >> README.md +git add README.md +git commit -m "second commit" + repo=$(git rev-parse --show-toplevel) +cd .. mkdir -p "$DIR" cd "$DIR" diff --git a/internal/codeintel/dependencies/internal/store/BUILD.bazel b/internal/codeintel/dependencies/internal/store/BUILD.bazel index d4bb6d8c729..ad7c544a33e 100644 --- a/internal/codeintel/dependencies/internal/store/BUILD.bazel +++ b/internal/codeintel/dependencies/internal/store/BUILD.bazel @@ -36,7 +36,6 @@ go_test( "//internal/database/dbtest", "//internal/observation", "@com_github_google_go_cmp//cmp", - "@com_github_keegancsmith_sqlf//:sqlf", "@com_github_sourcegraph_log//logtest", ], ) diff --git a/internal/comby/BUILD.bazel b/internal/comby/BUILD.bazel index d727fee70ad..c223389d668 100644 --- a/internal/comby/BUILD.bazel +++ b/internal/comby/BUILD.bazel @@ -30,6 +30,6 @@ go_test( deps = [ "//lib/errors", "@com_github_google_go_cmp//cmp", - "@com_github_hexops_autogold//:autogold", + "@com_github_hexops_autogold_v2//:autogold", ], ) diff --git a/internal/conf/BUILD.bazel b/internal/conf/BUILD.bazel index e06c0da5c68..a5e10f8104e 100644 --- a/internal/conf/BUILD.bazel +++ b/internal/conf/BUILD.bazel @@ -12,7 +12,6 @@ go_library( "init.go", "log_sinks.go", "parse.go", - "platform.go", "server.go", "service_watcher.go", "store.go", @@ -53,7 +52,6 @@ go_test( "computed_test.go", "diff_test.go", "mocks_test.go", - "platform_test.go", "validate_test.go", ], embed = [":conf"], diff --git a/internal/database/BUILD.bazel b/internal/database/BUILD.bazel index 73d7f9bfe50..9c64f111ee2 100644 --- a/internal/database/BUILD.bazel +++ b/internal/database/BUILD.bazel @@ -3,6 +3,7 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") go_library( name = "database", srcs = [ + "access_requests.go", "access_tokens.go", "authenticator.go", "authz.go", @@ -144,6 +145,7 @@ go_library( go_test( name = "database_test", srcs = [ + "access_requests_test.go", "access_tokens_test.go", "authenticator_test.go", "bitbucket_project_permissions_test.go", @@ -244,6 +246,8 @@ go_test( "@com_github_stretchr_testify//assert", "@com_github_stretchr_testify//require", "@com_github_tidwall_gjson//:gjson", + "@io_k8s_utils//pointer", + "@org_golang_x_exp//maps", "@org_golang_x_sync//errgroup", ], ) diff --git a/internal/database/dbconn/BUILD.bazel b/internal/database/dbconn/BUILD.bazel index 61358538636..be564b89157 100644 --- a/internal/database/dbconn/BUILD.bazel +++ b/internal/database/dbconn/BUILD.bazel @@ -6,6 +6,8 @@ go_library( "bulk_insertion.go", "config.go", "connect.go", + "connection_updater.go", + "connector.go", "dynamic_metadata.go", "hooks_combine.go", "hooks_metrics.go", @@ -16,6 +18,7 @@ go_library( importpath = "github.com/sourcegraph/sourcegraph/internal/database/dbconn", visibility = ["//:__subpackages__"], deps = [ + "//internal/database/dbconn/rds", "//internal/env", "//internal/lazyregexp", "//lib/errors", diff --git a/internal/database/dbconn/rds/BUILD.bazel b/internal/database/dbconn/rds/BUILD.bazel new file mode 100644 index 00000000000..8b17248051e --- /dev/null +++ b/internal/database/dbconn/rds/BUILD.bazel @@ -0,0 +1,26 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") + +go_library( + name = "rds", + srcs = ["rds.go"], + importpath = "github.com/sourcegraph/sourcegraph/internal/database/dbconn/rds", + visibility = ["//:__subpackages__"], + deps = [ + "//internal/syncx", + "//lib/errors", + "@com_github_aws_aws_sdk_go//aws/session", + "@com_github_aws_aws_sdk_go//service/rds/rdsutils", + "@com_github_jackc_pgx_v4//:pgx", + "@com_github_sourcegraph_log//:log", + ], +) + +go_test( + name = "rds_test", + srcs = ["rds_test.go"], + embed = [":rds"], + deps = [ + "@com_github_hexops_autogold_v2//:autogold", + "@com_github_stretchr_testify//require", + ], +) diff --git a/internal/database/fakedb/BUILD.bazel b/internal/database/fakedb/BUILD.bazel new file mode 100644 index 00000000000..6bfb18686e2 --- /dev/null +++ b/internal/database/fakedb/BUILD.bazel @@ -0,0 +1,18 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "fakedb", + srcs = [ + "fakedb.go", + "teams.go", + "users.go", + ], + importpath = "github.com/sourcegraph/sourcegraph/internal/database/fakedb", + visibility = ["//:__subpackages__"], + deps = [ + "//internal/actor", + "//internal/database", + "//internal/types", + "//lib/errors", + ], +) diff --git a/internal/database/migration/stitch/stitch_test.go b/internal/database/migration/stitch/stitch_test.go index c7621da56ec..69003e5e27b 100644 --- a/internal/database/migration/stitch/stitch_test.go +++ b/internal/database/migration/stitch/stitch_test.go @@ -34,7 +34,8 @@ func TestMain(m *testing.M) { // v3.38.0 -> privileged migrations introduced func TestStitchFrontendDefinitions(t *testing.T) { - if testing.Short() { + if testing.Short() || os.Getenv("BAZEL_TEST") == "1" { + t.Skip() return } t.Parallel() @@ -79,7 +80,8 @@ func TestStitchFrontendDefinitions(t *testing.T) { } func TestStitchCodeintelDefinitions(t *testing.T) { - if testing.Short() { + if testing.Short() || os.Getenv("BAZEL_TEST") == "1" { + t.Skip() return } t.Parallel() @@ -124,7 +126,8 @@ func TestStitchCodeintelDefinitions(t *testing.T) { } func TestStitchCodeinsightsDefinitions(t *testing.T) { - if testing.Short() { + if testing.Short() || os.Getenv("BAZEL_TEST") == "1" { + t.Skip() return } t.Parallel() @@ -169,7 +172,8 @@ func TestStitchCodeinsightsDefinitions(t *testing.T) { } func TestStitchAndApplyFrontendDefinitions(t *testing.T) { - if testing.Short() { + if testing.Short() || os.Getenv("BAZEL_TEST") == "1" { + t.Skip() return } t.Parallel() @@ -183,7 +187,8 @@ func TestStitchAndApplyFrontendDefinitions(t *testing.T) { } func TestStitchAndApplyCodeintelDefinitions(t *testing.T) { - if testing.Short() { + if testing.Short() || os.Getenv("BAZEL_TEST") == "1" { + t.Skip() return } t.Parallel() @@ -197,7 +202,8 @@ func TestStitchAndApplyCodeintelDefinitions(t *testing.T) { } func TestStitchAndApplyCodeinsightsDefinitions(t *testing.T) { - if testing.Short() { + if testing.Short() || os.Getenv("BAZEL_TEST") == "1" { + t.Skip() return } t.Parallel() diff --git a/internal/database/migration/store/BUILD.bazel b/internal/database/migration/store/BUILD.bazel index 1d7c3887985..4b3125d6741 100644 --- a/internal/database/migration/store/BUILD.bazel +++ b/internal/database/migration/store/BUILD.bazel @@ -43,7 +43,7 @@ go_test( "//internal/database/migration/shared", "//internal/observation", "@com_github_google_go_cmp//cmp", - "@com_github_hexops_autogold//:autogold", + "@com_github_hexops_autogold_v2//:autogold", "@com_github_keegancsmith_sqlf//:sqlf", "@com_github_sourcegraph_log//logtest", "@org_golang_x_sync//errgroup", diff --git a/internal/extsvc/azuredevops/BUILD.bazel b/internal/extsvc/azuredevops/BUILD.bazel index 540fcb37502..98c1de6cd8d 100644 --- a/internal/extsvc/azuredevops/BUILD.bazel +++ b/internal/extsvc/azuredevops/BUILD.bazel @@ -4,6 +4,7 @@ go_library( name = "azuredevops", srcs = [ "client.go", + "projects.go", "pull_requests.go", "repositories.go", "types.go", @@ -12,11 +13,14 @@ go_library( importpath = "github.com/sourcegraph/sourcegraph/internal/extsvc/azuredevops", visibility = ["//:__subpackages__"], deps = [ + "//internal/encryption", + "//internal/extsvc", "//internal/extsvc/auth", "//internal/httpcli", "//internal/ratelimit", "//lib/errors", "@com_github_goware_urlx//:urlx", + "@org_golang_x_oauth2//:oauth2", ], ) @@ -25,6 +29,7 @@ go_test( srcs = [ "client_test.go", "main_test.go", + "projects_test.go", "pull_requests_test.go", "repositories_test.go", "users_test.go", diff --git a/internal/fastwalk/BUILD.bazel b/internal/fastwalk/BUILD.bazel new file mode 100644 index 00000000000..aa8f4643d3b --- /dev/null +++ b/internal/fastwalk/BUILD.bazel @@ -0,0 +1,25 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") + +go_library( + name = "fastwalk", + srcs = [ + "fastwalk.go", + "fastwalk_darwin.go", + "fastwalk_dirent_fileno.go", + "fastwalk_dirent_ino.go", + "fastwalk_dirent_namlen_bsd.go", + "fastwalk_dirent_namlen_linux.go", + "fastwalk_portable.go", + "fastwalk_unix.go", + ], + cgo = True, + importpath = "github.com/sourcegraph/sourcegraph/internal/fastwalk", + visibility = ["//:__subpackages__"], + deps = ["//lib/errors"], +) + +go_test( + name = "fastwalk_test", + srcs = ["fastwalk_test.go"], + deps = [":fastwalk"], +) diff --git a/internal/gitserver/BUILD.bazel b/internal/gitserver/BUILD.bazel index 5ca6470352f..b9c9d38ecb4 100644 --- a/internal/gitserver/BUILD.bazel +++ b/internal/gitserver/BUILD.bazel @@ -3,6 +3,7 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") go_library( name = "gitserver", srcs = [ + "addrs.go", "client.go", "commands.go", "git_command.go", @@ -22,16 +23,17 @@ go_library( "//internal/authz", "//internal/conf", "//internal/extsvc/gitolite", - "//internal/featureflag", "//internal/fileutil", "//internal/gitserver/gitdomain", "//internal/gitserver/protocol", "//internal/gitserver/v1:gitserver", + "//internal/grpc", "//internal/grpc/defaults", "//internal/grpc/streamio", "//internal/honey", "//internal/httpcli", "//internal/lazyregexp", + "//internal/limiter", "//internal/metrics", "//internal/observation", "//internal/search/streaming/http", @@ -41,7 +43,6 @@ go_library( "@com_github_go_git_go_git_v5//plumbing/format/config", "@com_github_golang_groupcache//lru", "@com_github_grafana_regexp//:regexp", - "@com_github_neelance_parallel//:parallel", "@com_github_opentracing_contrib_go_stdlib//nethttp", "@com_github_opentracing_opentracing_go//ext", "@com_github_opentracing_opentracing_go//log", @@ -53,6 +54,7 @@ go_library( "@org_golang_google_grpc//:go_default_library", "@org_golang_google_grpc//codes", "@org_golang_google_grpc//status", + "@org_golang_x_exp//slices", "@org_golang_x_sync//errgroup", "@org_golang_x_sync//semaphore", ], @@ -61,8 +63,10 @@ go_library( go_test( name = "gitserver_test", srcs = [ + "addrs_test.go", "client_test.go", "commands_test.go", + "grpc_test.go", "internal_test.go", ], embed = [":gitserver"], @@ -72,6 +76,7 @@ go_test( "//internal/api", "//internal/authz", "//internal/conf", + "//internal/conf/conftypes", "//internal/database", "//internal/errcode", "//internal/gitserver/gitdomain", diff --git a/internal/gitserver/integration_tests/BUILD.bazel b/internal/gitserver/integration_tests/BUILD.bazel index 576aef56205..2021bc7d981 100644 --- a/internal/gitserver/integration_tests/BUILD.bazel +++ b/internal/gitserver/integration_tests/BUILD.bazel @@ -19,7 +19,6 @@ go_library( "//internal/httpcli", "//internal/observation", "@com_github_sourcegraph_log//:log", - "@org_golang_google_grpc//:go_default_library", "@org_golang_x_sync//semaphore", ], ) diff --git a/internal/gitserver/integration_tests/tree_test.go b/internal/gitserver/integration_tests/tree_test.go index a2a80e3193a..89f97baefd4 100644 --- a/internal/gitserver/integration_tests/tree_test.go +++ b/internal/gitserver/integration_tests/tree_test.go @@ -296,7 +296,7 @@ func TestRepository_FileSystem_gitSubmodules(t *testing.T) { const submodCommit = "94aa9078934ce2776ccbb589569eca5ef575f12e" gitCommands := []string{ - "git submodule add " + filepath.ToSlash(submodDir) + " submod", + "git -c protocol.file.allow=always submodule add " + filepath.ToSlash(submodDir) + " submod", "GIT_COMMITTER_NAME=a GIT_COMMITTER_EMAIL=a@a.com GIT_COMMITTER_DATE=2006-01-02T15:04:05Z git commit -m 'add submodule' --author='a ' --date 2006-01-02T15:04:05Z", } tests := map[string]struct { diff --git a/internal/gitserver/test_utils.go b/internal/gitserver/test_utils.go index a89dfc5c1e5..35d97ffc03e 100644 --- a/internal/gitserver/test_utils.go +++ b/internal/gitserver/test_utils.go @@ -89,7 +89,7 @@ func InitGitRepository(t *testing.T, cmds ...string) string { // setting git repo which is needed for successful run of git command against local file system ClientMocks.LocalGitCommandReposDir = remotes - cmds = append([]string{"git init"}, cmds...) + cmds = append([]string{"git init --initial-branch=master"}, cmds...) for _, cmd := range cmds { out, err := CreateGitCommand(dir, "bash", "-c", cmd).CombinedOutput() if err != nil { diff --git a/internal/gitserver/v1/BUILD.bazel b/internal/gitserver/v1/BUILD.bazel index d78f4ada76e..c550c561697 100644 --- a/internal/gitserver/v1/BUILD.bazel +++ b/internal/gitserver/v1/BUILD.bazel @@ -1,38 +1,38 @@ load("@rules_proto//proto:defs.bzl", "proto_library") load("@io_bazel_rules_go//go:def.bzl", "go_library") -load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library") load("@rules_buf//buf:defs.bzl", "buf_lint_test") proto_library( #keep name = "proto_proto", srcs = ["gitserver.proto"], + strip_import_prefix = "/internal", visibility = ["//:__subpackages__"], deps = ["@com_google_protobuf//:timestamp_proto"], ) -go_proto_library( - #keep - name = "v1_go_proto", - compilers = [ - "//:gen-go-grpc", - "@io_bazel_rules_go//proto:go_proto", - ], - importpath = "github.com/sourcegraph/sourcegraph/internal/gitserver/v1", - proto = ":proto_proto", - visibility = ["//:__subpackages__"], -) - go_library( #keep name = "gitserver", - embed = [":v1_go_proto"], + srcs = [ + "gitserver.pb.go", + "gitserver_grpc.pb.go", + ], importpath = "github.com/sourcegraph/sourcegraph/internal/gitserver/v1", visibility = ["//:__subpackages__"], + deps = [ + "@org_golang_google_grpc//:go_default_library", + "@org_golang_google_grpc//codes", + "@org_golang_google_grpc//status", + "@org_golang_google_protobuf//reflect/protoreflect", + "@org_golang_google_protobuf//runtime/protoimpl", + "@org_golang_google_protobuf//types/known/timestamppb", + ], ) buf_lint_test( - #keep + # keep name = "v1_proto_lint", + config = "//internal:buf.yaml", targets = [":proto_proto"], ) diff --git a/internal/gqlutil/BUILD.bazel b/internal/gqlutil/BUILD.bazel index e83d5d38a32..2d9803376b4 100644 --- a/internal/gqlutil/BUILD.bazel +++ b/internal/gqlutil/BUILD.bazel @@ -12,4 +12,5 @@ go_test( name = "gqlutil_test", srcs = ["datetime_test.go"], embed = [":gqlutil"], + deps = ["@com_github_stretchr_testify//require"], ) diff --git a/internal/grpc/BUILD.bazel b/internal/grpc/BUILD.bazel index 4dab02a198f..0b5be61b158 100644 --- a/internal/grpc/BUILD.bazel +++ b/internal/grpc/BUILD.bazel @@ -10,6 +10,7 @@ go_library( importpath = "github.com/sourcegraph/sourcegraph/internal/grpc", visibility = ["//:__subpackages__"], deps = [ + "//internal/featureflag", "@com_github_sourcegraph_log//:log", "@org_golang_google_grpc//:go_default_library", "@org_golang_google_grpc//codes", diff --git a/internal/grpc/defaults/BUILD.bazel b/internal/grpc/defaults/BUILD.bazel index 58ab4f84933..63e65b09239 100644 --- a/internal/grpc/defaults/BUILD.bazel +++ b/internal/grpc/defaults/BUILD.bazel @@ -16,5 +16,6 @@ go_library( "@io_opentelemetry_go_contrib_instrumentation_google_golang_org_grpc_otelgrpc//:otelgrpc", "@org_golang_google_grpc//:go_default_library", "@org_golang_google_grpc//credentials/insecure", + "@org_golang_google_grpc//reflection", ], ) diff --git a/internal/insights/BUILD.bazel b/internal/insights/BUILD.bazel index 250ae2da9d5..2b7187c9e86 100644 --- a/internal/insights/BUILD.bazel +++ b/internal/insights/BUILD.bazel @@ -25,7 +25,7 @@ go_test( "//internal/database", "//internal/database/dbtest", "@com_github_google_go_cmp//cmp", - "@com_github_hexops_autogold//:autogold", + "@com_github_hexops_autogold_v2//:autogold", "@com_github_hexops_valast//:valast", "@com_github_inconshreveable_log15//:log15", "@com_github_sourcegraph_log//logtest", diff --git a/internal/limiter/BUILD.bazel b/internal/limiter/BUILD.bazel index 8c871dad5c4..1190c376139 100644 --- a/internal/limiter/BUILD.bazel +++ b/internal/limiter/BUILD.bazel @@ -12,6 +12,9 @@ go_library( go_test( name = "limiter_test", - srcs = ["mutable_test.go"], + srcs = [ + "limiter_test.go", + "mutable_test.go", + ], embed = [":limiter"], ) diff --git a/internal/oobmigration/BUILD.bazel b/internal/oobmigration/BUILD.bazel index 9ea20e0b2e6..1072b7f9792 100644 --- a/internal/oobmigration/BUILD.bazel +++ b/internal/oobmigration/BUILD.bazel @@ -23,7 +23,6 @@ go_library( "//internal/database", "//internal/database/basestore", "//internal/database/dbutil", - "//internal/goroutine", "//internal/lazyregexp", "//internal/metrics", "//internal/observation", diff --git a/internal/oobmigration/migrations/batches/BUILD.bazel b/internal/oobmigration/migrations/batches/BUILD.bazel index 24c71f5f79e..9f1e8159ad4 100644 --- a/internal/oobmigration/migrations/batches/BUILD.bazel +++ b/internal/oobmigration/migrations/batches/BUILD.bazel @@ -35,8 +35,10 @@ go_test( "//internal/types", "//schema", "@com_github_google_go_cmp//cmp", + "@com_github_google_go_cmp//cmp/cmpopts", "@com_github_keegancsmith_sqlf//:sqlf", "@com_github_sourcegraph_log//logtest", "@com_github_stretchr_testify//assert", + "@com_github_stretchr_testify//require", ], ) diff --git a/internal/own/BUILD.bazel b/internal/own/BUILD.bazel new file mode 100644 index 00000000000..4031ebb1d71 --- /dev/null +++ b/internal/own/BUILD.bazel @@ -0,0 +1,36 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") + +go_library( + name = "own", + srcs = ["service.go"], + importpath = "github.com/sourcegraph/sourcegraph/internal/own", + visibility = ["//:__subpackages__"], + deps = [ + "//internal/api", + "//internal/authz", + "//internal/database", + "//internal/errcode", + "//internal/gitserver", + "//internal/own/codeowners", + "//internal/own/codeowners/v1:codeowners", + "//internal/types", + ], +) + +go_test( + name = "own_test", + srcs = ["service_test.go"], + deps = [ + ":own", + "//internal/api", + "//internal/authz", + "//internal/database", + "//internal/gitserver", + "//internal/own/codeowners", + "//internal/own/codeowners/v1:codeowners", + "//internal/types", + "//lib/errors", + "@com_github_stretchr_testify//assert", + "@com_github_stretchr_testify//require", + ], +) diff --git a/internal/own/codeowners/BUILD.bazel b/internal/own/codeowners/BUILD.bazel index c24d558fc66..d288235e9b1 100644 --- a/internal/own/codeowners/BUILD.bazel +++ b/internal/own/codeowners/BUILD.bazel @@ -3,8 +3,11 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") go_library( name = "codeowners", srcs = [ + "file.go", + "find_owners.go", "owner_types.go", "parse.go", + "repr.go", ], importpath = "github.com/sourcegraph/sourcegraph/internal/own/codeowners", visibility = ["//:__subpackages__"], @@ -13,12 +16,16 @@ go_library( "//internal/own/codeowners/v1:codeowners", "//internal/types", "//lib/errors", + "@com_github_becheran_wildmatch_go//:wildmatch-go", ], ) go_test( name = "codeowners_test", - srcs = ["parse_test.go"], + srcs = [ + "find_owners_test.go", + "parse_test.go", + ], deps = [ ":codeowners", "//internal/own/codeowners/v1:codeowners", diff --git a/internal/own/codeowners/v1/BUILD.bazel b/internal/own/codeowners/v1/BUILD.bazel index fff5f728021..057ba9184fd 100644 --- a/internal/own/codeowners/v1/BUILD.bazel +++ b/internal/own/codeowners/v1/BUILD.bazel @@ -1,48 +1,29 @@ load("@rules_buf//buf:defs.bzl", "buf_lint_test") load("@rules_proto//proto:defs.bzl", "proto_library") -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") -load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library") +load("@io_bazel_rules_go//go:def.bzl", "go_library") exports_files(["buf.gen.yaml"]) proto_library( name = "v1_proto", srcs = ["codeowners.proto"], - visibility = ["//:__subpackages__"], -) - -go_proto_library( - name = "v1_go_proto", - importpath = "github.com/sourcegraph/sourcegraph/internal/own/codeowners/v1", - proto = ":v1_proto", + strip_import_prefix = "/internal", visibility = ["//:__subpackages__"], ) go_library( name = "codeowners", - srcs = [ - "find_owners.go", - "repr.go", - ], - embed = [":v1_go_proto"], + srcs = ["codeowners.pb.go"], importpath = "github.com/sourcegraph/sourcegraph/internal/own/codeowners/v1", visibility = ["//:__subpackages__"], deps = [ - "//lib/errors", - "@com_github_grafana_regexp//:regexp", - ], -) - -go_test( - name = "codeowners_test", - srcs = ["find_owners_test.go"], - deps = [ - ":codeowners", - "@com_github_stretchr_testify//assert", + "@org_golang_google_protobuf//reflect/protoreflect", + "@org_golang_google_protobuf//runtime/protoimpl", ], ) buf_lint_test( name = "v1_proto_lint", + config = "//internal:buf.yaml", targets = [":v1_proto"], ) diff --git a/internal/repos/BUILD.bazel b/internal/repos/BUILD.bazel index 7f0a130677a..5a0dd90a5ac 100644 --- a/internal/repos/BUILD.bazel +++ b/internal/repos/BUILD.bazel @@ -9,6 +9,7 @@ go_library( "bitbucketserver.go", "clone_url.go", "conf.go", + "discoverable_sources.go", "doc.go", "exclude.go", "gerrit.go", @@ -78,8 +79,8 @@ go_library( "//internal/httpcli", "//internal/jsonc", "//internal/lazyregexp", + "//internal/limiter", "//internal/metrics", - "//internal/mutablelimiter", "//internal/observation", "//internal/ratelimit", "//internal/repoupdater/protocol", @@ -169,7 +170,7 @@ go_test( "//internal/gitserver/protocol", "//internal/httpcli", "//internal/httptestutil", - "//internal/mutablelimiter", + "//internal/limiter", "//internal/observation", "//internal/ratelimit", "//internal/rcache", diff --git a/internal/repoupdater/BUILD.bazel b/internal/repoupdater/BUILD.bazel index 117c6cc17d1..f56bd097c54 100644 --- a/internal/repoupdater/BUILD.bazel +++ b/internal/repoupdater/BUILD.bazel @@ -10,13 +10,20 @@ go_library( visibility = ["//:__subpackages__"], deps = [ "//internal/api", - "//internal/env", + "//internal/conf/deploy", + "//internal/grpc", + "//internal/grpc/defaults", "//internal/httpcli", "//internal/repoupdater/protocol", + "//internal/repoupdater/v1:repoupdater", + "//internal/syncx", "//internal/trace/ot", "//lib/errors", "@com_github_opentracing_contrib_go_stdlib//nethttp", "@com_github_opentracing_opentracing_go//ext", + "@org_golang_google_grpc//:go_default_library", + "@org_golang_google_grpc//codes", + "@org_golang_google_grpc//status", ], ) diff --git a/internal/repoupdater/protocol/BUILD.bazel b/internal/repoupdater/protocol/BUILD.bazel index 158e8358b75..48a784365af 100644 --- a/internal/repoupdater/protocol/BUILD.bazel +++ b/internal/repoupdater/protocol/BUILD.bazel @@ -15,6 +15,8 @@ go_library( "//internal/extsvc/bitbucketserver", "//internal/extsvc/github", "//internal/extsvc/gitlab", + "//internal/repoupdater/v1:repoupdater", "//internal/types", + "@org_golang_google_protobuf//types/known/timestamppb", ], ) diff --git a/internal/repoupdater/v1/BUILD.bazel b/internal/repoupdater/v1/BUILD.bazel new file mode 100644 index 00000000000..7b01ce54a1a --- /dev/null +++ b/internal/repoupdater/v1/BUILD.bazel @@ -0,0 +1,19 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "repoupdater", + srcs = [ + "repoupdater.pb.go", + "repoupdater_grpc.pb.go", + ], + importpath = "github.com/sourcegraph/sourcegraph/internal/repoupdater/v1", + visibility = ["//:__subpackages__"], + deps = [ + "@org_golang_google_grpc//:go_default_library", + "@org_golang_google_grpc//codes", + "@org_golang_google_grpc//status", + "@org_golang_google_protobuf//reflect/protoreflect", + "@org_golang_google_protobuf//runtime/protoimpl", + "@org_golang_google_protobuf//types/known/timestamppb", + ], +) diff --git a/internal/search/backend/BUILD.bazel b/internal/search/backend/BUILD.bazel index ed489dbc078..474b15e7fb6 100644 --- a/internal/search/backend/BUILD.bazel +++ b/internal/search/backend/BUILD.bazel @@ -47,6 +47,7 @@ go_library( go_test( name = "backend_test", srcs = [ + "aggregate_test.go", "cached_test.go", "config_test.go", "horizontal_test.go", @@ -56,6 +57,7 @@ go_test( embed = [":backend"], deps = [ "//internal/api", + "//internal/conf", "//internal/types", "//lib/errors", "//schema", diff --git a/internal/search/codeownership/BUILD.bazel b/internal/search/codeownership/BUILD.bazel index bcd2dd407d2..d8bbd1dee51 100644 --- a/internal/search/codeownership/BUILD.bazel +++ b/internal/search/codeownership/BUILD.bazel @@ -10,10 +10,11 @@ go_library( importpath = "github.com/sourcegraph/sourcegraph/internal/search/codeownership", visibility = ["//:__subpackages__"], deps = [ - "//cmd/frontend/backend", "//internal/api", "//internal/database", "//internal/gitserver", + "//internal/own", + "//internal/own/codeowners", "//internal/own/codeowners/v1:codeowners", "//internal/search", "//internal/search/job", @@ -40,7 +41,7 @@ go_test( "//internal/own/codeowners", "//internal/search/result", "//internal/types", - "@com_github_hexops_autogold//:autogold", + "@com_github_hexops_autogold_v2//:autogold", "@com_github_stretchr_testify//assert", ], ) diff --git a/internal/search/commit/BUILD.bazel b/internal/search/commit/BUILD.bazel index 577d730f979..3b0bdde0c5f 100644 --- a/internal/search/commit/BUILD.bazel +++ b/internal/search/commit/BUILD.bazel @@ -19,9 +19,9 @@ go_library( "//internal/search/streaming", "//internal/trace", "//internal/types", - "//lib/group", "@com_github_grafana_regexp//:regexp", "@com_github_opentracing_opentracing_go//log", + "@com_github_sourcegraph_conc//pool", ], ) diff --git a/internal/search/job/jobutil/BUILD.bazel b/internal/search/job/jobutil/BUILD.bazel index 73d3dc1ade9..3aece73fb2e 100644 --- a/internal/search/job/jobutil/BUILD.bazel +++ b/internal/search/job/jobutil/BUILD.bazel @@ -48,10 +48,10 @@ go_library( "//internal/trace", "//internal/usagestats", "//lib/errors", - "//lib/group", "//schema", "@com_github_grafana_regexp//:regexp", "@com_github_opentracing_opentracing_go//log", + "@com_github_sourcegraph_conc//pool", "@com_github_sourcegraph_log//:log", "@com_github_sourcegraph_zoekt//query", "@io_opentelemetry_go_otel//attribute", @@ -102,7 +102,7 @@ go_test( "@com_github_google_go_cmp//cmp", "@com_github_google_go_cmp//cmp/cmpopts", "@com_github_grafana_regexp//:regexp", - "@com_github_hexops_autogold//:autogold", + "@com_github_hexops_autogold_v2//:autogold", "@com_github_sourcegraph_log//:log", "@com_github_sourcegraph_log//logtest", "@com_github_sourcegraph_zoekt//query", diff --git a/internal/search/job/printer/BUILD.bazel b/internal/search/job/printer/BUILD.bazel index b16df0901bd..700e3dcad7e 100644 --- a/internal/search/job/printer/BUILD.bazel +++ b/internal/search/job/printer/BUILD.bazel @@ -28,7 +28,7 @@ go_test( embed = [":printer"], deps = [ "//internal/search/job", - "@com_github_hexops_autogold//:autogold", + "@com_github_hexops_autogold_v2//:autogold", "@com_github_opentracing_opentracing_go//log", ], ) diff --git a/internal/search/keyword/BUILD.bazel b/internal/search/keyword/BUILD.bazel index eefa8327f35..8585531d44d 100644 --- a/internal/search/keyword/BUILD.bazel +++ b/internal/search/keyword/BUILD.bazel @@ -3,7 +3,6 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") go_library( name = "keyword", srcs = [ - "file_score.go", "keyword_search_job.go", "keywords.go", "match_groups.go", @@ -36,6 +35,6 @@ go_test( deps = [ "//internal/search/query", "//internal/search/result", - "@com_github_hexops_autogold//:autogold", + "@com_github_hexops_autogold_v2//:autogold", ], ) diff --git a/internal/search/query/BUILD.bazel b/internal/search/query/BUILD.bazel index dd260e1d5a8..7d7c5a09724 100644 --- a/internal/search/query/BUILD.bazel +++ b/internal/search/query/BUILD.bazel @@ -56,7 +56,7 @@ go_test( "//lib/errors", "@com_github_google_go_cmp//cmp", "@com_github_grafana_regexp//syntax", - "@com_github_hexops_autogold//:autogold", + "@com_github_hexops_autogold_v2//:autogold", "@com_github_stretchr_testify//require", ], ) diff --git a/internal/search/repos/BUILD.bazel b/internal/search/repos/BUILD.bazel index 9a9808a9688..9490d90b54f 100644 --- a/internal/search/repos/BUILD.bazel +++ b/internal/search/repos/BUILD.bazel @@ -29,11 +29,11 @@ go_library( "//internal/trace", "//internal/types", "//lib/errors", - "//lib/group", "//lib/iterator", "@com_github_grafana_regexp//:regexp", "@com_github_grafana_regexp//syntax", "@com_github_opentracing_opentracing_go//log", + "@com_github_sourcegraph_conc//pool", "@com_github_sourcegraph_log//:log", "@com_github_sourcegraph_zoekt//:zoekt", "@com_github_sourcegraph_zoekt//query", diff --git a/internal/search/result/BUILD.bazel b/internal/search/result/BUILD.bazel index 1ab65f7dcb9..02ba67ab834 100644 --- a/internal/search/result/BUILD.bazel +++ b/internal/search/result/BUILD.bazel @@ -44,6 +44,7 @@ go_test( "deduper_test.go", "file_test.go", "match_test.go", + "merger_test.go", "range_test.go", "symbol_test.go", ], @@ -54,7 +55,7 @@ go_test( "//internal/gitserver/gitdomain", "//internal/search/filter", "//internal/types", - "@com_github_hexops_autogold//:autogold", + "@com_github_hexops_autogold_v2//:autogold", "@com_github_stretchr_testify//require", ], ) diff --git a/internal/search/searcher/BUILD.bazel b/internal/search/searcher/BUILD.bazel index 192405ea7c8..1d0bd0680fe 100644 --- a/internal/search/searcher/BUILD.bazel +++ b/internal/search/searcher/BUILD.bazel @@ -18,12 +18,11 @@ go_library( "//internal/conf", "//internal/endpoint", "//internal/errcode", - "//internal/featureflag", "//internal/gitserver", - "//internal/goroutine", + "//internal/grpc", "//internal/grpc/defaults", "//internal/httpcli", - "//internal/mutablelimiter", + "//internal/limiter", "//internal/search", "//internal/search/job", "//internal/search/result", @@ -35,13 +34,14 @@ go_library( "//internal/types", "//lib/errors", "@com_github_grafana_regexp//:regexp", - "@com_github_neelance_parallel//:parallel", "@com_github_opentracing_contrib_go_stdlib//nethttp", "@com_github_opentracing_opentracing_go//ext", "@com_github_opentracing_opentracing_go//log", + "@com_github_sourcegraph_conc//pool", "@com_github_sourcegraph_log//:log", "@io_opentelemetry_go_otel//attribute", - "@org_golang_google_grpc//:go_default_library", + "@org_golang_google_grpc//codes", + "@org_golang_google_grpc//status", "@org_golang_x_sync//errgroup", ], ) diff --git a/internal/search/smartsearch/BUILD.bazel b/internal/search/smartsearch/BUILD.bazel index 8a1c9c220c3..3a9e5d2bd2d 100644 --- a/internal/search/smartsearch/BUILD.bazel +++ b/internal/search/smartsearch/BUILD.bazel @@ -43,7 +43,7 @@ go_test( "//internal/search/query", "//internal/search/result", "//internal/search/streaming", - "@com_github_hexops_autogold//:autogold", + "@com_github_hexops_autogold_v2//:autogold", "@com_github_stretchr_testify//require", ], ) diff --git a/internal/search/streaming/BUILD.bazel b/internal/search/streaming/BUILD.bazel index f36af7e1637..3f181e56cba 100644 --- a/internal/search/streaming/BUILD.bazel +++ b/internal/search/streaming/BUILD.bazel @@ -32,8 +32,8 @@ go_test( deps = [ "//internal/search/result", "//internal/types", - "//lib/group", "@com_github_google_go_cmp//cmp", + "@com_github_sourcegraph_conc//pool", "@com_github_stretchr_testify//require", "@org_uber_go_atomic//:atomic", ], diff --git a/internal/search/zoekt/BUILD.bazel b/internal/search/zoekt/BUILD.bazel index 973d184aa65..f72cee69e6b 100644 --- a/internal/search/zoekt/BUILD.bazel +++ b/internal/search/zoekt/BUILD.bazel @@ -71,7 +71,7 @@ go_test( "@com_github_google_go_cmp//cmp", "@com_github_google_go_cmp//cmp/cmpopts", "@com_github_grafana_regexp//:regexp", - "@com_github_hexops_autogold//:autogold", + "@com_github_hexops_autogold_v2//:autogold", "@com_github_roaringbitmap_roaring//:roaring", "@com_github_sourcegraph_log//logtest", "@com_github_sourcegraph_zoekt//:zoekt", diff --git a/internal/searcher/v1/BUILD.bazel b/internal/searcher/v1/BUILD.bazel index d7a197593ca..431dfa28d71 100644 --- a/internal/searcher/v1/BUILD.bazel +++ b/internal/searcher/v1/BUILD.bazel @@ -1,36 +1,37 @@ load("@rules_buf//buf:defs.bzl", "buf_lint_test") load("@rules_proto//proto:defs.bzl", "proto_library") load("@io_bazel_rules_go//go:def.bzl", "go_library") -load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library") exports_files(["buf.gen.yaml"]) proto_library( name = "v1_proto", srcs = ["searcher.proto"], + strip_import_prefix = "/internal", visibility = ["//visibility:public"], deps = ["@com_google_protobuf//:duration_proto"], ) -go_proto_library( - name = "v1_go_proto", - compilers = [ - "//:gen-go-grpc", - "@io_bazel_rules_go//proto:go_proto", - ], - importpath = "github.com/sourcegraph/sourcegraph/internal/searcher/v1", - proto = ":v1_proto", - visibility = ["//:__subpackages__"], -) - go_library( name = "searcher", - embed = [":v1_go_proto"], + srcs = [ + "searcher.pb.go", + "searcher_grpc.pb.go", + ], importpath = "github.com/sourcegraph/sourcegraph/internal/searcher/v1", visibility = ["//:__subpackages__"], + deps = [ + "@org_golang_google_grpc//:go_default_library", + "@org_golang_google_grpc//codes", + "@org_golang_google_grpc//status", + "@org_golang_google_protobuf//reflect/protoreflect", + "@org_golang_google_protobuf//runtime/protoimpl", + "@org_golang_google_protobuf//types/known/durationpb", + ], ) buf_lint_test( name = "v1_proto_lint", + config = "//internal:buf.yaml", targets = [":v1_proto"], ) diff --git a/internal/service/servegit/BUILD.bazel b/internal/service/servegit/BUILD.bazel index 00290242c70..b2c5f6772dc 100644 --- a/internal/service/servegit/BUILD.bazel +++ b/internal/service/servegit/BUILD.bazel @@ -16,6 +16,7 @@ go_library( "//internal/debugserver", "//internal/env", "//internal/extsvc", + "//internal/fastwalk", "//internal/observation", "//internal/service", "//internal/types", @@ -23,6 +24,7 @@ go_library( "//lib/gitservice", "//schema", "@com_github_sourcegraph_log//:log", + "@org_golang_x_exp//slices", ], ) diff --git a/internal/service/svcmain/BUILD.bazel b/internal/service/svcmain/BUILD.bazel index e7cc5f4f931..c253843ffe7 100644 --- a/internal/service/svcmain/BUILD.bazel +++ b/internal/service/svcmain/BUILD.bazel @@ -15,6 +15,7 @@ go_library( "//internal/profiler", "//internal/service", "//internal/singleprogram", + "//internal/syncx", "//internal/tracer", "//internal/version", "@com_github_getsentry_sentry_go//:sentry-go", diff --git a/internal/symbols/BUILD.bazel b/internal/symbols/BUILD.bazel index 4ba27625adb..0b40753bc47 100644 --- a/internal/symbols/BUILD.bazel +++ b/internal/symbols/BUILD.bazel @@ -11,9 +11,10 @@ go_library( "//internal/authz", "//internal/conf/conftypes", "//internal/endpoint", - "//internal/featureflag", + "//internal/grpc", "//internal/grpc/defaults", "//internal/httpcli", + "//internal/limiter", "//internal/resetonce", "//internal/search", "//internal/search/result", @@ -22,12 +23,13 @@ go_library( "//internal/types", "//lib/errors", "@com_github_gobwas_glob//:glob", - "@com_github_neelance_parallel//:parallel", "@com_github_opentracing_contrib_go_stdlib//nethttp", "@com_github_opentracing_opentracing_go//ext", "@com_github_opentracing_opentracing_go//log", "@com_github_sourcegraph_go_ctags//:go-ctags", "@org_golang_google_grpc//:go_default_library", + "@org_golang_google_grpc//codes", + "@org_golang_google_grpc//status", ], ) @@ -39,8 +41,14 @@ go_test( "//internal/actor", "//internal/authz", "//internal/endpoint", + "//internal/grpc", + "//internal/grpc/defaults", "//internal/search", "//internal/search/result", + "//internal/symbols/v1:symbols", "//internal/types", + "//lib/errors", + "@com_github_sourcegraph_log//:log", + "@com_github_sourcegraph_log//logtest", ], ) diff --git a/internal/symbols/v1/BUILD.bazel b/internal/symbols/v1/BUILD.bazel index 1b59f64f243..f2a2e3aa6d5 100644 --- a/internal/symbols/v1/BUILD.bazel +++ b/internal/symbols/v1/BUILD.bazel @@ -1,35 +1,25 @@ load("@rules_buf//buf:defs.bzl", "buf_lint_test") load("@rules_proto//proto:defs.bzl", "proto_library") load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") -load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library") exports_files(["buf.gen.yaml"]) proto_library( name = "v1_proto", srcs = ["symbols.proto"], + strip_import_prefix = "/internal", visibility = ["//visibility:public"], deps = ["@com_google_protobuf//:duration_proto"], ) -go_proto_library( - name = "v1_go_proto", - compilers = [ - "//:gen-go-grpc", - "@io_bazel_rules_go//proto:go_proto", - ], - importpath = "github.com/sourcegraph/sourcegraph/internal/symbols/v1", - proto = ":v1_proto", - visibility = ["//:__subpackages__"], -) - go_library( name = "symbols", srcs = [ "conversion.go", "doc.go", + "symbols.pb.go", + "symbols_grpc.pb.go", ], - embed = [":v1_go_proto"], importpath = "github.com/sourcegraph/sourcegraph/internal/symbols/v1", visibility = ["//:__subpackages__"], deps = [ @@ -37,6 +27,11 @@ go_library( "//internal/search", "//internal/search/result", "//internal/types", + "@org_golang_google_grpc//:go_default_library", + "@org_golang_google_grpc//codes", + "@org_golang_google_grpc//status", + "@org_golang_google_protobuf//reflect/protoreflect", + "@org_golang_google_protobuf//runtime/protoimpl", "@org_golang_google_protobuf//types/known/durationpb", ], ) @@ -56,5 +51,6 @@ go_test( buf_lint_test( name = "v1_proto_lint", + config = "//internal:buf.yaml", targets = [":v1_proto"], ) diff --git a/internal/syncx/oncefunc_test.go b/internal/syncx/oncefunc_test.go index 4cdfee0f435..05e4f822dfd 100644 --- a/internal/syncx/oncefunc_test.go +++ b/internal/syncx/oncefunc_test.go @@ -127,8 +127,9 @@ func TestOnceFuncPanicTraceback(t *testing.T) { t.Fatalf("want panic %v, got %v", "x", p) } stack := debug.Stack() - want := "syncx_test.onceFuncPanic" - if !bytes.Contains(stack, []byte(want)) { + // Add second case for bazel binary names + want := []string{"syncx_test.onceFuncPanic", "syncx_test_test.onceFuncPanic"} + if !bytes.Contains(stack, []byte(want[0])) && !bytes.Contains(stack, []byte(want[1])) { t.Fatalf("want stack containing %v, got:\n%s", want, string(stack)) } }() diff --git a/internal/tracer/BUILD.bazel b/internal/tracer/BUILD.bazel index 4697fa34018..b0616ff7871 100644 --- a/internal/tracer/BUILD.bazel +++ b/internal/tracer/BUILD.bazel @@ -4,10 +4,10 @@ go_library( name = "tracer", srcs = [ "doc.go", + "logged_ot.go", + "logged_otel.go", "otel.go", - "should_trace.go", - "switchable_ot.go", - "switchable_otel.go", + "otel_should_trace.go", "tracer.go", "watch.go", ], @@ -32,6 +32,7 @@ go_library( "@io_opentelemetry_go_otel_bridge_opentracing//:opentracing", "@io_opentelemetry_go_otel_sdk//resource", "@io_opentelemetry_go_otel_sdk//trace", + "@io_opentelemetry_go_otel_sdk//trace/tracetest", "@io_opentelemetry_go_otel_trace//:trace", "@org_uber_go_automaxprocs//maxprocs", ], @@ -43,10 +44,12 @@ go_test( embed = [":tracer"], deps = [ "//internal/conf/conftypes", + "//internal/trace/policy", "//schema", - "@com_github_opentracing_opentracing_go//:opentracing-go", + "@com_github_sourcegraph_log//:log", "@com_github_sourcegraph_log//logtest", "@com_github_stretchr_testify//assert", - "@io_opentelemetry_go_otel_trace//:trace", + "@io_opentelemetry_go_otel_sdk//trace", + "@io_opentelemetry_go_otel_sdk//trace/tracetest", ], ) diff --git a/internal/txemail/BUILD.bazel b/internal/txemail/BUILD.bazel index 463fce7d1e1..b1083b877c9 100644 --- a/internal/txemail/BUILD.bazel +++ b/internal/txemail/BUILD.bazel @@ -34,7 +34,7 @@ go_test( "//internal/txemail/txtypes", "//schema", "@com_github_google_go_cmp//cmp", - "@com_github_hexops_autogold//:autogold", + "@com_github_hexops_autogold_v2//:autogold", "@com_github_jordan_wright_email//:email", "@com_github_stretchr_testify//require", ], diff --git a/internal/types/BUILD.bazel b/internal/types/BUILD.bazel index 078c1e6daa4..095cecab747 100644 --- a/internal/types/BUILD.bazel +++ b/internal/types/BUILD.bazel @@ -24,6 +24,7 @@ go_library( "//internal/executor", "//internal/extsvc", "//internal/jsonc", + "//internal/own/codeowners/v1:codeowners", "//lib/errors", "//schema", "@com_github_google_uuid//:uuid", diff --git a/internal/wrexec/cmd_test.go b/internal/wrexec/cmd_test.go index 28b36b5fac9..fc724ea44a1 100644 --- a/internal/wrexec/cmd_test.go +++ b/internal/wrexec/cmd_test.go @@ -18,8 +18,8 @@ import ( func TestCommand(t *testing.T) { logger := logtest.Scoped(t) - name := "md5sum" - args := []string{"-b"} + name := "echo" + args := []string{"foo"} got := wrexec.CommandContext(context.Background(), logger, name, args...).Cmd want := osexec.Command(name, args...) @@ -41,8 +41,8 @@ func TestCommand(t *testing.T) { func TestWrap(t *testing.T) { logger := logtest.Scoped(t) - name := "md5sum" - args := []string{"-b"} + name := "echo" + args := []string{"foo"} want := osexec.Command(name, args...) got := wrexec.Wrap(context.Background(), logger, want).Cmd @@ -64,7 +64,7 @@ func TestWrap(t *testing.T) { func TestCombinedOutput(t *testing.T) { logger := logtest.Scoped(t) f := createTmpFile(t, "foobar") - tc := createTestCommand(context.Background(), logger, "md5sum", "-b", f.Name()) + tc := createTestCommand(context.Background(), logger, "cat", f.Name()) want, wantErr := tc.oscmd.CombinedOutput() got, gotErr := tc.cmd.CombinedOutput() @@ -92,7 +92,7 @@ func TestCombinedOutput(t *testing.T) { func TestEnviron(t *testing.T) { logger := logtest.Scoped(t) - tc := createTestCommand(context.Background(), logger, "md5sum", "-b", "something") + tc := createTestCommand(context.Background(), logger, "echo", "foobar") want := tc.oscmd.Environ() got := tc.cmd.Environ() @@ -118,7 +118,7 @@ func TestEnviron(t *testing.T) { func TestOutput(t *testing.T) { logger := logtest.Scoped(t) f := createTmpFile(t, "foobar") - tc := createTestCommand(context.Background(), logger, "md5sum", "-b", f.Name()) + tc := createTestCommand(context.Background(), logger, "cat", f.Name()) want, wantErr := tc.oscmd.Output() got, gotErr := tc.cmd.Output() @@ -147,7 +147,7 @@ func TestOutput(t *testing.T) { func TestRun(t *testing.T) { logger := logtest.Scoped(t) f := createTmpFile(t, "foobar") - tc := createTestCommand(context.Background(), logger, "md5sum", "-b", f.Name()) + tc := createTestCommand(context.Background(), logger, "cat", f.Name()) want := tc.oscmd.Run() got := tc.cmd.Run() @@ -173,7 +173,7 @@ func TestRun(t *testing.T) { func TestStart(t *testing.T) { logger := logtest.Scoped(t) f := createTmpFile(t, "foobar") - tc := createTestCommand(context.Background(), logger, "md5sum", "-b", f.Name()) + tc := createTestCommand(context.Background(), logger, "cat", f.Name()) want := tc.oscmd.Start() got := tc.cmd.Start() @@ -199,7 +199,7 @@ func TestStart(t *testing.T) { func TestStdoutPipe(t *testing.T) { logger := logtest.Scoped(t) f := createTmpFile(t, "foobar") - tc := createTestCommand(context.Background(), logger, "md5sum", "-b", f.Name()) + tc := createTestCommand(context.Background(), logger, "cat", f.Name()) wStdout, err := tc.oscmd.StdoutPipe() if err != nil { @@ -264,7 +264,7 @@ func TestStdoutPipe(t *testing.T) { func TestStderrPipe(t *testing.T) { logger := logtest.Scoped(t) - tc := createTestCommand(context.Background(), logger, "md5sum", "-b", "not-existing") + tc := createTestCommand(context.Background(), logger, "cat", "non-existing") wStderr, err := tc.oscmd.StderrPipe() if err != nil { @@ -329,7 +329,7 @@ func TestStderrPipe(t *testing.T) { func TestStdinPipe(t *testing.T) { logger := logtest.Scoped(t) data := "foobar" - tc := createTestCommand(context.Background(), logger, "md5sum", "-b") + tc := createTestCommand(context.Background(), logger, "cat") wStdin, err := tc.oscmd.StdinPipe() if err != nil { @@ -411,8 +411,8 @@ func TestStdinPipe(t *testing.T) { func TestString(t *testing.T) { ctx := context.Background() logger := logtest.Scoped(t) - oscmd := osexec.CommandContext(ctx, "md5sum", "-h") - cmd := wrexec.CommandContext(ctx, logger, "md5sum", "-h") + oscmd := osexec.CommandContext(ctx, "echo", "foobar") + cmd := wrexec.CommandContext(ctx, logger, "echo", "foobar") cmd1 := wrexec.Wrap(ctx, logger, oscmd) want := oscmd.String() @@ -428,13 +428,13 @@ func TestString(t *testing.T) { } func TestHooks(t *testing.T) { - name := "md5sum" + name := "cat" logger := logtest.Scoped(t) ctx := context.Background() t.Run("all hooks are called", func(t *testing.T) { f := createTmpFile(t, "foobar") - args := []string{"-b", f.Name()} + args := []string{f.Name()} cmd := wrexec.CommandContext(ctx, logger, name, args...) var a1, a2 int var b1, b2 int @@ -472,7 +472,7 @@ func TestHooks(t *testing.T) { t.Run("before hooks can interrupt the command", func(t *testing.T) { f := createTmpFile(t, "foobar") - args := []string{"-b", f.Name()} + args := []string{f.Name()} cmd := wrexec.CommandContext(ctx, logger, name, args...) var a, b1, b2 int wantErr := errors.New("foobar") @@ -514,13 +514,13 @@ func TestHooks(t *testing.T) { t.Run("before hooks can update the os.exec.Cmd", func(t *testing.T) { f := createTmpFile(t, "foobar") - oscmd := osexec.Command("md5sum", "-b", f.Name()) - cmd := wrexec.CommandContext(ctx, logger, "md5sum", "--help") + oscmd := osexec.Command("cat", f.Name()) + cmd := wrexec.CommandContext(ctx, logger, "cat", "wrong") cmd.SetBeforeHooks(func(ctx context.Context, _ log.Logger, c *osexec.Cmd) error { // .Args[0] is going to be ignored if and only if .Path is present. // And the osexec.Command always set it obviously ... // It's really easy to miss it and to end up wondering why an argument is missing. - c.Args = []string{c.Path, "-b", f.Name()} + c.Args = []string{c.Path, f.Name()} return nil }) @@ -545,7 +545,7 @@ func TestHooks(t *testing.T) { //nolint:staticcheck ctx := context.WithValue(context.Background(), "my-key", 1) f := createTmpFile(t, "foobar") - cmd := wrexec.CommandContext(ctx, logger, "md5sum", "-b", f.Name()) + cmd := wrexec.CommandContext(ctx, logger, "cat", f.Name()) cmd.SetBeforeHooks(func(ctx context.Context, _ log.Logger, _ *osexec.Cmd) error { want, got := 1, ctx.Value("my-key") if want != got { diff --git a/internal/wrexec/recording_cmd_test.go b/internal/wrexec/recording_cmd_test.go index 5130c706cab..be367b6b146 100644 --- a/internal/wrexec/recording_cmd_test.go +++ b/internal/wrexec/recording_cmd_test.go @@ -99,7 +99,7 @@ func TestRecordingCmd(t *testing.T) { ctx := context.Background() t.Run("with combinedOutput", func(t *testing.T) { f := createTmpFile(t, "foobar") - cmd := osexec.Command("md5sum", "-b", f.Name()) + cmd := osexec.Command("cat", f.Name()) rcmd := wrexec.RecordingWrap(ctx, logtest.Scoped(t), recordAlways, store, cmd) _, err := rcmd.CombinedOutput() if err != nil { @@ -113,7 +113,7 @@ func TestRecordingCmd(t *testing.T) { }) t.Run("with Run", func(t *testing.T) { f := createTmpFile(t, "foobar") - cmd := osexec.Command("md5sum", "-b", f.Name()) + cmd := osexec.Command("cat", f.Name()) rcmd := wrexec.RecordingWrap(ctx, logtest.Scoped(t), recordAlways, store, cmd) rcmd.Run() @@ -124,7 +124,7 @@ func TestRecordingCmd(t *testing.T) { }) t.Run("with Output", func(t *testing.T) { f := createTmpFile(t, "foobar") - cmd := osexec.Command("md5sum", "-b", f.Name()) + cmd := osexec.Command("cat", f.Name()) rcmd := wrexec.RecordingWrap(ctx, logtest.Scoped(t), recordAlways, store, cmd) _, err := rcmd.Output() if err != nil { @@ -138,7 +138,7 @@ func TestRecordingCmd(t *testing.T) { }) t.Run("with Start and Wait", func(t *testing.T) { f := createTmpFile(t, "foobar") - cmd := osexec.Command("md5sum", "-b", f.Name()) + cmd := osexec.Command("cat", f.Name()) rcmd := wrexec.RecordingWrap(ctx, logtest.Scoped(t), recordAlways, store, cmd) // We record the size so that we can see the list did not change between calls @@ -207,8 +207,8 @@ func TestRecordingCmd(t *testing.T) { t.Run("two concurrent commands have seperate recordings", func(t *testing.T) { f1 := createTmpFile(t, "foobar") f2 := createTmpFile(t, "fubar") - cmd1 := osexec.Command("md5sum", "-b", f1.Name()) - cmd2 := osexec.Command("md5sum", "-b", f2.Name()) + cmd1 := osexec.Command("cat", f1.Name()) + cmd2 := osexec.Command("cat", f2.Name()) rcmd1 := wrexec.RecordingWrap(ctx, logtest.Scoped(t), recordAlways, store, cmd1) rcmd2 := wrexec.RecordingWrap(ctx, logtest.Scoped(t), recordAlways, store, cmd2) diff --git a/lib/codeintel/precise/diff/BUILD.bazel b/lib/codeintel/precise/diff/BUILD.bazel index feb23059d7e..3eb0023d46c 100644 --- a/lib/codeintel/precise/diff/BUILD.bazel +++ b/lib/codeintel/precise/diff/BUILD.bazel @@ -21,6 +21,6 @@ go_test( deps = [ "//lib/codeintel/lsif/conversion", "//lib/codeintel/precise", - "@com_github_hexops_autogold//:autogold", + "@com_github_hexops_autogold_v2//:autogold", ], ) diff --git a/migrations/BUILD.bazel b/migrations/BUILD.bazel index 9dcb029120f..043452f9a91 100644 --- a/migrations/BUILD.bazel +++ b/migrations/BUILD.bazel @@ -685,6 +685,54 @@ go_library( "frontend/1675962678_remove_action_namespace_perms/down.sql", "frontend/1675962678_remove_action_namespace_perms/metadata.yaml", "frontend/1675962678_remove_action_namespace_perms/up.sql", + "frontend/1676328864_add_cached_available_indexers/down.sql", + "frontend/1676328864_add_cached_available_indexers/metadata.yaml", + "frontend/1676328864_add_cached_available_indexers/up.sql", + "frontend/1676584791_add_index/down.sql", + "frontend/1676584791_add_index/metadata.yaml", + "frontend/1676584791_add_index/up.sql", + "frontend/1676996650_package_repos_separate_versions_table_patch1/down.sql", + "frontend/1676996650_package_repos_separate_versions_table_patch1/metadata.yaml", + "frontend/1676996650_package_repos_separate_versions_table_patch1/up.sql", + "frontend/1677003167_package_repos_separate_versions_table_stage2/down.sql", + "frontend/1677003167_package_repos_separate_versions_table_stage2/metadata.yaml", + "frontend/1677003167_package_repos_separate_versions_table_stage2/up.sql", + "frontend/1677005673_add_codeintel_rank_defintions_and_references/down.sql", + "frontend/1677005673_add_codeintel_rank_defintions_and_references/metadata.yaml", + "frontend/1677005673_add_codeintel_rank_defintions_and_references/up.sql", + "frontend/1677008591_add_codeintel_rank_path_counts_inputs/down.sql", + "frontend/1677008591_add_codeintel_rank_path_counts_inputs/metadata.yaml", + "frontend/1677008591_add_codeintel_rank_path_counts_inputs/up.sql", + "frontend/1677073533_add_codeowners_table/down.sql", + "frontend/1677073533_add_codeowners_table/metadata.yaml", + "frontend/1677073533_add_codeowners_table/up.sql", + "frontend/1677104938_move_processed_flag_out_of_references_table/down.sql", + "frontend/1677104938_move_processed_flag_out_of_references_table/metadata.yaml", + "frontend/1677104938_move_processed_flag_out_of_references_table/up.sql", + "frontend/1674754280_executor_job_tokens/down.sql", + "frontend/1674754280_executor_job_tokens/metadata.yaml", + "frontend/1674754280_executor_job_tokens/up.sql", + "frontend/1675850599_add_access_requests_table/down.sql", + "frontend/1675850599_add_access_requests_table/metadata.yaml", + "frontend/1675850599_add_access_requests_table/up.sql", + "frontend/1676272751_add_repo_embedding_jobs/down.sql", + "frontend/1676272751_add_repo_embedding_jobs/metadata.yaml", + "frontend/1676272751_add_repo_embedding_jobs/up.sql", + "frontend/1677242688_add_triggers_for_soft_deleted_perms_entities/down.sql", + "frontend/1677242688_add_triggers_for_soft_deleted_perms_entities/metadata.yaml", + "frontend/1677242688_add_triggers_for_soft_deleted_perms_entities/up.sql", + "frontend/1677594756_add_better_index_to_ranking_path_counts_table/down.sql", + "frontend/1677594756_add_better_index_to_ranking_path_counts_table/metadata.yaml", + "frontend/1677594756_add_better_index_to_ranking_path_counts_table/up.sql", + "frontend/1677627515_add_scan_column_to_ranking_definitionsreferences/down.sql", + "frontend/1677627515_add_scan_column_to_ranking_definitionsreferences/metadata.yaml", + "frontend/1677627515_add_scan_column_to_ranking_definitionsreferences/up.sql", + "frontend/1677627559_add_index_to_definition_scan_column/down.sql", + "frontend/1677627559_add_index_to_definition_scan_column/metadata.yaml", + "frontend/1677627559_add_index_to_definition_scan_column/up.sql", + "frontend/1677627566_add_index_to_reference_scan_column/down.sql", + "frontend/1677627566_add_index_to_reference_scan_column/metadata.yaml", + "frontend/1677627566_add_index_to_reference_scan_column/up.sql", ], importpath = "github.com/sourcegraph/sourcegraph/migrations", visibility = ["//visibility:public"],